[CMake] How to do that w/o LOCATION property of a target...

Petr Kmoch petr.kmoch at gmail.com
Sat Sep 5 04:38:04 EDT 2015


Hi Alex.

I don't know if there is a better solution, but the following workaround
should work for you:

In your normal CMakeList, do `file(GENERATE OUTPUT location.cmake CONTENT
"set(TheLocation \"$<TARGET_FILE:TheTarget>\")\n")`.
Then, in the configured *.cmake script, do `include(location.cmake)`. The
location of the target will then be stored in the variable `TheLocation`.

Alternatively, generate just the location and use `file(READ)` instead of
`include()`, whichever suits you better.

Petr

On Sat, Sep 5, 2015 at 8:22 AM, Alex Turbov <i.zaufi at gmail.com> 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()`
>
> any other idea?
>
>
>
> --
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150905/3089ac9e/attachment.html>


More information about the CMake mailing list