diff options
-rw-r--r-- | CMakeLists.txt | 22 | ||||
-rw-r--r-- | config.h.cmake.in | 4 | ||||
-rw-r--r-- | libcrystfel/CMakeLists.txt | 2 | ||||
-rw-r--r-- | libcrystfel/config.h.cmake.in | 2 |
4 files changed, 22 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bb37e05..8537b005 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required(VERSION 3.6) -set(CRYSTFEL_VERSION 0.7.0) +set(CRYSTFEL_SHORT_VERSION 0.7.0) +set(CRYSTFEL_VERSION ${CRYSTFEL_SHORT_VERSION}) set(CRYSTFEL_API_VERSION 10) project(crystfel VERSION ${CRYSTFEL_VERSION} LANGUAGES C) @@ -29,9 +30,22 @@ set(CMAKE_C_STANDARD 99) set(COMMON_INCLUDES ${HDF5_INCLUDE_DIRS}) set(COMMON_LIBRARIES libcrystfel m GSL::gsl Threads::Threads) -include(GetGitRevisionDescription) -get_git_head_revision(GIT_REFSPEC GIT_SHA1) -string(SUBSTRING ${GIT_SHA1} 0 8 GIT_SHA1) +if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git) + # If this is a Git checkout, add the revision ID + message(STATUS "This is a Git checkout: adding revision ID to version number") + include(GetGitRevisionDescription) + get_git_head_revision(GIT_REFSPEC GIT_SHA1) + string(SUBSTRING ${GIT_SHA1} 0 8 GIT_SHA1) + set(CRYSTFEL_VERSION "${CRYSTFEL_VERSION}+${GIT_SHA1}") +else () + if (DEFINED CRYSTFEL_SNAPSHOT_ID) + message(STATUS "This is a packaged snapshot: adding snapshot ID to version number") + set(CRYSTFEL_VERSION ${CRYSTFEL_VERSION}+${CRYSTFEL_SNAPSHOT_ID}) + else () + message(STATUS "This is a packaged release version") + endif () + +endif () include(CheckIncludeFile) include(CheckLibraryExists) diff --git a/config.h.cmake.in b/config.h.cmake.in index 24b2ab86..a218026c 100644 --- a/config.h.cmake.in +++ b/config.h.cmake.in @@ -8,9 +8,9 @@ #cmakedefine HAVE_OPENCL #cmakedefine HAVE_CLOCK_GETTIME -#define PACKAGE_VERSION "${PROJECT_VERSION}" +#define PACKAGE_VERSION "${CRYSTFEL_VERSION}" -#define CRYSTFEL_VERSIONSTRING "${PROJECT_VERSION}+${GIT_SHA1}" +#define CRYSTFEL_VERSIONSTRING "${CRYSTFEL_VERSION}" #define CRYSTFEL_BOILERPLATE "License GPLv3+: GNU GPL version 3 or later"\ " <http://gnu.org/licenses/gpl.html>.\n"\ diff --git a/libcrystfel/CMakeLists.txt b/libcrystfel/CMakeLists.txt index 1fba6624..568dd2b3 100644 --- a/libcrystfel/CMakeLists.txt +++ b/libcrystfel/CMakeLists.txt @@ -1,4 +1,4 @@ -project(libcrystfel VERSION ${CRYSTFEL_VERSION} LANGUAGES C) +project(libcrystfel VERSION ${CRYSTFEL_SHORT_VERSION} LANGUAGES C) find_package(Curses) find_package(FFTW) diff --git a/libcrystfel/config.h.cmake.in b/libcrystfel/config.h.cmake.in index 36bbba60..ba332bec 100644 --- a/libcrystfel/config.h.cmake.in +++ b/libcrystfel/config.h.cmake.in @@ -16,4 +16,4 @@ #cmakedefine HAVE_CBF_CBF_H #cmakedefine HAVE_CBFLIB_CBF_H -#define CRYSTFEL_VERSIONSTRING "${PROJECT_VERSION}+${GIT_SHA1}" +#define CRYSTFEL_VERSIONSTRING "${CRYSTFEL_VERSION}" |