X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=blobdiff_plain;f=CMakeLists.txt;fp=CMakeLists.txt;h=7fbe947522f707b751ec25248446b94e39af19e4;hb=19d3c2e5d0c401eb59010960d11a18b6ba2c54c6;hp=53498532af1377e335ee0747ace076bf86f54d6a;hpb=a349e4beffcbe43be945226384d2a590b27263f0;p=alexxy%2Fgromacs.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 53498532af..7fbe947522 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,75 +48,28 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -# PROJECT_VERSION should have the following structure: -# VERSION-dev[-SUFFIX] where the VERSION should have the for: vMajor.vMinor.vPatch -# -# The "-dev" suffix is important to keep because it makes possible to distinguish -# between a build from official release and a build from git release branch on a -# machine with no git. -# -# NOTE: when releasing the "-dev" suffix needs to be stripped off! -# REGRESSIONTEST_VERSION and REGRESSIONTEST_BRANCH should always be -# defined. -set(PROJECT_VERSION "5.0.3-dev") -# If this is a released tarball, "-dev" will not be present in -# PROJECT_VERSION, and REGRESSIONTEST_VERSION specifies the version -# number of the regressiontest tarball against which the code tarball -# can be tested. This will be the version of the last patch release. -set(REGRESSIONTEST_VERSION "5.0.3-dev") -# The MD5 checksum of the regressiontest tarball. Only used if "-dev" -# is not present in the PROJECT_VERSION -set(REGRESSIONTEST_MD5SUM "004f2377adf252e2caa9c241390d4b9c") -# If this is not a released tarball, "-dev" will be present in -# PROJECT_VERSION, and REGRESSIONTEST_BRANCH specifies the name of the -# gerrit.gromacs.org branch whose HEAD can test this code, *if* this -# code contains all recent fixes from the corresponding code branch. -set(REGRESSIONTEST_BRANCH "refs/heads/release-5-0") - -set(CUSTOM_VERSION_STRING "" - CACHE STRING "Custom version string (if empty, use hard-coded default)") -mark_as_advanced(CUSTOM_VERSION_STRING) -if (CUSTOM_VERSION_STRING) - set(PROJECT_VERSION ${CUSTOM_VERSION_STRING}) -endif() -set(LIBRARY_SOVERSION 0) -set(LIBRARY_VERSION ${LIBRARY_SOVERSION}.0.0) -# It is a bit irritating, but this has to be set separately for now! -SET(CPACK_PACKAGE_VERSION_MAJOR "5") -SET(CPACK_PACKAGE_VERSION_MINOR "0") -#SET(CPACK_PACKAGE_VERSION_PATCH "0") - -# The numerical gromacs version. It is 40600 for 4.6.0. -# The #define GMX_VERSION in gromacs/version.h is set to this value. -math(EXPR NUM_VERSION - "${CPACK_PACKAGE_VERSION_MAJOR}*10000 + ${CPACK_PACKAGE_VERSION_MINOR}*100") -if(CPACK_PACKAGE_VERSION_PATCH) - math(EXPR NUM_VERSION - "${NUM_VERSION} + ${CPACK_PACKAGE_VERSION_PATCH}") -endif() - -# The API version tracks the numerical Gromacs version (for now). -# It is potentially different from the Gromacs version in the future, if -# the programs/libraries diverge from the presumably more stable API. -# The #define GMX_API_VERSION in version.h is set to this value to -# provide backward compatibility of software written against the Gromacs API. -set(API_VERSION ${NUM_VERSION}) +# Set up common version variables, as well as general information about +# the build tree (whether the build is from a source package or from a git +# repository). Also declares a few functions that will be used for generating +# version info files later. +include(gmxVersionInfo) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND UNIX) set(CMAKE_INSTALL_PREFIX "/usr/local/gromacs" CACHE STRING "Installation prefix (installation will need write permissions here)" FORCE) endif() include(gmxBuildTypeReference) +include(gmxBuildTypeProfile) include(gmxBuildTypeTSAN) include(gmxBuildTypeASAN) include(gmxBuildTypeReleaseWithAssert) if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel Reference RelWithAssert." FORCE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel Reference RelWithAssert Profile." FORCE) # There's no need to offer a user the choice of ThreadSanitizer # Set the possible values of build type for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" - "MinSizeRel" "RelWithDebInfo" "Reference" "RelWithAssert") + "MinSizeRel" "RelWithDebInfo" "Reference" "RelWithAssert" "Profile") endif() if(CMAKE_CONFIGURATION_TYPES) # Add appropriate GROMACS-specific build types for the Visual @@ -128,34 +81,10 @@ if(CMAKE_CONFIGURATION_TYPES) "List of configuration types" FORCE) endif() -set(build_types_with_explicit_flags RELEASE DEBUG RELWITHDEBINFO RELWITHASSERT MINSIZEREL) +set(build_types_with_explicit_flags RELEASE DEBUG RELWITHDEBINFO RELWITHASSERT MINSIZEREL PROFILE) -enable_language(C) -enable_language(CXX) set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) -set(CPACK_PACKAGE_NAME "gromacs") -set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) -set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") -set(CPACK_PACKAGE_VENDOR "gromacs.org") -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Gromacs - a toolkit for high-performance molecular simulation") -set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/admin/InstallWelcome.txt") -# Its GPL/LGPL, so they do not have to agree to a license for mere usage, but some installers require this... -set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING") -set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/admin/InstallInfo.txt") -set(CPACK_SOURCE_IGNORE_FILES "\\\\.isreposource$;\\\\.git/;\\\\.gitignore$;\\\\.gitattributes;") -set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_SOURCE_DIR}/CPackInit.cmake") -# CPack source archives include only the directories we list here. -# This variable is a list of pairs of names of source and destination -# directories. Most of these are used for content GROMACS generates as -# part of the configuration or build. -set(CPACK_SOURCE_INSTALLED_DIRECTORIES "${CMAKE_SOURCE_DIR};/;${CMAKE_BINARY_DIR}/src/programs/completion;src/programs/completion;${CMAKE_BINARY_DIR}/docs/man/man1;docs/man/man1;${CMAKE_BINARY_DIR}/docs/man/man7;docs/man/man7;${CMAKE_BINARY_DIR}/docs/old-html/final;docs/old-html/final;${CMAKE_BINARY_DIR}/docs/install-guide/final;/") -set(CPACK_PACKAGE_CONTACT "gmx-users@gromacs.org") -set(CPACK_GMX_BUILD_HELP "${GMX_BUILD_HELP}") #Works even though GMX_BUILD_HELP is defined later because it is off by default. - -#must come after all cpack settings! -include(CPack) - # Set a default valgrind suppression file. # This unfortunately needs to duplicate information from CTest to work as # expected... @@ -165,14 +94,12 @@ set(MEMORYCHECK_SUPPRESSIONS_FILE "File that contains suppressions for the memory checker") include(CTest) -set(SOURCE_IS_GIT_REPOSITORY OFF) -set(SOURCE_IS_SOURCE_DISTRIBUTION OFF) -if(EXISTS "${CMAKE_SOURCE_DIR}/.git") - set(SOURCE_IS_GIT_REPOSITORY ON) -endif() -if(NOT EXISTS "${CMAKE_SOURCE_DIR}/admin/.isreposource") - set(SOURCE_IS_SOURCE_DISTRIBUTION ON) -endif() +include(gmxCPackUtilities) +gmx_cpack_init() + +# Variables that accumulate stuff influencing the installed headers +set(INSTALLED_HEADER_INCLUDE_DIRS "") +set(INSTALLED_HEADER_DEFINITIONS "") ######################################################################## # Check and warn if cache generated on a different host is being reused @@ -263,7 +190,7 @@ gmx_option_multichoice( GMX_SIMD "SIMD instruction set for CPU kernels and compiler optimization" "${GMX_SUGGESTED_SIMD}" - None SSE2 SSE4.1 AVX_128_FMA AVX_256 AVX2_256 IBM_QPX Sparc64_HPC_ACE Reference) + None SSE2 SSE4.1 AVX_128_FMA AVX_256 AVX2_256 ARM_NEON ARM_NEON_ASIMD IBM_QPX IBM_VMX IBM_VSX Sparc64_HPC_ACE Reference) gmx_option_multichoice( GMX_FFT_LIBRARY @@ -304,9 +231,6 @@ option(GMX_OPENMP "Enable OpenMP-based multithreading" ON) option(GMX_USE_TNG "Use the TNG library for trajectory I/O" ON) -option(GMX_GIT_VERSION_INFO "Generate git version information" ${SOURCE_IS_GIT_REPOSITORY}) -mark_as_advanced(GMX_GIT_VERSION_INFO) - if(UNIX) option(GMX_SYMLINK_OLD_BINARY_NAMES "Create symbolic links for pre-5.0 binary names" ON) endif() @@ -380,17 +304,15 @@ if(GMX_SIMD STREQUAL "AVX_256" endif() - -set(PKG_CFLAGS "") if(GMX_DOUBLE) add_definitions(-DGMX_DOUBLE) - set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_DOUBLE") + list(APPEND INSTALLED_HEADER_DEFINITIONS "-DGMX_DOUBLE") if(GMX_RELAXED_DOUBLE_PRECISION) add_definitions(-DGMX_RELAXED_DOUBLE_PRECISION) endif() endif() if(GMX_SOFTWARE_INVSQRT) - set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_SOFTWARE_INVSQRT") + list(APPEND INSTALLED_HEADER_DEFINITIONS "-DGMX_SOFTWARE_INVSQRT") endif() if(WIN32 AND NOT CYGWIN) @@ -555,25 +477,6 @@ if(WIN32 AND NOT CYGWIN) add_definitions(-DNOMINMAX) endif() -# only bother with finding git and using version.h if the source is a git repo -if(GMX_GIT_VERSION_INFO) - if (NOT SOURCE_IS_GIT_REPOSITORY) - message(FATAL_ERROR - "Cannot generate git version information from source tree not under git. " - "Set GMX_GIT_VERSION_INFO=OFF to proceed.") - endif() - # We need at least git v1.5.3 be able to parse git's date output. If not - # found or the version is too small, we can't generate version information. - find_package(Git) - - if(NOT GIT_FOUND OR GIT_VERSION_STRING VERSION_LESS "1.5.3") - message(FATAL_ERROR - "No compatible git version found (>= 1.5.3 required). " - "Won't be able to generate development version information. " - "Set GMX_GIT_VERSION_INFO=OFF to proceed.") - endif() -endif() - # Detect boost unless GMX_EXTERNAL_BOOST is explicitly OFF # Used for default if GMX_EXTERNAL_BOOST is not defined (first CMake pass) if(NOT DEFINED GMX_EXTERNAL_BOOST OR GMX_EXTERNAL_BOOST) @@ -616,12 +519,6 @@ if(GMX_USE_TNG AND NOT GMX_EXTERNAL_TNG) gmx_test_zlib(HAVE_ZLIB) endif() -######################################################################## -# Generate development version info for cache -######################################################################## -# set(GEN_VERSION_INFO_INTERNAL "ON") -# include(gmxGenerateVersionString) - ######################################################################## # Our own GROMACS tests ######################################################################## @@ -631,10 +528,6 @@ include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src) include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src/external/thread_mpi/include) # Required for config.h, maybe should only be set in src/CMakeLists.txt include_directories(BEFORE ${CMAKE_BINARY_DIR}/src) -# Required for gmx_header_config_gen.h to be found before installation -include_directories(BEFORE ${CMAKE_BINARY_DIR}/src/gromacs/utility) -# Required for now to make old code compile -include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src/gromacs/legacyheaders) include(gmxTestInlineASM) gmx_test_inline_asm_gcc_x86(GMX_X86_GCC_INLINE_ASM) @@ -789,14 +682,18 @@ if(GMX_FAHCORE) include_directories(${COREWRAP_INCLUDE_DIR}) endif() -option(GMX_BUILD_HELP "Build man pages, HTML help, and completions automatically (requires that compiled binaries can be executed on the build host)" OFF) +# Value of AUTO tries to generate things, but will only produce warnings if +# that fails. +set(build_help_default AUTO) +if (SOURCE_IS_SOURCE_DISTRIBUTION) + set(build_help_default OFF) +endif() +gmx_option_trivalue(GMX_BUILD_HELP "Build man pages, HTML help, and completions automatically (requires that compiled binaries can be executed on the build host)" ${build_help_default}) mark_as_advanced(GMX_BUILD_HELP) -if (GMX_BUILD_HELP AND SOURCE_IS_SOURCE_DISTRIBUTION AND - "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") - +if (GMX_BUILD_HELP AND SOURCE_IS_SOURCE_DISTRIBUTION AND BUILD_IS_INSOURCE) message(FATAL_ERROR - "Rebuilding HTML and man pages is not supported for in-source " - "builds from a source distribution. " + "Rebuilding HTML and man pages or shell completions is not supported " + "for in-source builds from a source distribution. " "Set GMX_BUILD_HELP=OFF or do an out-of-source build to proceed.") endif() @@ -828,7 +725,6 @@ else() set(GMX_EXE_LINKER_FLAGS ${GMX_EXE_LINKER_FLAGS} ${OpenMP_LINKER_FLAGS}) set(GMX_SHARED_LINKER_FLAGS ${GMX_SHARED_LINKER_FLAGS} ${OpenMP_SHARED_LINKER_FLAGS}) endif() -set(PKG_CFLAGS "${PKG_CFLAGS} ${OpenMP_C_FLAGS}") ######################################################################## # Specify install locations @@ -845,17 +741,24 @@ mark_as_advanced(GMX_LIB_INSTALL_DIR GMX_DATA_INSTALL_DIR) # These variables are used internally to provide a central location for # customizing the install locations. -set(LIB_INSTALL_DIR ${GMX_LIB_INSTALL_DIR}) -set(BIN_INSTALL_DIR bin) -set(DATA_INSTALL_DIR share/${GMX_DATA_INSTALL_DIR}) -set(MAN_INSTALL_DIR share/man) -set(INCL_INSTALL_DIR include) +set(LIB_INSTALL_DIR ${GMX_LIB_INSTALL_DIR}) +set(BIN_INSTALL_DIR bin) +set(DATA_INSTALL_DIR share/${GMX_DATA_INSTALL_DIR}) +set(MAN_INSTALL_DIR share/man) +# If the nesting level wrt. the installation root is changed, +# gromacs-config.cmake.cmakein needs to be adapted. +set(CMAKE_INSTALL_DIR share/cmake) +# TODO: Make GMXRC adapt if this is changed +set(PKGCONFIG_INSTALL_DIR ${LIB_INSTALL_DIR}/pkgconfig) +set(INCL_INSTALL_DIR include) # These variables get written into config.h for use in finding the data # directories. set(GMXLIB_SEARCH_DIR share/${GMX_DATA_INSTALL_DIR}/top) set(GMXLIB_FALLBACK ${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}/top) +list(APPEND INSTALLED_HEADER_INCLUDE_DIRS ${INCL_INSTALL_DIR}) + # Binary and library suffix options include(gmxManageSuffixes) @@ -901,15 +804,14 @@ install(FILES COPYING DESTINATION ${DATA_INSTALL_DIR} COMPONENT data) if(GMX_EXTERNAL_BOOST) include_directories(${Boost_INCLUDE_DIRS}) - set(PKG_CFLAGS "${PKG_CFLAGS} -I${Boost_INCLUDE_DIRS}") + list(APPEND INSTALLED_HEADER_INCLUDE_DIRS ${Boost_INCLUDE_DIRS}) else() include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src/external/boost) + list(APPEND INSTALLED_HEADER_INCLUDE_DIRS ${INCL_INSTALL_DIR}/gromacs/external/boost) + list(APPEND INSTALLED_HEADED_DEFINITIONS "-DBOOST_NO_TYPEID") # typeid not supported for minimal internal version # (would add significant amount of code) add_definitions(-DBOOST_NO_TYPEID) - # TODO: Propagate the above settings to the installed CMakeFiles.txt template - # (from share/template/) - set(PKG_CFLAGS "${PKG_CFLAGS} -DBOOST_NO_TYPEID -I${CMAKE_INSTALL_PREFIX}/${INCL_INSTALL_DIR}/gromacs/external/boost") if (NOT GMX_BUILD_MDRUN_ONLY) install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/external/boost/boost DESTINATION ${INCL_INSTALL_DIR}/gromacs/external/boost @@ -952,6 +854,8 @@ if (BUILD_TESTING) add_subdirectory(tests) endif() +gmx_cpack_write_config() + # Issue a warning if NVIDIA GPUs were detected, but CUDA was not found. # Don't bother the user after the first configure pass. if ((CUDA_NOTFOUND_AUTO AND GMX_DETECT_GPU_AVAILABLE) AND NOT GMX_GPU_DETECTION_DONE)