Documente Academic
Documente Profesional
Documente Cultură
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(GMX_BUILD_HOSTNAME AND NOT "${GMX_BUILD_HOSTNAME}" STREQUAL "${TMP_HOSTNA
ME}")
message(WARNING "
The CMake cache, probably generated on a different host (${GMX_BUILD
_HOSTNAME}),
is being reused! This could lead to inconsistencies; therefore, it i
s
recommended to regenerate the cache!")
endif()
set(GMX_BUILD_HOSTNAME "${TMP_HOSTNAME}" CACHE INTERNAL
"Hostname of the machine where the cache was generated.")
endif()
########################################################################
# Detect architecture before setting options so we can alter defaults
########################################################################
# Detect the architecture the compiler is targetting, detect
# SIMD instructions possibilities on that hardware, suggest SIMD instruction set
# to use if none is specified, and populate the cache option for CPU
# SIMD.
include(gmxDetectTargetArchitecture)
gmx_detect_target_architecture()
########################################################################
# User input options
#
########################################################################
include(gmxOptionUtilities)
set(CMAKE_PREFIX_PATH "" CACHE STRING "Extra locations to search for external li
braries and tools (give directory without lib, bin, or include)")
if(GMX_TARGET_FUJITSU_SPARC64)
# Fujitsu only has SIMD in double precision, so this will be faster
set(GMX_DOUBLE_DEFAULT ON)
else()
set(GMX_DOUBLE_DEFAULT OFF)
endif()
option(GMX_DOUBLE "Use double precision (much slower, use only if you really nee
d it)" ${GMX_DOUBLE_DEFAULT})
option(GMX_RELAXED_DOUBLE_PRECISION "Accept single precision 1/sqrt(x) when usin
g Fujitsu HPC-ACE SIMD" OFF)
mark_as_advanced(GMX_RELAXED_DOUBLE_PRECISION)
option(GMX_MPI
"Build a parallel (message-passing) version of GROMACS" OFF)
option(GMX_THREAD_MPI "Build a thread-MPI-based multithreaded version of GROMAC
S (not compatible with MPI)" ON)
gmx_dependent_option(
GMX_MPI_IN_PLACE
"Enable MPI_IN_PLACE for MPIs that have it defined"
ON
GMX_MPI)
mark_as_advanced(GMX_MPI_IN_PLACE)
option(GMX_SOFTWARE_INVSQRT "Use GROMACS software 1/sqrt" ON)
mark_as_advanced(GMX_SOFTWARE_INVSQRT)
option(GMX_FAHCORE "Build a library with mdrun functionality" OFF)
mark_as_advanced(GMX_FAHCORE)
option(GMX_COOL_QUOTES "Enable GROMACS cool quotes" ON)
mark_as_advanced(GMX_COOL_QUOTES)
include(gmxManageOpenMP)
######################################################################
# Compiler tests
# These need to be done early (before further tests).
#####################################################################
# The cmake/Check{C,CXX}CompilerFlag.cmake files in the GROMACS distribution
# are used with permission from CMake v3.0.0 so that GROMACS can detect
# invalid options with the Intel Compilers, and we have added a line
# to detect warnings with the Fujitsu compilers on K computer and ICC.
# CMake-3.0 also has a bug where the FAIL_REGEX pattern for AIX contains
# a semicolon. Since this is also used as a separator in lists inside CMake,
# that string ends up being split into two separate patterns, and the last
# part is just a single word that also matches other messages. We solved this
# by replacing the semicolon with a period that matches any character.
#
# These files should be removed from the source tree when a CMake version that
# includes the features in question becomes required for building GROMACS.
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(gmxCFlags)
gmx_c_flags()
# This variable should be used for additional compiler flags which are not
# generated in gmxCFlags nor are SIMD or MPI related.
set(EXTRA_C_FLAGS "")
set(EXTRA_CXX_FLAGS "")
# Run through a number of tests for buggy compilers and other issues
include(gmxTestCompilerProblems)
gmx_test_compiler_problems()
# GMX_SIMD will not be set automatically until the second
# pass (which is not strictly guaranteed to occur), so putting this
# check here among logically-related tests is inefficient, but the
# potential loss is likely zero.
if(GMX_SIMD STREQUAL "AVX_256"
AND CMAKE_COMPILER_IS_GNUCC
AND (C_COMPILER_VERSION VERSION_EQUAL "4.6.1"
OR CXX_COMPILER_VERSION VERSION_EQUAL "4.6.1"))
message(FATAL_ERROR "gcc 4.6.1 has buggy support for AVX, and GROMACS mdrun
will not work. If you want simulation performance, use a more recent compiler. O
therwise, use GMX_SIMD=SSE4.1")
# See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49002
endif()
if(GMX_DOUBLE)
add_definitions(-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)
list(APPEND INSTALLED_HEADER_DEFINITIONS "-DGMX_SOFTWARE_INVSQRT")
endif()
if(WIN32)
list(APPEND GMX_EXTRA_LIBRARIES "wsock32")
add_definitions(-DGMX_HAVE_WINSOCK)
endif()
########################################################################
# Basic system tests (standard libraries, headers, functions, types) #
########################################################################
include(CheckIncludeFiles)
include(CheckIncludeFileCXX)
check_include_files(unistd.h
HAVE_UNISTD_H)
check_include_files(pwd.h
HAVE_PWD_H)
check_include_files(dirent.h
HAVE_DIRENT_H)
check_include_files(time.h
HAVE_TIME_H)
check_include_files(sys/time.h HAVE_SYS_TIME_H)
check_include_files(io.h
HAVE_IO_H)
check_include_files(sched.h
HAVE_SCHED_H)
check_include_files(regex.h
HAVE_POSIX_REGEX)
# TODO: It could be nice to inform the user if no regex support is found,
# as selections won't be fully functional.
include(CheckCXXSymbolExists)
check_cxx_symbol_exists(posix_memalign
check_cxx_symbol_exists(memalign
check_cxx_symbol_exists(_aligned_malloc
check_cxx_symbol_exists(gettimeofday
check_cxx_symbol_exists(sysconf
check_cxx_symbol_exists(nice
check_cxx_symbol_exists(fsync
check_cxx_symbol_exists(_fileno
check_cxx_symbol_exists(fileno
check_cxx_symbol_exists(_commit
check_cxx_symbol_exists(sigaction
check_cxx_symbol_exists(rsqrt
check_cxx_symbol_exists(rsqrtf
check_cxx_symbol_exists(sqrtf
stdlib.h
stdlib.h
stdlib.h
sys/time.h
unistd.h
unistd.h
unistd.h
stdio.h
stdio.h
io.h
signal.h
math.h
math.h
math.h
HAVE_POSIX_MEMALIGN)
HAVE_MEMALIGN)
HAVE__ALIGNED_MALLOC)
HAVE_GETTIMEOFDAY)
HAVE_SYSCONF)
HAVE_NICE)
HAVE_FSYNC)
HAVE__FILENO)
HAVE_FILENO)
HAVE__COMMIT)
HAVE_SIGACTION)
HAVE_RSQRT)
HAVE_RSQRTF)
HAVE_SQRTF)
include(CheckLibraryExists)
find_library(HAVE_LIBM m)
mark_as_advanced(HAVE_LIBM)
check_library_exists(rt clock_gettime "" HAVE_CLOCK_GETTIME)
check_library_exists(m feenableexcept "" HAVE_FEENABLEEXCEPT)
include(TestSchedAffinity)
test_sched_affinity(HAVE_SCHED_AFFINITY)
include(TestBigEndian)
test_big_endian(GMX_INTEGER_BIG_ENDIAN)
set(GMX_USE_NICE 0)
if (HAVE_UNISTD_H AND HAVE_NICE)
set(GMX_USE_NICE 1)
endif()
# Management of GROMACS options for specific toolchains should go
# here. Because the initial settings for some of the main options have
# already happened, but things like library detection and MPI compiler
# feature detection have not, the docstrings for any over-rides of
# GROMACS defaults or user settings will make sense. Also, any
# toolchain-related reasons for choosing whether to detect various
# things can be sorted out now, before the detection takes place.
if(${CMAKE_SYSTEM_NAME} MATCHES BlueGene)
include(gmxManageBlueGene)
endif()
if(GMX_TARGET_FUJITSU_SPARC64)
include(gmxManageFujitsuSparc64)
endif()
########################################################################
#Process MPI settings
########################################################################
include(gmxManageMPI)
########################################################################
#Process shared/static library settings
########################################################################
include(gmxManageSharedLibraries)
########################################################################
# Find external packages
#
########################################################################
# TNG wants zlib if it is available. And static libxml2 might have a dependency
find_package(ZLIB QUIET)
include(gmxTestZLib)
gmx_test_zlib(HAVE_ZLIB)
# Unconditionally find the package, as it is also required for unit
# tests. This exports LIBXML2_FOUND, which we should not use because
# it does not tell us that linking will succeed. Instead, we test that
# next.
if(DEFINED LIBXML2_LIBRARIES)
set(LibXml2_FIND_QUIETLY TRUE)
endif()
find_package(LibXml2)
include(gmxTestLibXml2)
gmx_test_libxml2(HAVE_LIBXML2)
option(GMX_XML "Use libxml2 to parse xml files (currently has no effect)" ${HAVE
_LIBXML2})
set(PKG_XML "")
mark_as_advanced(GMX_XML)
# Don't actually do anything, since libxml2 is currently not used by libgromacs
#if(GMX_XML AND NOT HAVE_LIBXML2)
#
message(FATAL_ERROR "libxml2 not found. Set GMX_XML=OFF to compile without
XML support")
#endif()
#if(GMX_XML)
#
include_directories(${LIBXML2_INCLUDE_DIR})
#
set(PKG_XML libxml-2.0)
#
set(XML_LIBRARIES ${LIBXML2_LIBRARIES})
#endif()
option(GMX_EXTRAE "Add support for tracing using EXTRAE" OFF)
mark_as_advanced(GMX_EXTRAE)
if (GMX_EXTRAE)
find_package(EXTRAE)
if(EXTRAE_FOUND)
include_directories(SYSTEM ${EXTRAE_INCLUDE_DIR})
set(HAVE_EXTRAE 1)
else()
message(FATAL_ERROR "EXTRAE library was not found. Please add the correct pa
th to CMAKE_PREFIX_PATH")
endif()
endif()
option(GMX_X11 "Use X window system" OFF)
if (GMX_X11)
find_package(X11)
# X11 includes/libraries are only set in the ngmx subdirectory!
if(NOT X11_FOUND)
message(FATAL_ERROR
"X11 include files and/or libraries were not found. "
"Set GMX_X11=OFF to compile without X11 support. "
"gmx view will not be available.")
endif()
include_directories(SYSTEM ${X11_INCLUDE_DIR})
endif()
include(ThreadMPI)
# Enable core threading facilities
tmpi_enable_core("${CMAKE_SOURCE_DIR}/src/external/thread_mpi/include")
# Enable tMPI C++ support
tmpi_enable_cxx()
if(GMX_THREAD_MPI)
# enable MPI functions
tmpi_enable()
set(MPI_IN_PLACE_EXISTS 1)
endif()
# If atomics are manually disabled a define is needed because atomics.h doesn't
depend on config.h
if (TMPI_ATOMICS_DISABLED)
add_definitions(-DTMPI_ATOMICS_DISABLED)
endif()
if(GMX_GPU)
# now that we have detected the dependencies, do the second configure pass
gmx_gpu_setup()
else()
mark_as_advanced(CUDA_HOST_COMPILER)
endif()
if(CYGWIN)
set(GMX_CYGWIN 1)
endif()
if(WIN32)
set(GMX_NATIVE_WINDOWS 1)
# This makes windows.h not declare min/max as macros that would break
# C++ code using std::min/std::max.
add_definitions(-DNOMINMAX)
endif()
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)
include(gmxTestInlineASM)
gmx_test_inline_asm_gcc_x86(GMX_X86_GCC_INLINE_ASM)
include(gmxSetBuildInformation)
gmx_set_build_information()
# Turn on RDTSCP if:
# - the build system's CPU supports it
# - the acceleration is set to AVX as all AVX-capable CPUs support AVX (which
# at this point means that the user set it).
# Note: it's better to not use the later set value of GMX_SIMD because
# it reflects the system's capability of both compiling and running AVX code.
# TODO: After merge with 5.0 one could implement a cache variable dependency
# such that GMX_USE_RDTSCP can change if GMX_SIMD is changed to AVX
# after the first cmake pass.
if (BUILD_CPU_FEATURES MATCHES "rdtscp" OR GMX_SIMD MATCHES "AVX")
set(GMX_USE_RDTSCP_DEFAULT_VALUE ON)
else()
set(GMX_USE_RDTSCP_DEFAULT_VALUE OFF)
endif()
option(GMX_USE_RDTSCP "Use RDTSCP for better CPU-based timers (available on rece
nt x86 CPUs; might need to be off when compiling for heterogeneous environments)
" ${GMX_USE_RDTSCP_DEFAULT_VALUE})
mark_as_advanced(GMX_USE_RDTSCP)
if(GMX_USE_RDTSCP)
set(HAVE_RDTSCP 1)
endif()
include(gmxTestFloatFormat)
gmx_test_float_format(GMX_FLOAT_FORMAT_IEEE754
GMX_IEEE754_BIG_ENDIAN_BYTE_ORDER
GMX_IEEE754_BIG_ENDIAN_WORD_ORDER)
include(gmxTestLargeFiles)
gmx_test_large_files(GMX_LARGEFILES)
include(gmxTestSignal)
gmx_test_sigusr1(HAVE_SIGUSR1)
include(gmxTestPipes)
gmx_test_pipes(HAVE_PIPES)
include(gmxTestIsfinite)
gmx_test_isfinite(HAVE_ISFINITE)
gmx_test__isfinite(HAVE__ISFINITE)
gmx_test__finite(HAVE__FINITE)
include(gmxTestCXX11)
gmx_test_cxx11(GMX_CXX11_SUPPORTED GMX_CXX11_FLAGS)
include(CMakeDependentOption)
# clang with some older versions of boost fail to work with C++11
if(CMAKE_CXX_COMPILER_ID MATCHES Clang AND
(Boost_VERSION VERSION_EQUAL 104601 OR Boost_VERSION VERSION_EQUAL 104700))
set(CLANG_AND_OLD_EXTERNAL_BOOST TRUE)
endif()
# nvcc does not support C++11 flags, so with GPUs we prefer to skip C++11 flags
set(LIB_INSTALL_DIR
${GMX_LIB_INSTALL_DIR})
set(BIN_INSTALL_DIR
bin)
# This variable also gets written into config.h for use in finding the data
# directories.
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(OCL_INSTALL_DIR
${DATA_INSTALL_DIR}/opencl)
set(INCL_INSTALL_DIR
include)
list(APPEND INSTALLED_HEADER_INCLUDE_DIRS ${INCL_INSTALL_DIR})
# Binary and library suffix options
include(gmxManageSuffixes)
################################################################
# Shared library load path settings
################################################################
# CMake supports RPATH on OS X only from 2.8.12 upwards.
# CMAKE_SYSTEM_VERSION > 8.0 matches OS X 10.5 and above, where RPATH support
# was added.
if(NOT GMX_BUILD_SHARED_EXE)
# No rpath
set(CMAKE_SKIP_RPATH TRUE)
set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS) # remove -Wl,-Bdynamic
set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
elseif((NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") OR
((CMAKE_SYSTEM_VERSION VERSION_GREATER 8.0) AND (NOT CMAKE_VERSION VERSION_LE
SS 2.8.12)))
# The build folder always has bin/ and lib/; if we are also going to
# install to lib/, then the installation RPATH works also in the build
# tree. This makes installation slightly faster (no need to rewrite the
# RPATHs), and makes the binaries in the build tree relocatable.
if(GMX_LIB_INSTALL_DIR STREQUAL "lib")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
endif()
# Set the RPATH as relative to the executable location to make the
# binaries relocatable.
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${GMX_LIB_INSTALL_DIR}")
else()
set(CMAKE_INSTALL_RPATH "@executable_path/../${GMX_LIB_INSTALL_DIR}")
endif()
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_MACOSX_RPATH 1)
else()
# We are on Darwin/OSX, and CMake cannot handle RPATHs automatically.
if(CMAKE_SYSTEM_VERSION VERSION_GREATER 8.0)
# Set the RPATH options manually.
set(CMAKE_INSTALL_NAME_DIR "@rpath")
set(GMX_EXE_LINKER_FLAGS ${GMX_EXE_LINKER_FLAGS} "-Wl,-rpath,@executable
_path/../${GMX_LIB_INSTALL_DIR}")
else()
# Use the old INSTALL_NAME_DIR mechanism if RPATH is not supported.
set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}")
endif()
endif()
#COPYING file: Only necessary for binary distributions.
#Simpler to always install.
install(FILES COPYING DESTINATION ${DATA_INSTALL_DIR} COMPONENT data)
if(GMX_EXTERNAL_BOOST)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
list(APPEND INSTALLED_HEADER_INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
else()
include_directories(BEFORE SYSTEM ${CMAKE_SOURCE_DIR}/src/external/boost)
list(APPEND INSTALLED_HEADER_INCLUDE_DIRS ${INCL_INSTALL_DIR}/gromacs/extern
al/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)
if (NOT GMX_BUILD_MDRUN_ONLY)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/external/boost/boost
DESTINATION ${INCL_INSTALL_DIR}/gromacs/external/boost
COMPONENT development)
endif()
endif()
if (GMX_BUILD_FOR_COVERAGE)
# Code heavy with asserts makes conditional coverage close to useless metric
,
# as by design most of the false branches are impossible to trigger in
# correctly functioning code. And the benefit of testing those that could
# be triggered by using an API against its specification isn't usually
# worth the effort.
add_definitions(-DNDEBUG -DBOOST_DISABLE_ASSERTS -DGMX_DISABLE_ASSERTS)
endif()
if (BUILD_TESTING)
# "tests" target builds all the separate test binaries.
add_custom_target(tests)
# "run-ctest" is an internal target that actually runs the tests.
# This is necessary to be able to add separate targets that execute as part
# of 'make check', but are ensured to be executed after the actual tests.
add_custom_target(run-ctest
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
COMMENT "Running all tests"
VERBATIM)
add_dependencies(run-ctest tests)
# "check" target builds and runs all tests.
add_custom_target(check DEPENDS run-ctest)
endif()
if (NOT GMX_BUILD_MDRUN_ONLY)
add_subdirectory(docs)
add_subdirectory(share)
add_subdirectory(scripts)
endif()
add_subdirectory(src)
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)
message(WARNING "${CUDA_NOTFOUND_MESSAGE}")
endif()
set(GMX_GPU_DETECTION_DONE TRUE CACHE INTERNAL "Whether GPU detection has alread
y been done")
#######################
## uninstall target
#######################
CONFIGURE_FILE( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
###########################
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P
"${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake")
###########################
set_directory_properties(PROPERTIES
ADDITIONAL_MAKE_CLEAN_FILES "install_manifest.txt")