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

James Bigler bigler at cs.utah.edu
Fri Feb 1 18:42:50 EST 2008


This is an example of something I have done:

   ADD_CUSTOM_COMMAND(OUTPUT ${c_file_name}
     COMMAND ${CMAKE_COMMAND}
     -DC_FILE:STRING="${c_file_name}" -DMEL_FILE:STRING="${source_file}"
     -DVARIABLE_NAME:STRING=${variable_name} - 
DNAMESPACE:STRING=MyNameSpacde
     -P ${my_cmake_script}
     DEPENDS ${source_file}
     DEPENDS ${my_cmake_script}
     COMMENT "${my_cmake_script}: converting ${source_file} to $ 
{c_file_name}"
     )

Make sure you put the arguments before theh -P ${my_cmake_script} or  
the arguments won't get passed in.

James

On Feb 1, 2008, at 3:36 PM, Matthew Woehlke wrote:

> I'm trying to write an X cursor generator using cmake. Because I  
> can create multiple sizes of cursors from a single config, I need  
> to generate config files as part of the build process. Currently,  
> I'm using a script that looks like this:
>
> awk \
> "{
>     printf \"%i %i %i \", (\$1*$3)/90, (\$2*$3)/90, (\$3*$3)/90 ;
>     if (NF > 4) printf \"%s %i\n\", \$4, \$5 ; else printf \"%s\n 
> \", \$4
> }" < $1 > $2
>
> I'd like to remove the awk dependency by using a cmake script  
> instead, but I couldn't figure out how to tell the script what  
> parameters it should run with.
>
> Suggestions?
>
> -- 
> Matthew
> "It's impossible! But... do-able."
>   -- Robert MacDougal (Sean Connery, Entrapment)
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list