[CMake] Feature request (with patch): add #cmakedefine-like directive without #define

Pau Garcia i Quiles pgquiles at elpauer.org
Wed Jan 23 06:14:09 EST 2008


Hello,

CMake allows to customize header files by using CONFIGURE_FILE and
"#cmakedefine variable value", which generates "#define variable value".

It would be nice if we had something like #cmakedefine but for
arbitrary files which only wrote the value. For example: "#cmakewrite
my_text", which would generate "my_text".

Use case: combined use of configuration files and INSTALL directives.
I need to specify the application directory both in pfsi.conf and in
CMakeLists.txt for INSTALL( FILES ${PROJECT_SOURCE_DIR}/pfsi.png
DESTINATION ${CMAKE_INSTALL_PREFIX}/{PFSI_APP_DIR} ).

For example, the configuration file pfsi.conf.cmake could then be:
--------------------
[global]

#cmakewrite application_directory = ${PFSI_APP_DIR}

[shared_folders]

digest = /usr/wt/pfsi/htdigest-pfsi
shared_folders_directory = /media/tragabytes/webdav
---------------------

As I have a SET( ${PFSI_APP_DIR} /usr/wt/pfsi ), the output would be:

---------------------
[global]

application_directory = /usr/wt/pfsi

[shared_folders]

digest = /usr/wt/pfsi/htdigest-pfsi
shared_folders_directory = /media/tragabytes/webdav
---------------------

I know this can the done with FILE but I think the use case is
common enough, and the implementation simple enough, to add this
feature.

I've opened an issue in the bug tracker  
(http://www.cmake.org/Bug/view.php?id=6266) and attached a patch which  
add the requested feature.

-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)




More information about the CMake mailing list