Problem: execution of imported target returns a No such file or directory
message.
find_package( Python3 )
if( Python3_FOUND )
execute_process(
COMMAND Python3::Interpreter --version
RESULT_VARIABLE res
OUTPUT_VARIABLE out
)
message( "this message: ${res}" )
endif()
results in: this message: No such file or directory
The package is found correctly and its targets are accessible during build. It is just that, execute_process
does not seem to have access to it.
My first thought was that execute_process
does not have this target during configuration because it might be run before the package is found. This is why I added the _FOUND
condition. I thought it would then run correctly in a second iteration at configure time. It did not.
I cannot see the call to python anywhere in my verbose build output.
everything works fine using the cache variable, instead of the target:
```cmake
find_package( Python3 )
if( Python3_FOUND )
execute_process(
COMMAND ${Python3_EXECUTABLE} --version
RESULT_VARIABLE res
OUTPUT_VARIABLE out
)
message( "this message: ${res}" )
endif()
This confirms that configure stage works as expected. It seems as if there was a problem with the imported target during configuration. Generally speaking, this shouldn’t be a problem, though.