On 02/22/2012 04:43 PM, Andrea Crotti wrote:
> I would like to be able to pass arguments to my generated Makefile.
> 
> Suppose I use an environment variable like this:
> 
> add_custom_target(run_dev_script
>    COMMAND ${PYTHON_EXECUTABLE} ${PREREQUISITE}
>    COMMAND ${PYTHON_EXECUTABLE} ${SCRIPT}
>    )
> 
> Would that actually work?
> In theory ${SCRIPT} is substituted at cmake time, so I have the 
> impression that it wouldn't work..
> I don't find anything useful in cmake -E however, that would allow me to 
> do something at make time.
> Any suggestions?

CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(P NONE)
ADD_CUSTOM_TARGET(echo ${CMAKE_COMMAND} -E echo \${ECHO})

After initial configuration:

% make echo ECHO="Hello World"
Scanning dependencies of target echo
Hello World
Built target echo
% make echo ECHO="Goodbye World"
Goodbye World
Built target echo

% make echo ECHO="Regards, Michael"
Regards, Michael
Built target echo
--

Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to