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")
# 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
set(GMX_PROJECT_VERSION_STR)
set(GMX_GIT_HEAD_HASH)
set(GMX_GIT_REMOTE_HASH)
- set(USE_VERSION_H)
endif()
set(GIT_BIN)
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
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!")
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}"
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)