[CMake] passing arguments to the final make

Andrea Crotti andrea.crotti.0 at gmail.com
Wed Feb 22 12:32:23 EST 2012


On 02/22/2012 05:25 PM, Michael Hertling wrote:
> 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

Ah that's nice thanks, I'm not sure though that I can rely on being >= 
2.8 always,
and that's probably a requirement, right?



More information about the CMake mailing list