[CMake] passing arguments to the final make

Michael Hertling mhertling at online.de
Thu Feb 23 01:20:29 EST 2012


On 02/23/2012 12:04 AM, John Drescher wrote:
>> And another thing, is it actually \${SCRIPT} a portable solution that works
>> on all the generators?
>>
> 
> This is not about generators but about what shell you are running
> cmake from. For example that would not work on windows since the
> command prompt has a different syntax for variables.

The point is that ${SCRIPT} is substituted in the Makefile by

(1) a macro specified on the command line
(2) a macro specified in the Makefile
(3) an environment variable

in that order, or with (2) and (3) reversed if Make is invoked with the
"-e" switch. When the Makefile's command lines are passed to the shell,
the substitution has already taken place, so it should also work with
the Windows command prompt. However, one needs a Make program, i.e. a
parameterization of this kind probably doesn't work with non-Makefile
generators. Even with Makefiles, there are subtle pitfalls: If a line
"SCRIPT = ..." happens to appear somewhere in the Makefiles, invoking
Make as "make SCRIPT=..." will overwrite it, most certainly resulting
in surprising and undesired behaviour. Personally, I'd advise against
using this method without explicit support by the Makefile generator.

Regards,

Michael


More information about the CMake mailing list