[CMake] How to do that w/o LOCATION property of a target...
Gregor Jasny
gjasny at googlemail.com
Sat Sep 5 15:16:29 EDT 2015
On 05/09/15 08:22, Alex Turbov wrote:
> Hi,
>
> in my project I have `add_executable()`. after that, in a current binary
> dir I need to render a `*.cmake` script (via `configure_file()`) to be
> running from `add_test()` (as `cmake -P`) which should start just the
> compiled executable via `execute_process()` and capture its output (to be
> processed by followed commands)...
>
> the problem is: how to render an absolute path to the compiled executable
> inside the generated `*.cmake` script ??
> 0) access to LOCATION target property is prohibited from CMakeLists.txt, so
> I can't set it into a generated script
> 1) generator expressions don't work w/ `configure_file()`
If you use the add_test(NAME <name> COMMAND <command>) signature you can
use generator expressions.
You could pass the executable directory as a parameter to the script:
add_test(NAME myTest COMMAND ${CMAKE_COMMAND}
-DMY_EXECUATABLE=$<TARGET_FILE:myTarget> -P my_script.cmake)
In the script use ${MY_EXECUATABLE}.
Hope this helps,
Gregor
More information about the CMake
mailing list