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

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to