[CMake] Environment variable for a custom command

Bill Hoffman bill.hoffman at kitware.com
Fri Aug 15 11:45:44 EDT 2008


Gregory C. Sharp wrote:
> Bill Hoffman wrote:
>> Gregory C. Sharp wrote:
>>>
>>> I found this little tidbit in the FAQ:
>>>
>>>   [E]nvironment variables SET in the CMakeLists.txt only take
>>>   effect for cmake itself, so you cannot use this method to set
>>>   an environment variable that a custom command might need.
>>>
>>> I would like to augment the path during a custom command.
>>> Is there a suggested workaround?
>>>
>> Run a cmake script in the custom command that runs the program via 
>> execute_process.
> 
> OK.  I might need another hint though.  I try this:
> 
>   MACRO(RUNME)
>     EXECUTE_PROCESS(...)
>   ENDMACRO(RUNME)
> 
>   ADD_CUSTOM_COMMAND(OUTPUT output COMMAND RUNME ...)
> 
> Which yields:
> 
>   1> 'RUNME' is not recognized as an internal or external command
> 
> -Greg
add_custom_command(OUTPUT output COMMAND ${CMAKE_COMMAND} -S myscript.cmake)

myscript.cmake:
set(ENV{PATH} ...)
execute_process(....)


-Bill

-- 
Bill Hoffman
Kitware, Inc.
28 Corporate Drive
Clifton Park, NY 12065
bill.hoffman at kitware.com
http://www.kitware.com
518-371-3971 (phone and fax)


More information about the CMake mailing list