Properly updates cmake revision numbers.

Rewrote the code and should properly work with out-of-tree builds and
also no longer causing unneeded recompilations if the version number
didn't change. Fixes bug #16483.
This commit is contained in:
Mark de Wever 2010-10-02 09:50:39 +00:00
parent 856f187e4f
commit dde1f99f9c
3 changed files with 16 additions and 13 deletions

View file

@ -53,6 +53,7 @@ Version 1.9.1+svn:
* Miscellaneous and bugfixes:
* Changed: Lowered severity of some gui2 timer log messages.
* Units created in debug mode now play their recruit animation (FR #16766)
* Fixed: properly update cmake revision numbers (bug #16483)
Version 1.9.1:
* AI:

View file

@ -1,6 +1,6 @@
if (EXISTS revision-stamp)
file(READ revision-stamp OLD_VERSION)
endif (EXISTS revision-stamp)
if (EXISTS revision.hpp)
file(READ revision.hpp OLD_VERSION)
endif (EXISTS revision.hpp)
execute_process(COMMAND ${SVNVERSION_EXECUTABLE} -n ${SRC_DIR}
OUTPUT_VARIABLE SVN_VERSION)
@ -8,7 +8,7 @@ execute_process(COMMAND ${SVNVERSION_EXECUTABLE} -n ${SRC_DIR}
if(SVN_VERSION MATCHES [0-9]+.*)
if(NOT OLD_VERSION MATCHES ".*\"${SVN_VERSION}\".*")
file(WRITE revision-stamp "#define REVISION \"${SVN_VERSION}\"\n")
file(WRITE revision.hpp "#define REVISION \"${SVN_VERSION}\"\n")
endif(NOT OLD_VERSION MATCHES ".*\"${SVN_VERSION}\".*")
endif(SVN_VERSION MATCHES [0-9]+.*)

View file

@ -140,19 +140,18 @@ if(SVNVERSION_EXECUTABLE)
execute_process(COMMAND ${SVNVERSION_EXECUTABLE} -n ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE SVN_VERSION)
if(SVN_VERSION MATCHES [0-9]+.*)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/revision-stamp
add_custom_target(update_revision ALL
COMMAND ${CMAKE_COMMAND}
-DSVNVERSION_EXECUTABLE="${SVNVERSION_EXECUTABLE}" -DSRC_DIR="${CMAKE_SOURCE_DIR}"
-P "${CMAKE_MODULE_PATH}/revision.cmake"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-DSVNVERSION_EXECUTABLE="${SVNVERSION_EXECUTABLE}"
-DSRC_DIR="${CMAKE_SOURCE_DIR}"
-P "${CMAKE_MODULE_PATH}/revision.cmake"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Updating revision")
add_custom_command(OUTPUT revision.hpp
COMMAND ${CMAKE_COMMAND}
-E copy ${CMAKE_CURRENT_BINARY_DIR}/revision-stamp ${CMAKE_CURRENT_SOURCE_DIR}/revision.hpp
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/revision-stamp)
set(REVISION_FILE revision.hpp)
set_source_files_properties(
revision.hpp
PROPERTIES GENERATED true)
add_definitions(-DHAVE_REVISION)
endif(SVN_VERSION MATCHES [0-9]+.*)
endif(SVNVERSION_EXECUTABLE)
@ -230,6 +229,9 @@ endif(ENABLE_POOL_ALLOC AND NOT WIN32)
# internal reference is the name given here
add_library(wesnoth-core STATIC EXCLUDE_FROM_ALL ${libwesnoth-core_STAT_SRC})
if(SVNVERSION_EXECUTABLE)
add_dependencies(wesnoth-core update_revision)
endif(SVNVERSION_EXECUTABLE)
########### libwesnoth-lua ###############