Adds autorevision based revision numbers.

This commit adds the support for CMake.
This commit is contained in:
Mark de Wever 2013-03-15 20:28:52 +00:00
parent 8016efa3fb
commit 43f617179e
4 changed files with 55 additions and 2 deletions

View File

@ -82,6 +82,18 @@ option(ENABLE_NLS "Enable building of translations" ON)
option(ENABLE_LOW_MEM "Reduce memory usage by removing extra functionality" OFF)
option(ENABLE_OMP "Enables OpenMP, and has additional dependencies" OFF)
if(NOT UNIX)
set(DEFAULT_ENABLE_DISPLAY_REVISION false)
else()
set(DEFAULT_ENABLE_DISPLAY_REVISION true)
endif()
option(
ENABLE_DISPLAY_REVISION
"Enable the display of the revision number in the game"
${DEFAULT_ENABLE_DISPLAY_REVISION}
)
# The use of shared libraries makes compilation debug versions faster but
# results in extra shared libraries. For installation this is not practical
# since the libraries need to be given SONAMES and kept in sync. Therefore

View File

@ -110,6 +110,7 @@ Version 1.11.1+svn:
* Fixed wmllint, wmlscope and wmlindent not working correctly on Windows if a
command line argument ends with a backslash
* Fixed: Compilation with CLang 3.2 and libc++.
* Added: Autorevision based revision numbers in CMake.
Version 1.11.1:
* AI:

View File

@ -139,7 +139,7 @@ endif(X11_FOUND)
find_program(SVNVERSION_EXECUTABLE "svnversion")
set(REVISION_FILE)
if(SVNVERSION_EXECUTABLE)
if(SVNVERSION_EXECUTABLE AND NOT ENABLE_DISPLAY_REVISION)
execute_process(COMMAND ${SVNVERSION_EXECUTABLE} -n ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE SVN_VERSION)
if(SVN_VERSION MATCHES [0-9]+.*)
@ -159,7 +159,7 @@ if(SVNVERSION_EXECUTABLE)
set(UPDATE_REVISION ON CACHE INTERNAL "")
endif(SVN_VERSION MATCHES [0-9]+.*)
endif(SVNVERSION_EXECUTABLE)
endif()
if(MSVC)
SOURCE_GROUP("src" REGULAR_EXPRESSION ".*")
@ -244,6 +244,39 @@ if(UPDATE_REVISION)
add_dependencies(wesnoth-core update_revision)
endif(UPDATE_REVISION)
# Depending on the flag create a real file or an empty dummy.
#
# Since the code is executed every build run of Wesnoth we need to make sure
# that no modifications don't turn into a rebuild. Therefore a the dummy is
# created and the second target only copies the file if modified.
if(ENABLE_DISPLAY_REVISION)
add_custom_target(wesnoth-revision_dummy
COMMAND
${CMAKE_SOURCE_DIR}/utils/autorevision
-th
> ${CMAKE_CURRENT_BINARY_DIR}/revision.dummy
WORKING_DIRECTORY
${CMAKE_SOURCE_DIR}
)
add_custom_target(wesnoth-revision
COMMAND
${CMAKE_COMMAND} -E
copy_if_different
${CMAKE_CURRENT_BINARY_DIR}/revision.dummy
${CMAKE_CURRENT_BINARY_DIR}/revision.h
)
add_dependencies(wesnoth-revision wesnoth-revision_dummy)
add_dependencies(wesnoth-core wesnoth-revision)
set_source_files_properties(
game_config.cpp
PROPERTIES
COMPILE_DEFINITIONS "LOAD_REVISION"
)
endif()
########### libwesnoth-lua ###############
set(libwesnoth-lua_STAT_SRC

View File

@ -27,6 +27,9 @@
#ifdef HAVE_REVISION
#include "revision.hpp"
#endif /* HAVE_REVISION */
#ifdef LOAD_REVISION
#include "revision.h"
#endif
#include <boost/foreach.hpp>
@ -51,6 +54,10 @@ namespace game_config
std::string default_terrain;
#ifdef REVISION
const std::string revision = VERSION " (" REVISION ")";
#elif defined(VCS_SHORT_HASH) && defined(VCS_WC_MODIFIED)
const std::string revision
= std::string(VCS_SHORT_HASH)
+ (VCS_WC_MODIFIED ? "-Modified" : "-Clean");
#else
const std::string revision = VERSION;
#endif