[CMake] CONFIGURE_FILE output not cleaned up
Brad King
brad.king at kitware.com
Fri Aug 25 12:22:38 EDT 2006
Eduard Bloch wrote:
> CONFIGURE_FILE is used (see below) to adopt an autoconf-style config
> file, however the result is not cleaned up when the clean target is run.
> It is not that bad as long as the generated file is not shipped and so
> the generation is triggered on users machine, but when something
> unexpected happens then the build will get xconfig.h with wrong
> contents.
[snip]
> How can I make sure that autogenerated files are removed? I tried
> setting ADDITIONAL_MAKE_CLEAN_FILES even with complete path, it does not
> help.
[snip]
> CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/xconfig.h.in ${CMAKE_CURRENT_SOURCE_DIR}/xconfig.h)
With an out of source build no generated file can ever be shipped with
the source. You should configure the file to
${CMAKE_CURRENT_BINARY_DIR}/xconfig.h instead. Then you don't have to
worry about whether it is cleaned out of the source tree.
> SET_SOURCE_FILES_PROPERTIES(xconfig.h PROPERTIES GENERATED 1)
This is not necessary. This property is only for outputs of
ADD_CUSTOM_COMMAND, and it is now automatically added in that case.
What documentation did you read that mentioned this?
> SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_SOURCE_DIR}/xconfig.h ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_SOURCE_DIR}/align.h)
The ADDITIONAL_MAKE_CLEAN_FILES property is a string. You have to
append the list yourself and then reference the variable:
LIST(APPEND tmps ${CMAKE_CURRENT_SOURCE_DIR}/xconfig.h
${CMAKE_CURRENT_SOURCE_DIR}/align.h)
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${tmps}")
-Brad
More information about the CMake
mailing list