2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2010,2011,2012,2013,2014,2015,2016, 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 set_property(GLOBAL PROPERTY GMX_LIBGROMACS_SOURCES)
38 set_property(GLOBAL PROPERTY GMX_INSTALLED_HEADERS)
40 function (_gmx_add_files_to_property PROPERTY)
41 foreach (_file ${ARGN})
42 if (IS_ABSOLUTE "${_file}")
43 set_property(GLOBAL APPEND PROPERTY ${PROPERTY} ${_file})
45 set_property(GLOBAL APPEND PROPERTY ${PROPERTY}
46 ${CMAKE_CURRENT_LIST_DIR}/${_file})
51 function (gmx_add_libgromacs_sources)
52 _gmx_add_files_to_property(GMX_LIBGROMACS_SOURCES ${ARGN})
55 function (gmx_install_headers)
56 if (NOT GMX_BUILD_MDRUN_ONLY)
57 file(RELATIVE_PATH _dest ${PROJECT_SOURCE_DIR}/src ${CMAKE_CURRENT_LIST_DIR})
59 DESTINATION "${INCL_INSTALL_DIR}/${_dest}"
60 COMPONENT development)
62 _gmx_add_files_to_property(GMX_INSTALLED_HEADERS ${ARGN})
65 function (gmx_write_installed_header_list)
66 get_property(_list GLOBAL PROPERTY GMX_INSTALLED_HEADERS)
67 string(REPLACE ";" "\n" _list "${_list}")
68 # TODO: Make this only update the file timestamp if the contents actually change.
69 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/installed-headers.txt "${_list}")
72 add_subdirectory(gmxlib)
73 add_subdirectory(mdlib)
74 add_subdirectory(listed-forces)
75 add_subdirectory(commandline)
76 add_subdirectory(domdec)
77 add_subdirectory(ewald)
79 add_subdirectory(gpu_utils)
80 add_subdirectory(hardware)
81 add_subdirectory(linearalgebra)
82 add_subdirectory(math)
83 add_subdirectory(mdrunutility)
84 add_subdirectory(mdtypes)
85 add_subdirectory(onlinehelp)
86 add_subdirectory(options)
87 add_subdirectory(pbcutil)
88 add_subdirectory(random)
89 add_subdirectory(tables)
90 add_subdirectory(timing)
91 add_subdirectory(topology)
92 add_subdirectory(trajectory)
93 add_subdirectory(utility)
94 add_subdirectory(fileio)
95 add_subdirectory(swap)
96 add_subdirectory(essentialdynamics)
97 add_subdirectory(pulling)
98 add_subdirectory(simd)
100 if (NOT GMX_BUILD_MDRUN_ONLY)
101 add_subdirectory(gmxana)
102 add_subdirectory(gmxpreprocess)
103 add_subdirectory(correlationfunctions)
104 add_subdirectory(statistics)
105 add_subdirectory(analysisdata)
106 add_subdirectory(selection)
107 add_subdirectory(trajectoryanalysis)
108 add_subdirectory(tools)
111 get_property(PROPERTY_SOURCES GLOBAL PROPERTY GMX_LIBGROMACS_SOURCES)
112 list(APPEND LIBGROMACS_SOURCES ${GMXLIB_SOURCES} ${MDLIB_SOURCES} ${PROPERTY_SOURCES})
114 # This would be the standard way to include thread_mpi, but
115 # we want libgromacs to link the functions directly
117 # add_subdirectory(thread_mpi)
119 #target_link_libraries(gmx ${GMX_EXTRA_LIBRARIES} ${THREAD_MPI_LIB})
121 tmpi_get_source_list(THREAD_MPI_SOURCES ${CMAKE_SOURCE_DIR}/src/external/thread_mpi/src)
122 list(APPEND LIBGROMACS_SOURCES ${THREAD_MPI_SOURCES})
124 list(APPEND LIBGROMACS_SOURCES ${TNG_SOURCES})
125 tng_set_source_properties(WITH_ZLIB ${HAVE_ZLIB})
127 configure_file(version.h.cmakein version.h)
136 ${CMAKE_CURRENT_BINARY_DIR}/version.h
139 # This code is here instead of utility/CMakeLists.txt, because CMake
140 # custom commands and source file properties can only be set in the directory
141 # that contains the target that uses them.
142 # TODO: Generate a header instead that can be included from baseversion.c.
143 # That probably simplifies things somewhat.
144 set(GENERATED_VERSION_FILE utility/baseversion-gen.c)
145 gmx_configure_version_file(
146 utility/baseversion-gen.c.cmakein ${GENERATED_VERSION_FILE}
147 REMOTE_HASH SOURCE_FILE)
148 list(APPEND LIBGROMACS_SOURCES ${GENERATED_VERSION_FILE})
151 cuda_add_library(libgromacs ${LIBGROMACS_SOURCES})
153 add_library(libgromacs ${LIBGROMACS_SOURCES})
156 # Recent versions of gcc and clang give warnings on scanner.cpp, which
157 # is a generated source file. These are awkward to suppress inline, so
158 # we do it in the compilation command (after testing that the compiler
159 # supports the suppressions).
160 include(CheckCXXCompilerFlag)
161 check_cxx_compiler_flag(-Wno-unused-parameter HAS_NO_UNUSED_PARAMETER)
162 if (HAS_NO_UNUSED_PARAMETER)
163 set(_scanner_cpp_compiler_flags "${_scanner_cpp_compiler_flags} -Wno-unused-parameter")
165 check_cxx_compiler_flag(-Wno-deprecated-register HAS_NO_DEPRECATED_REGISTER)
166 if (HAS_NO_DEPRECATED_REGISTER)
167 set(_scanner_cpp_compiler_flags "${_scanner_cpp_compiler_flags} -Wno-deprecated-register")
169 check_cxx_compiler_flag(-Wno-deprecated HAS_NO_DEPRECATED)
170 if (HAS_NO_DEPRECATED)
171 set(_scanner_cpp_compiler_flags "${_scanner_cpp_compiler_flags} -Wno-deprecated")
174 set_source_files_properties(selection/scanner.cpp PROPERTIES COMPILE_FLAGS "${_scanner_cpp_compiler_flags}")
176 target_link_libraries(libgromacs
178 ${GMX_EXTRA_LIBRARIES}
180 ${FFT_LIBRARIES} ${LINEAR_ALGEBRA_LIBRARIES}
182 ${THREAD_LIB} ${GMX_SHARED_LINKER_FLAGS} ${OPENCL_LIBRARIES}
183 ${GMX_STDLIB_LIBRARIES})
184 set_target_properties(libgromacs PROPERTIES
185 OUTPUT_NAME "gromacs${GMX_LIBS_SUFFIX}"
186 SOVERSION ${LIBRARY_SOVERSION_MAJOR}
187 VERSION ${LIBRARY_VERSION}
188 COMPILE_FLAGS "${OpenMP_C_FLAGS}")
190 gmx_write_installed_header_list()
192 # Only install the library in mdrun-only mode if it is actually necessary
194 if (NOT GMX_BUILD_MDRUN_ONLY OR BUILD_SHARED_LIBS)
195 install(TARGETS libgromacs
197 LIBRARY DESTINATION ${LIB_INSTALL_DIR}
198 RUNTIME DESTINATION ${BIN_INSTALL_DIR}
199 ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
203 if (NOT GMX_BUILD_MDRUN_ONLY)
204 include(InstallLibInfo.cmake)
207 # Technically, the user could want to do this for an OpenCL build
208 # using the CUDA runtime, but currently there's no reason to want to
210 if (INSTALL_CUDART_LIB) #can be set manual by user
212 foreach(CUDA_LIB ${CUDA_LIBRARIES})
213 string(REGEX MATCH "cudart" IS_CUDART ${CUDA_LIB})
214 if(IS_CUDART) #libcuda should not be installed
215 #install also name-links (linker uses those)
216 file(GLOB CUDA_LIBS ${CUDA_LIB}*)
217 install(FILES ${CUDA_LIBS} DESTINATION
218 ${LIB_INSTALL_DIR} COMPONENT libraries)
222 message(WARNING "INSTALL_CUDART_LIB only makes sense when configuring for CUDA support")
227 set(OPENCL_KERNELS ${MDLIB_OPENCL_KERNELS})
229 install(FILES ${OPENCL_KERNELS} DESTINATION
230 ${OCL_INSTALL_DIR} COMPONENT libraries)