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

Jörg Kreuzberger j.kreuzberger at procitec.de
Fri Apr 11 06:56:33 EDT 2014


ok, biggest hint here was the tip for $<TARGET_FILE:..>. This was new to me (am new to cmake at all).
Thanks.

My major problem is still passing the additonal PATH elements to the cmake script, cause they will always expanded in an space seperated list.

So if i add -DENV_PATH="${QT_LIBRARY_DIR};${INTELIPP_LIBRARY_DIR}"
and assign it to $ENV{PATH} in my cmake script, is will always remove the semikolons

i have tried 

set( $ENV{PATH} "$ENV{PATH};${ENV_PATH}" )

and 

set( $ENV{PATH} "$ENV{PATH}\\;${ENV_PATH}" )

i have tried to REPLACE every occureny of ";" in ${ENV_PATH} with "\\;" for escaping, but this will also not work.



-----Ursprüngliche Nachricht-----
Von:	Nils Gladitz <nilsgladitz at gmail.com>
Gesendet:	Fr 11.04.2014 12:05
Betreff:	Re: [CMake] Custom Commands and Environmnt Settings for PATH and LD_LIBRARY_PATH
An:	Jörg Kreuzberger <j.kreuzberger at procitec.de>; cmake at cmake.org; 
> 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