[CMake] Custom Commands and Environmnt Settings for PATH and LD_LIBRARY_PATH

Nils Gladitz nilsgladitz at gmail.com
Fri Apr 11 06:03:22 EDT 2014


On 04/11/2014 11:32 AM, Jörg Kreuzberger wrote:
> After reading serveral threads i ended in this solution
>
> - create a batch/shell script for the command i want to start. This ensures path modifications are local. Creation is done via a configure_file step
>

I would run a cmake script with ${CMAKE_COMMAND} -P.
The script can use set(ENV{VAR}) and execute_process().
This has the advantage of being more portable than bash or batch scripts.

You can pass parameters to the script with -D (have to be listed before -P).

One of those parameters can be a generator expression that will expand 
to the location of the actual target to be executed. e.g. 
$<TARGET_FILE:tgt> [1] will be replaced with the full path of the target.

Nils

[1] 
http://www.cmake.org/cmake/help/git-master/manual/cmake-generator-expressions.7.html#informational-expressions


More information about the CMake mailing list