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)