# HG changeset patch # User Akos Ladanyi # Date 2009-05-29 12:40:53 # Node ID d1e1cd94bf49d75657dde71a3557a267acbf0644 # Parent a0265f621d393d765cb5a476a729f77d1388cc15 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. diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,24 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -IF(EXISTS ${CMAKE_SOURCE_DIR}/cmake/version.cmake) - INCLUDE(${CMAKE_SOURCE_DIR}/cmake/version.cmake) -ELSE(EXISTS ${CMAKE_SOURCE_DIR}/cmake/version.cmake) - SET(PROJECT_NAME "LEMON") - SET(PROJECT_VERSION "hg-tip" CACHE STRING "LEMON version string.") -ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/cmake/version.cmake) +SET(PROJECT_NAME "LEMON") +PROJECT(${PROJECT_NAME}) -PROJECT(${PROJECT_NAME}) +IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake) + INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake) +ELSEIF(DEFINED ENV{LEMON_VERSION}) + SET(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.") +ELSE() + EXECUTE_PROCESS( + COMMAND hg id -i + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE HG_REVISION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + SET(LEMON_VERSION ${HG_REVISION} CACHE STRING "LEMON version string.") +ENDIF() + +SET(PROJECT_VERSION ${LEMON_VERSION}) SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) diff --git a/cmake/version.cmake.in b/cmake/version.cmake.in --- a/cmake/version.cmake.in +++ b/cmake/version.cmake.in @@ -1,2 +1,1 @@ -SET(PROJECT_NAME "@PACKAGE_NAME@") -SET(PROJECT_VERSION "@PACKAGE_VERSION@" CACHE STRING "LEMON version string.") +SET(LEMON_VERSION "@PACKAGE_VERSION@" CACHE STRING "LEMON version string.") diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -19,6 +19,8 @@ AC_CONFIG_SRCDIR([lemon/list_graph.h]) AC_CONFIG_HEADERS([config.h lemon/config.h]) +AC_DEFINE([LEMON_VERSION], [lemon_version()], [The version string]) + dnl Do compilation tests using the C++ compiler. AC_LANG([C++]) diff --git a/lemon/config.h.cmake b/lemon/config.h.cmake --- a/lemon/config.h.cmake +++ b/lemon/config.h.cmake @@ -1,3 +1,4 @@ +#define LEMON_VERSION "@PROJECT_VERSION@" #cmakedefine LEMON_HAVE_LONG_LONG 1 #cmakedefine LEMON_HAVE_LP 1 #cmakedefine LEMON_HAVE_MIP 1 diff --git a/lemon/config.h.in b/lemon/config.h.in --- a/lemon/config.h.in +++ b/lemon/config.h.in @@ -1,3 +1,6 @@ +/* The version string */ +#undef LEMON_VERSION + /* Define to 1 if you have long long */ #undef LEMON_HAVE_LONG_LONG