2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
5 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 # and including many others, as listed in the AUTHORS file in the
7 # top-level source directory and at http://www.gromacs.org.
9 # GROMACS is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public License
11 # as published by the Free Software Foundation; either version 2.1
12 # of the License, or (at your option) any later version.
14 # GROMACS is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with GROMACS; if not, see
21 # http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 # If you want to redistribute modifications to GROMACS, please
25 # consider that scientific software is very special. Version
26 # control is crucial - bugs must be traceable. We will be happy to
27 # consider code for inclusion in the official distribution, but
28 # derived work must not be called official GROMACS. Details are found
29 # in the README & COPYING files - if they are missing, get the
30 # official version at http://www.gromacs.org.
32 # To help us fund GROMACS development, we humbly ask that you cite
33 # the research papers on the package. Check out http://www.gromacs.org.
35 set(LIBGROMACS_SOURCES)
37 function (gmx_install_headers DESTINATION)
38 if (NOT GMX_BUILD_MDRUN_ONLY)
40 set(DESTINATION ${INCL_INSTALL_DIR}/gromacs/${DESTINATION})
42 set(DESTINATION ${INCL_INSTALL_DIR}/gromacs)
44 install(FILES ${ARGN} DESTINATION ${DESTINATION} COMPONENT development)
49 option(GMX_EXTERNAL_TNG "Use external TNG instead of compiling the version shipped with GROMACS."
51 # Detect TNG if GMX_EXTERNAL_TNG is explicitly ON
53 find_package(TNG_IO 1.6.0)
56 "TNG >= 1.6.0 not found. "
57 "You can set GMX_EXTERNAL_TNG=OFF to compile TNG.")
59 include_directories(${TNG_IO_INCLUDE_DIRS})
61 if(NOT GMX_EXTERNAL_TNG)
62 # TNG wants zlib if it is available
63 find_package(ZLIB QUIET)
65 gmx_test_zlib(HAVE_ZLIB)
67 include(${CMAKE_SOURCE_DIR}/src/external/tng_io/BuildTNG.cmake)
68 tng_get_source_list(TNG_SOURCES TNG_IO_DEFINITIONS)
69 list(APPEND LIBGROMACS_SOURCES ${TNG_SOURCES})
70 tng_set_source_properties(WITH_ZLIB ${HAVE_ZLIB})
73 list(APPEND GMX_EXTRA_LIBRARIES ${ZLIB_LIBRARIES})
74 include_directories(${ZLIB_INCLUDE_DIRS})
78 # We still need to get tng/tng_io_fwd.h from somewhere!
79 include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src/external/tng_io/include)
82 add_subdirectory(gmxlib)
83 add_subdirectory(mdlib)
84 add_subdirectory(gmxpreprocess)
85 add_subdirectory(bonded)
86 add_subdirectory(commandline)
88 add_subdirectory(linearalgebra)
89 add_subdirectory(math)
90 add_subdirectory(random)
91 add_subdirectory(onlinehelp)
92 add_subdirectory(options)
93 add_subdirectory(pbcutil)
94 add_subdirectory(timing)
95 add_subdirectory(topology)
96 add_subdirectory(utility)
97 add_subdirectory(fileio)
98 add_subdirectory(swap)
99 add_subdirectory(essentialdynamics)
100 add_subdirectory(pulling)
101 add_subdirectory(simd)
102 add_subdirectory(imd)
103 if (NOT GMX_BUILD_MDRUN_ONLY)
104 add_subdirectory(legacyheaders)
105 add_subdirectory(gmxana)
106 add_subdirectory(statistics)
107 add_subdirectory(analysisdata)
108 add_subdirectory(selection)
109 add_subdirectory(trajectoryanalysis)
110 add_subdirectory(tools)
113 list(APPEND LIBGROMACS_SOURCES ${GMXLIB_SOURCES} ${MDLIB_SOURCES})
115 # This would be the standard way to include thread_mpi, but
116 # we want libgromacs to link the functions directly
118 # add_subdirectory(thread_mpi)
120 #target_link_libraries(gmx ${GMX_EXTRA_LIBRARIES} ${THREAD_MPI_LIB})
122 tmpi_get_source_list(THREAD_MPI_SOURCES ${CMAKE_SOURCE_DIR}/src/external/thread_mpi/src)
123 list(APPEND LIBGROMACS_SOURCES ${THREAD_MPI_SOURCES})
125 set(LIBGROMACS_HEADERS
132 configure_file(version.h.cmakein version.h)
133 gmx_install_headers("" ${LIBGROMACS_HEADERS})
134 gmx_install_headers("" ${CMAKE_CURRENT_BINARY_DIR}/version.h)
136 # This code is here instead of utility/CMakeLists.txt, because CMake
137 # custom commands and source file properties can only be set in the directory
138 # that contains the target that uses them.
139 # TODO: Generate a header instead that can be included from baseversion.c.
140 # That probably simplifies things somewhat.
141 set(GENERATED_VERSION_FILE utility/baseversion-gen.c)
142 gmx_configure_version_file(
143 utility/baseversion-gen.c.cmakein ${GENERATED_VERSION_FILE}
144 REMOTE_HASH SOURCE_FILE)
145 list(APPEND LIBGROMACS_SOURCES ${GENERATED_VERSION_FILE})
147 # apply gcc 4.4.x bug workaround
148 if(GMX_USE_GCC44_BUG_WORKAROUND)
149 include(gmxGCC44O3BugWorkaround)
150 gmx_apply_gcc44_bug_workaround("bonded/bonded.cpp")
151 gmx_apply_gcc44_bug_workaround("mdlib/force.c")
152 gmx_apply_gcc44_bug_workaround("mdlib/constr.c")
156 cuda_add_library(libgromacs ${LIBGROMACS_SOURCES}
159 DEBUG -g -D_DEBUG_=1)
161 add_library(libgromacs ${LIBGROMACS_SOURCES})
164 # Recent versions of gcc and clang give warnings on scanner.cpp, which
165 # is a generated source file. These are awkward to suppress inline, so
166 # we do it in the compilation command (after testing that the compiler
167 # supports the suppressions). Setting the properties only works after
168 # the related target has been created, e.g. after when the file is
169 # used with add_library().
170 include(CheckCXXCompilerFlag)
171 check_cxx_compiler_flag(-Wno-unused-parameter HAS_NO_UNUSED_PARAMETER)
172 if (HAS_NO_UNUSED_PARAMETER)
173 set(_scanner_cpp_compiler_flags "${_scanner_cpp_compiler_flags} -Wno-unused-parameter")
175 check_cxx_compiler_flag(-Wno-deprecated-register HAS_NO_DEPRECATED_REGISTER)
176 if (HAS_NO_DEPRECATED_REGISTER)
177 set(_scanner_cpp_compiler_flags "${_scanner_cpp_compiler_flags} -Wno-deprecated-register")
179 check_cxx_compiler_flag(-Wno-deprecated HAS_NO_DEPRECATED)
180 if (HAS_NO_DEPRECATED)
181 set(_scanner_cpp_compiler_flags "${_scanner_cpp_compiler_flags} -Wno-deprecated")
184 set_source_files_properties(selection/scanner.cpp PROPERTIES COMPILE_FLAGS "${_scanner_cpp_compiler_flags}")
186 target_link_libraries(libgromacs
188 ${GMX_EXTRA_LIBRARIES}
190 ${FFT_LIBRARIES} ${LINEAR_ALGEBRA_LIBRARIES}
192 ${THREAD_LIB} ${GMX_SHARED_LINKER_FLAGS})
193 set_target_properties(libgromacs PROPERTIES
194 OUTPUT_NAME "gromacs${GMX_LIBS_SUFFIX}"
195 SOVERSION ${LIBRARY_SOVERSION}
196 VERSION ${LIBRARY_VERSION}
197 COMPILE_FLAGS "${OpenMP_C_FLAGS}")
199 # Only install the library in mdrun-only mode if it is actually necessary
201 if (NOT GMX_BUILD_MDRUN_ONLY OR BUILD_SHARED_LIBS)
202 install(TARGETS libgromacs
204 DESTINATION ${LIB_INSTALL_DIR}
208 if (NOT GMX_BUILD_MDRUN_ONLY)
209 include(InstallLibInfo.cmake)
212 if (INSTALL_CUDART_LIB) #can be set manual by user
214 foreach(CUDA_LIB ${CUDA_LIBRARIES})
215 string(REGEX MATCH "cudart" IS_CUDART ${CUDA_LIB})
216 if(IS_CUDART) #libcuda should not be installed
217 #install also name-links (linker uses those)
218 file(GLOB CUDA_LIBS ${CUDA_LIB}*)
219 install(FILES ${CUDA_LIBS} DESTINATION
220 ${LIB_INSTALL_DIR} COMPONENT libraries)
224 message(WARNING "INSTALL_CUDART_LIB only makes sense with GMX_GPU")