[CMake] Disabling Argument Parsing in CMake -P Scripts

Eskandar Ensafi Ensafi at SpaceComputer.Com
Fri Nov 2 00:21:49 EDT 2012


Hello,

I often find it very useful to run CMake scripts of the form "cmake -P script-name arg1 arg2 ..." as a cross-platform scripting solution that doesn't rely on Perl, Python, etc.  One major limitation is that CMake continues to parse all arguments after the script name.  For example, if arg1 is "-i" then CMake will enter wizard mode before executing the script, and options such as "-D", "-G" and "-L" will be parsed and removed from the command-line by CMake.  The current behavior limits the flexibility of CMake's script mode by making it impossible to pass arbitrary options to be parsed directly by the script.

It would be great if I could somehow specify "cmake -P script-name -- arg1 arg2 ..." to tell CMake to stop parsing all subsequent arguments while still placing arg1, arg2, etc. in the CMAKE_ARGVn variables.  If the "--" flag is potentially problematic and may pose compatibility problems, perhaps another syntax can be adopted, such as "cmake -PP script-name arg1 arg2 ..." where -P is doubled.

Is this something that can be easily implemented?

Best,

Eskandar


More information about the CMake mailing list