2012/5/9 Jensen, Erik A <[email protected]>:
> That worked, although a little roundabout. Thank you.
>
> Would there be any interest in having an easier way to do this? It seems like 
> it could be usefully in a fair number of situations.
>
> Maybe an additional -E command:
> cmake -E configure_file -D var1=value1 -D var2=value2 --at-only infile outfile

Not that much simpler than the following example.

> Or even a way to run arbitrary CMake commands without a script file:
> cmake -D var1=value1 -D var2=value2 -R "configure_file(infile outfile @ONLY)"
>
> This would make it possible to avoid having a whole other file just to 
> execute one CMake command at build time.
>
> Thoughts?

Is it really simpler than writing your own simple (or complicated)
script once and launching:

cmake -DINFILE=blah.in  -DOUTFILE=blah.out -Dvar1=value1 -Dvar2=value2
-DCOPYONLY=1 -P GenericConfigureFile.cmake

this command may be launched in add_custom_command and you can spare the first
configure_file if you pass all the value you need with -D on the command line.

One option that could be nice would be a way to inherit CMake-time
defined values
at Build-time in order to spare much of "-Dvar1=value1" argument.

Something like a new CMake command that would dump in a file the definition
of the currently defined vars

variables_save(FILE ${CMAKE_CURRENT_BINARY_DIR}/myvarset.cmake)
then you would be able to do
variables_load(FILE /path/to/myvarset.cmake)
and get the previously saved vars defintions.

May be variables_save could take a list of vars as argument:
variables_save(VARS MyVar1 MyVar2 FILE ${CMAKE_CURRENT_BINARY_DIR}/myset.cmake)

I think this should even be doable as CMake macro.
variables_load may simply be
include(/path/to/myvarset.cmake)

-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org

Attachment: GenericConfigureFile.cmake
Description: Binary data

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to