From a8489b2a10ef3523139470f080a0c60a482907dc Mon Sep 17 00:00:00 2001 From: Szilard Pall Date: Thu, 25 Mar 2010 15:55:30 +0100 Subject: [PATCH] fixed USE_VERSION_H Cmake option --- CMakeLists.txt | 2 ++ cmake/gmxGenerateVersionInfo.cmake | 13 ++++++++----- src/gmxlib/CMakeLists.txt | 8 +++++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 75228a2905..3e2bbd441c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 2.6) project(Gromacs) +# PROJECT_VERSION should have the following structure: +# VERSION[-dev-SUFFIX] where the VERSION can have any form and the suffix set(PROJECT_VERSION "4.0.99-dev-20100315" CACHE STRING "Gromacs version string") diff --git a/cmake/gmxGenerateVersionInfo.cmake b/cmake/gmxGenerateVersionInfo.cmake index 1a8e6e3342..5a15ef3e70 100644 --- a/cmake/gmxGenerateVersionInfo.cmake +++ b/cmake/gmxGenerateVersionInfo.cmake @@ -7,7 +7,9 @@ # GEN_VERSION_INFO_INTERNAL has to be set ON. # # The following variables have to be previously defined: -# PROJECT_VERSION - hard-coded version string +# PROJECT_VERSION - hard-coded version string, should have the following structure: +# VERSION[-dev-SUFFIX] where the VERSION can have any form and the suffix +# is optional but should start with -dev # PROJECT_SOURCE_DIR - top level source directory # VERSION_C_CMAKEIN - path to the version.c.cmakein file # VERSION_C_OUT - path to the version.c output file @@ -33,7 +35,6 @@ if(GEN_VERSION_INFO_INTERNAL) set(GMX_PROJECT_VERSION_STR) set(GMX_GIT_HEAD_HASH) set(GMX_GIT_REMOTE_HASH) - set(USE_VERSION_H) endif() set(GIT_BIN) @@ -154,11 +155,13 @@ if(NOT "${GIT_BIN}" MATCHES ".*-NOTFOUND" string(REGEX REPLACE "(.*)-dev.*" "\\1" VER ${VER}) set(GMX_PROJECT_VERSION_STR "${VER}-dev-${VERSION_STR_SUFFIX}") else() - # the version has to be defined + # the version has to be defined - if not we're not using version.h/.c and set + # the GIT related information to "unknown" message(WARNING " Not a git repository and/or git not found, using hard-coded version.") set(GMX_PROJECT_VERSION_STR "${PROJECT_VERSION}") set(GMX_GIT_HEAD_HASH "unknown") - set(GMX_GIT_REMOTE_HASH "unknown") + set(GMX_GIT_REMOTE_HASH "unknown") + set(USE_VERSION_H OFF) endif() # if we're generating cache variables set these @@ -170,7 +173,7 @@ if(GEN_VERSION_INFO_INTERNAL) CACHE STRING "Current git HEAD commit object" FORCE) set(GMX_GIT_REMOTE_HASH ${GMX_GIT_REMOTE_HASH} CACHE STRING "Commmit object of the nearest ancestor present in the Gromacs git repository" FORCE) - mark_as_advanced(GMX_GIT_HEAD_HASH GMX_GIT_REMOTE_HASH USE_VERSION_H) + mark_as_advanced(GMX_GIT_HEAD_HASH GMX_GIT_REMOTE_HASH) else() if(${VERSION_C_CMAKEIN} STREQUAL "") message(FATAL_ERROR "Missing input parameter VERSION_C_CMAKEIN!") diff --git a/src/gmxlib/CMakeLists.txt b/src/gmxlib/CMakeLists.txt index 1982d9d0ed..d49c1ca0bb 100644 --- a/src/gmxlib/CMakeLists.txt +++ b/src/gmxlib/CMakeLists.txt @@ -1,6 +1,9 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + # add target that generates version.c every time a make is run +# only do this if we generate the version +if(USE_VERSION_H) add_custom_target(gmx_version ALL COMMAND ${CMAKE_COMMAND} -D PROJECT_VERSION="${PROJECT_VERSION}" @@ -11,17 +14,20 @@ add_custom_target(gmx_version ALL WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/gmxlib DEPENDS ${CMAKE_SOURCE_DIR}/src/gmxlib/version.c.cmakein COMMENT "Generating version information") +endif() # The nonbonded directory contains subdirectories that are only # conditionally built, so we cannot use a GLOB_RECURSE here. - file(GLOB GMXLIB_SOURCES *.c selection/*.c trajana/*.c statistics/*.c nonbonded/*.c nonbonded/nb_kernel_c/*.c) +# add version.c to the list of sources and tell cmake that it is generated +if(USE_VERSION_H) LIST(APPEND GMXLIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/version.c) # auto-generated set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/version.c PROPERTIES GENERATED true) +endif() if(GMX_IA32_SSE) if(GMX_ASM_USEASM-ATT) -- 2.11.4.GIT