[CMake] Re: How to pass arguments to 'cmake -P' scripts?

Matthew Woehlke mw_triad at users.sourceforge.net
Fri Feb 1 19:19:48 EST 2008


Ick. Please, no http://www.cygwin.com/acronyms#TOFU.

James Bigler wrote:
> Matthew Woehlke wrote:
>> but I couldn't figure out how to tell the script what parameters it 
>> should run with.
> 
> [snip]
> Make sure you put the arguments before theh -P ${my_cmake_script} or the 
> arguments won't get passed in.

Ah, so *that's* what I was doing wrong. Sigh. It would be really nice if 
'man cmake' documented that (in fact, if it just plain documented that 
yes, you /can/ pass defines into a -P script).

Maybe like this?

SYNOPSIS
   cmake [options] <path-to-source>
   cmake [options] <path-to-existing-build>
   cmake [options] -P <file>
   cmake -E [command]

-P <file>
   Process script mode.

   Process the given cmake file as a script written in the CMake 
language.  No configure or generate step is performed and the cache is 
not modified. Arguments may be passed to the script as CMake variables 
by using -D. -P should be the last option on the command line.

Better yet, fix this restriction in 2.6.0? I wanted to do something like:

set(FOO_SCRIPT foo.cmake)
set(FOO ${CMAKE_COMMAND} -P ${FOO_SCRIPT})

add_custom_command(OUTPUT moo
                    DEPENDS cow ${FOO_SCRIPT}
                    COMMAND ${FOO} -Dhay=straw
                   )

...but alas, it is not possible.

-- 
Matthew
"It's impossible! But... do-able."
   -- Robert MacDougal (Sean Connery, Entrapment)



More information about the CMake mailing list