[CMake] svn info from cmake script?
Brad King
brad.king at kitware.com
Tue Jul 25 09:26:36 EDT 2006
Abe Stephens wrote:
> How can I have a CMake script run if a certain non-source file has
> changed since the last project build?
>
> I have a script which extracts some revision information from "svn info"
> and places it in a source file via CONFIGURE_FILE. I'd like this script
> to be executed during build every time the
> ${CMAKE_SOURCE_DIR}/.svn/entries file changes. (This file is altered
> every time I commit a file or update from the repository.)
# Configure the script to know where to put the output file.
# It should reference @MYSCRIPT_OUTPUT@ to get this variable setting.
SET(MYSCRIPT_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/myoutput.txt)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/myscript.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/myscript.cmake)
# Add a custom command to drive the script whenever the svn entries
# file changes.
ADD_CUSTOM_COMMAND(
OUTPUT ${MYSCRIPT_OUTPUT}
DEPENDS ${CMAKE_SOURCE_DIR}/.svn/entries
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/myscript.cmake
)
# Add a custom target to drive the custom command.
ADD_CUSTOM_TARGET(svn_check ALL DEPENDS ${MYSCRIPT_OUTPUT})
-Brad
More information about the CMake
mailing list