#
# This file is part of the GROMACS molecular simulation package.
#
-# Copyright (c) 2010,2011,2012,2013, by the GROMACS development team, led by
-# David van der Spoel, Berk Hess, Erik Lindahl, and including many
-# others, as listed in the AUTHORS file in the top-level source
-# directory and at http://www.gromacs.org.
+# Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+# and including many others, as listed in the AUTHORS file in the
+# top-level source directory and at http://www.gromacs.org.
#
# GROMACS is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
set(LIBGROMACS_SOURCES)
-add_subdirectory(legacyheaders)
+set_property(GLOBAL PROPERTY GMX_INSTALLED_HEADERS)
+
+function (gmx_install_headers)
+ if (NOT GMX_BUILD_MDRUN_ONLY)
+ file(RELATIVE_PATH _dest ${PROJECT_SOURCE_DIR}/src ${CMAKE_CURRENT_LIST_DIR})
+ install(FILES ${ARGN}
+ DESTINATION "${INCL_INSTALL_DIR}/${_dest}"
+ COMPONENT development)
+ endif()
+ foreach (_file ${ARGN})
+ if (IS_ABSOLUTE "${_file}")
+ set_property(GLOBAL APPEND PROPERTY GMX_INSTALLED_HEADERS ${_file})
+ else()
+ set_property(GLOBAL APPEND PROPERTY GMX_INSTALLED_HEADERS
+ ${CMAKE_CURRENT_LIST_DIR}/${_file})
+ endif()
+ endforeach()
+endfunction ()
+
+function (gmx_write_installed_header_list)
+ get_property(_list GLOBAL PROPERTY GMX_INSTALLED_HEADERS)
+ string(REPLACE ";" "\n" _list "${_list}")
+ # TODO: Make this only update the file timestamp if the contents actually change.
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/installed-headers.txt "${_list}")
+endfunction()
+
+if(GMX_USE_TNG)
+ option(GMX_EXTERNAL_TNG "Use external TNG instead of compiling the version shipped with GROMACS."
+ OFF)
+ # Detect TNG if GMX_EXTERNAL_TNG is explicitly ON
+ if(GMX_EXTERNAL_TNG)
+ find_package(TNG_IO 1.6.0)
+ if(NOT TNG_IO_FOUND)
+ message(FATAL_ERROR
+ "TNG >= 1.6.0 not found. "
+ "You can set GMX_EXTERNAL_TNG=OFF to compile TNG.")
+ endif()
+ include_directories(${TNG_IO_INCLUDE_DIRS})
+ endif()
+ if(NOT GMX_EXTERNAL_TNG)
+ include(${CMAKE_SOURCE_DIR}/src/external/tng_io/BuildTNG.cmake)
+ tng_get_source_list(TNG_SOURCES TNG_IO_DEFINITIONS)
+ list(APPEND LIBGROMACS_SOURCES ${TNG_SOURCES})
+ tng_set_source_properties(WITH_ZLIB ${HAVE_ZLIB})
+
+ if (HAVE_ZLIB)
+ list(APPEND GMX_EXTRA_LIBRARIES ${ZLIB_LIBRARIES})
+ include_directories(${ZLIB_INCLUDE_DIRS})
+ endif()
+ endif()
+else()
+ # We still need to get tng/tng_io_fwd.h from somewhere!
+ include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src/external/tng_io/include)
+endif()
+
add_subdirectory(gmxlib)
add_subdirectory(mdlib)
add_subdirectory(gmxpreprocess)
-add_subdirectory(gmxana)
-add_subdirectory(analysisdata)
+add_subdirectory(listed-forces)
add_subdirectory(commandline)
+add_subdirectory(fft)
add_subdirectory(linearalgebra)
+add_subdirectory(math)
+add_subdirectory(random)
add_subdirectory(onlinehelp)
add_subdirectory(options)
-add_subdirectory(selection)
-add_subdirectory(trajectoryanalysis)
+add_subdirectory(pbcutil)
+add_subdirectory(timing)
+add_subdirectory(topology)
add_subdirectory(utility)
-
-file(GLOB LIBGROMACS_HEADERS *.h)
-install(FILES ${LIBGROMACS_HEADERS} DESTINATION ${INCL_INSTALL_DIR}/gromacs
- COMPONENT development)
+add_subdirectory(fileio)
+add_subdirectory(swap)
+add_subdirectory(essentialdynamics)
+add_subdirectory(pulling)
+add_subdirectory(simd)
+add_subdirectory(imd)
+if (NOT GMX_BUILD_MDRUN_ONLY)
+ add_subdirectory(legacyheaders)
+ add_subdirectory(gmxana)
+ add_subdirectory(statistics)
+ add_subdirectory(analysisdata)
+ add_subdirectory(selection)
+ add_subdirectory(trajectoryanalysis)
+ add_subdirectory(tools)
+endif()
list(APPEND LIBGROMACS_SOURCES ${GMXLIB_SOURCES} ${MDLIB_SOURCES})
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.cmakein ${CMAKE_CURRENT_BINARY_DIR}/version.h)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/version.h
- DESTINATION ${INCL_INSTALL_DIR}/gromacs
- COMPONENT development)
-
-# Add target that generates gitversion.c every time make is run
-# if git version info is requested
-# This code is here instead of utility/CMakeLists.txt because CMake
-# ignores set_source_file_properties from subdirectories.
-if (GMX_GIT_VERSION_INFO)
- set(GENERATED_VERSION_FILE ${CMAKE_CURRENT_BINARY_DIR}/utility/gitversion.c)
- add_custom_target(gmx_version ALL
- COMMAND ${CMAKE_COMMAND}
- -D GIT_EXECUTABLE="${GIT_EXECUTABLE}"
- -D GIT_VERSION="${GIT_VERSION}"
- -D PROJECT_VERSION="${PROJECT_VERSION}"
- -D PROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}"
- -D VERSION_C_CMAKEIN="${CMAKE_CURRENT_SOURCE_DIR}/utility/gitversion.c.cmakein"
- -D VERSION_C_OUT=${GENERATED_VERSION_FILE}
- -P ${CMAKE_SOURCE_DIR}/cmake/gmxGenerateVersionInfo.cmake
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/utility/gitversion.c.cmakein
- COMMENT "Generating git version information")
- set_source_files_properties(${GENERATED_VERSION_FILE}
- PROPERTIES GENERATED true)
- list(APPEND LIBGROMACS_SOURCES ${GENERATED_VERSION_FILE})
-endif()
+# This would be the standard way to include thread_mpi, but
+# we want libgromacs to link the functions directly
+#if(GMX_THREAD_MPI)
+# add_subdirectory(thread_mpi)
+#endif()
+#target_link_libraries(gmx ${GMX_EXTRA_LIBRARIES} ${THREAD_MPI_LIB})
+
+tmpi_get_source_list(THREAD_MPI_SOURCES ${CMAKE_SOURCE_DIR}/src/external/thread_mpi/src)
+list(APPEND LIBGROMACS_SOURCES ${THREAD_MPI_SOURCES})
+
+configure_file(version.h.cmakein version.h)
+gmx_install_headers(
+ analysisdata.h
+ commandline.h
+ options.h
+ selection.h
+ trajectoryanalysis.h
+ utility.h
+ ${CMAKE_CURRENT_BINARY_DIR}/version.h
+ )
+
+# This code is here instead of utility/CMakeLists.txt, because CMake
+# custom commands and source file properties can only be set in the directory
+# that contains the target that uses them.
+# TODO: Generate a header instead that can be included from baseversion.c.
+# That probably simplifies things somewhat.
+set(GENERATED_VERSION_FILE utility/baseversion-gen.c)
+gmx_configure_version_file(
+ utility/baseversion-gen.c.cmakein ${GENERATED_VERSION_FILE}
+ REMOTE_HASH SOURCE_FILE)
+list(APPEND LIBGROMACS_SOURCES ${GENERATED_VERSION_FILE})
# apply gcc 4.4.x bug workaround
if(GMX_USE_GCC44_BUG_WORKAROUND)
include(gmxGCC44O3BugWorkaround)
- gmx_apply_gcc44_bug_workaround("gmxlib/bondfree.c")
+ gmx_apply_gcc44_bug_workaround("listed-forces/bonded.cpp")
gmx_apply_gcc44_bug_workaround("mdlib/force.c")
gmx_apply_gcc44_bug_workaround("mdlib/constr.c")
endif()
-add_library(libgromacs ${LIBGROMACS_SOURCES})
-if (GMX_GIT_VERSION_INFO)
- add_dependencies(libgromacs gmx_version)
-endif ()
-
-if(GMX_BUILD_OWN_FFTW)
- # This dependency has to be made here rather than the CMakeLists.txt that
- # does the FFTW build, because of the order in which
- # add_subdirectory() calls are made in the top-level CMakeLists.txt; the
- # md library target does not necessarily exist yet. Also enabling and
- # disabling GMX_BUILD_OWN_FFTW changes dependencies correctly.
- add_dependencies(libgromacs gmxfftw)
+if (GMX_GPU)
+ cuda_add_library(libgromacs ${LIBGROMACS_SOURCES}
+ OPTIONS
+ RELWITHDEBINFO -g
+ DEBUG -g -D_DEBUG_=1)
+else()
+ add_library(libgromacs ${LIBGROMACS_SOURCES})
endif()
-target_link_libraries(libgromacs ${GMX_GPU_LIBRARIES}
+# Recent versions of gcc and clang give warnings on scanner.cpp, which
+# is a generated source file. These are awkward to suppress inline, so
+# we do it in the compilation command (after testing that the compiler
+# supports the suppressions). Setting the properties only works after
+# the related target has been created, e.g. after when the file is
+# used with add_library().
+include(CheckCXXCompilerFlag)
+check_cxx_compiler_flag(-Wno-unused-parameter HAS_NO_UNUSED_PARAMETER)
+if (HAS_NO_UNUSED_PARAMETER)
+ set(_scanner_cpp_compiler_flags "${_scanner_cpp_compiler_flags} -Wno-unused-parameter")
+endif()
+check_cxx_compiler_flag(-Wno-deprecated-register HAS_NO_DEPRECATED_REGISTER)
+if (HAS_NO_DEPRECATED_REGISTER)
+ set(_scanner_cpp_compiler_flags "${_scanner_cpp_compiler_flags} -Wno-deprecated-register")
+else()
+ check_cxx_compiler_flag(-Wno-deprecated HAS_NO_DEPRECATED)
+ if (HAS_NO_DEPRECATED)
+ set(_scanner_cpp_compiler_flags "${_scanner_cpp_compiler_flags} -Wno-deprecated")
+ endif()
+endif()
+set_source_files_properties(selection/scanner.cpp PROPERTIES COMPILE_FLAGS "${_scanner_cpp_compiler_flags}")
+
+target_link_libraries(libgromacs
+ ${EXTRAE_LIBRARIES}
${GMX_EXTRA_LIBRARIES}
- ${FFT_LIBRARIES} ${XML_LIBRARIES} ${GSL_LIBRARIES}
+ ${TNG_IO_LIBRARIES}
+ ${FFT_LIBRARIES} ${LINEAR_ALGEBRA_LIBRARIES}
+ ${XML_LIBRARIES}
${THREAD_LIB} ${GMX_SHARED_LINKER_FLAGS})
set_target_properties(libgromacs PROPERTIES
OUTPUT_NAME "gromacs${GMX_LIBS_SUFFIX}"
- SOVERSION ${SOVERSION}
+ SOVERSION ${LIBRARY_SOVERSION}
+ VERSION ${LIBRARY_VERSION}
COMPILE_FLAGS "${OpenMP_C_FLAGS}")
-install(TARGETS libgromacs DESTINATION ${LIB_INSTALL_DIR} COMPONENT libraries)
+gmx_write_installed_header_list()
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libgromacs.pc.cmakein
- ${CMAKE_CURRENT_BINARY_DIR}/libgromacs.pc @ONLY)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgromacs.pc
- DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
- RENAME "libgromacs${GMX_LIBS_SUFFIX}.pc"
- COMPONENT development)
+# Only install the library in mdrun-only mode if it is actually necessary
+# for the binary
+if (NOT GMX_BUILD_MDRUN_ONLY OR BUILD_SHARED_LIBS)
+ install(TARGETS libgromacs
+ EXPORT libgromacs
+ LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+ RUNTIME DESTINATION ${BIN_INSTALL_DIR}
+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
+ COMPONENT libraries)
+endif()
+
+if (NOT GMX_BUILD_MDRUN_ONLY)
+ include(InstallLibInfo.cmake)
+endif()
if (INSTALL_CUDART_LIB) #can be set manual by user
if (GMX_GPU)
else()
message(WARNING "INSTALL_CUDART_LIB only makes sense with GMX_GPU")
endif()
-endif ()
+endif()