fixed USE_VERSION_H Cmake option
authorSzilard Pall <pszilard@cbr.su.se>
Thu, 25 Mar 2010 14:55:30 +0000 (15:55 +0100)
committerSzilard Pall <pszilard@cbr.su.se>
Thu, 25 Mar 2010 14:55:30 +0000 (15:55 +0100)
CMakeLists.txt
cmake/gmxGenerateVersionInfo.cmake
src/gmxlib/CMakeLists.txt

index 75228a2905ddb343b7015e1982f3684f5be0c088..3e2bbd441c5c88ec5ffc3660d70230be50f555da 100644 (file)
@@ -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")
 
index 1a8e6e3342461765790cb682126e7a7399eec165..5a15ef3e70afc0796ff9363178525c57ee7ce7ee 100644 (file)
@@ -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!")
index 1982d9d0edd64599641b88e39f6a549a111ed606..d49c1ca0bba015b0dc870520364337cd7bb09291 100644 (file)
@@ -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)