Put the version string into config.h
authorAkos Ladanyi <ladanyi@tmit.bme.hu>
Fri, 29 May 2009 11:40:53 +0100
changeset 678d1e1cd94bf49
parent 677 a0265f621d39
child 679 9c7639f3a741
Put the version string into config.h

Also make it possible to set the version using the LEMON_VERSION environment
variable, and use the hg revision as version string in case this variable is
unset.
CMakeLists.txt
cmake/version.cmake.in
configure.ac
lemon/config.h.cmake
lemon/config.h.in
     1.1 --- a/CMakeLists.txt	Fri May 29 10:35:05 2009 +0100
     1.2 +++ b/CMakeLists.txt	Fri May 29 11:40:53 2009 +0100
     1.3 @@ -1,13 +1,24 @@
     1.4  CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
     1.5  
     1.6 -IF(EXISTS ${CMAKE_SOURCE_DIR}/cmake/version.cmake)
     1.7 -  INCLUDE(${CMAKE_SOURCE_DIR}/cmake/version.cmake)
     1.8 -ELSE(EXISTS ${CMAKE_SOURCE_DIR}/cmake/version.cmake)
     1.9 -  SET(PROJECT_NAME "LEMON")
    1.10 -  SET(PROJECT_VERSION "hg-tip" CACHE STRING "LEMON version string.")
    1.11 -ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/cmake/version.cmake)
    1.12 +SET(PROJECT_NAME "LEMON")
    1.13 +PROJECT(${PROJECT_NAME})
    1.14  
    1.15 -PROJECT(${PROJECT_NAME})
    1.16 +IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
    1.17 +  INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
    1.18 +ELSEIF(DEFINED ENV{LEMON_VERSION})
    1.19 +  SET(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.")
    1.20 +ELSE()
    1.21 +  EXECUTE_PROCESS(
    1.22 +    COMMAND hg id -i
    1.23 +    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
    1.24 +    OUTPUT_VARIABLE HG_REVISION
    1.25 +    ERROR_QUIET
    1.26 +    OUTPUT_STRIP_TRAILING_WHITESPACE
    1.27 +  )
    1.28 +  SET(LEMON_VERSION ${HG_REVISION} CACHE STRING "LEMON version string.")
    1.29 +ENDIF()
    1.30 +
    1.31 +SET(PROJECT_VERSION ${LEMON_VERSION})
    1.32  
    1.33  SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
    1.34  
     2.1 --- a/cmake/version.cmake.in	Fri May 29 10:35:05 2009 +0100
     2.2 +++ b/cmake/version.cmake.in	Fri May 29 11:40:53 2009 +0100
     2.3 @@ -1,2 +1,1 @@
     2.4 -SET(PROJECT_NAME "@PACKAGE_NAME@")
     2.5 -SET(PROJECT_VERSION "@PACKAGE_VERSION@" CACHE STRING "LEMON version string.")
     2.6 +SET(LEMON_VERSION "@PACKAGE_VERSION@" CACHE STRING "LEMON version string.")
     3.1 --- a/configure.ac	Fri May 29 10:35:05 2009 +0100
     3.2 +++ b/configure.ac	Fri May 29 11:40:53 2009 +0100
     3.3 @@ -19,6 +19,8 @@
     3.4  AC_CONFIG_SRCDIR([lemon/list_graph.h])
     3.5  AC_CONFIG_HEADERS([config.h lemon/config.h])
     3.6  
     3.7 +AC_DEFINE([LEMON_VERSION], [lemon_version()], [The version string])
     3.8 +
     3.9  dnl Do compilation tests using the C++ compiler.
    3.10  AC_LANG([C++])
    3.11  
     4.1 --- a/lemon/config.h.cmake	Fri May 29 10:35:05 2009 +0100
     4.2 +++ b/lemon/config.h.cmake	Fri May 29 11:40:53 2009 +0100
     4.3 @@ -1,3 +1,4 @@
     4.4 +#define LEMON_VERSION "@PROJECT_VERSION@"
     4.5  #cmakedefine LEMON_HAVE_LONG_LONG 1
     4.6  #cmakedefine LEMON_HAVE_LP 1
     4.7  #cmakedefine LEMON_HAVE_MIP 1
     5.1 --- a/lemon/config.h.in	Fri May 29 10:35:05 2009 +0100
     5.2 +++ b/lemon/config.h.in	Fri May 29 11:40:53 2009 +0100
     5.3 @@ -1,3 +1,6 @@
     5.4 +/* The version string */
     5.5 +#undef LEMON_VERSION
     5.6 +
     5.7  /* Define to 1 if you have long long */
     5.8  #undef LEMON_HAVE_LONG_LONG
     5.9