On 08/01/2011 07:13 PM, The Novice Coder wrote:
The short version of what I'm trying to do:
Add some kind of definition to the cmake file that specifies a file,
that if modified, will cause the project to be regenerated.
Longer (more specific) version.
We (our small program team) want's to use cmake to generate a file
svn_version.h, which has a solution posted on the web. The problem
happens when we checkout new revisions, this file goes unmodified.
Looking for a way to cause CMake to regenerate the build files (and with
it, the revision number) after an svn up command, without having to
touch cmakelists.txt. It would be trivial to simply check files in the
.svn folder for modification times, so that would probably be the
easiest (although not 100% accurate) way to go.
Any help on where to look... Thanks!
The usual solution is a custom target which (re)generates svn_version.h
if necessary, i.e. if it would change, to mark it as GENERATED and have
the other targets depend on that custom one. In this way, svn_version.h
is always up-to-date, doesn't trigger unnecessary rebuilds and can be
used normally without invalidating the build files and rebuilding the
whole project subsequently. E.g., you might use a CMake script calling
CONFIGURE_FILE() to regenerate svn_version.h from a template to ensure
it doesn't get touched if nothing has changed:
ADD_CUSTOM_TARGET(svn_version
${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/svn_version.cmake
)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/svn_version.h
PROPERTIES GENERATED TRUE
)
FOREACH(i target_1 target_2 ... target_n)
ADD_DEPENDENCIES(${i} svn_version)
ENDFOREACH()
# svn_version.cmake:
# set up variables
CONFIGURE_FILE(path/to/svn_version.h.in path/to/svn_version.h)
Do you have special requirements because of which you definitely
need the build files regenerated, i.e. the project reconfigured
and rebuilt instead of just updating svn_version.h?
Regards,
Michael
___
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