Add AWH biasing module + tests
[gromacs.git] / src / gromacs / CMakeLists.txt
blobcf48a183b7ae5a0ebbfa438ad7196829eb6a5839
2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017, 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 if (GMX_CLANG_CUDA)
38     include(gmxClangCudaUtils)
39 endif()
41 set_property(GLOBAL PROPERTY GMX_LIBGROMACS_SOURCES)
42 set_property(GLOBAL PROPERTY GMX_INSTALLED_HEADERS)
44 function (_gmx_add_files_to_property PROPERTY)
45     foreach (_file ${ARGN})
46         if (IS_ABSOLUTE "${_file}")
47             set_property(GLOBAL APPEND PROPERTY ${PROPERTY} ${_file})
48         else()
49             set_property(GLOBAL APPEND PROPERTY ${PROPERTY}
50                          ${CMAKE_CURRENT_LIST_DIR}/${_file})
51         endif()
52     endforeach()
53 endfunction ()
55 function (gmx_add_libgromacs_sources)
56     _gmx_add_files_to_property(GMX_LIBGROMACS_SOURCES ${ARGN})
57 endfunction ()
59 function (gmx_install_headers)
60     if (NOT GMX_BUILD_MDRUN_ONLY)
61         file(RELATIVE_PATH _dest ${PROJECT_SOURCE_DIR}/src ${CMAKE_CURRENT_LIST_DIR})
62         install(FILES       ${ARGN}
63                 DESTINATION "${INCL_INSTALL_DIR}/${_dest}"
64                 COMPONENT   development)
65     endif()
66     _gmx_add_files_to_property(GMX_INSTALLED_HEADERS ${ARGN})
67 endfunction ()
69 function (gmx_write_installed_header_list)
70     get_property(_list GLOBAL PROPERTY GMX_INSTALLED_HEADERS)
71     string(REPLACE ";" "\n" _list "${_list}")
72     # TODO: Make this only update the file timestamp if the contents actually change.
73     file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/installed-headers.txt "${_list}")
74 endfunction()
76 add_subdirectory(gmxlib)
77 add_subdirectory(mdlib)
78 add_subdirectory(applied-forces)
79 add_subdirectory(listed-forces)
80 add_subdirectory(commandline)
81 add_subdirectory(domdec)
82 add_subdirectory(ewald)
83 add_subdirectory(fft)
84 add_subdirectory(gpu_utils)
85 add_subdirectory(hardware)
86 add_subdirectory(linearalgebra)
87 add_subdirectory(math)
88 add_subdirectory(mdrunutility)
89 add_subdirectory(mdtypes)
90 add_subdirectory(onlinehelp)
91 add_subdirectory(options)
92 add_subdirectory(pbcutil)
93 add_subdirectory(random)
94 add_subdirectory(tables)
95 add_subdirectory(taskassignment)
96 add_subdirectory(timing)
97 add_subdirectory(topology)
98 add_subdirectory(trajectory)
99 add_subdirectory(utility)
100 add_subdirectory(fileio)
101 add_subdirectory(swap)
102 add_subdirectory(essentialdynamics)
103 add_subdirectory(pulling)
104 add_subdirectory(awh)
105 add_subdirectory(simd)
106 add_subdirectory(imd)
107 if (NOT GMX_BUILD_MDRUN_ONLY)
108     add_subdirectory(gmxana)
109     add_subdirectory(gmxpreprocess)
110     add_subdirectory(correlationfunctions)
111     add_subdirectory(statistics)
112     add_subdirectory(analysisdata)
113     add_subdirectory(selection)
114     add_subdirectory(trajectoryanalysis)
115     add_subdirectory(energyanalysis)
116     add_subdirectory(tools)
117 endif()
119 get_property(PROPERTY_SOURCES GLOBAL PROPERTY GMX_LIBGROMACS_SOURCES)
120 list(APPEND LIBGROMACS_SOURCES ${GMXLIB_SOURCES} ${MDLIB_SOURCES} ${PROPERTY_SOURCES})
122 # This would be the standard way to include thread_mpi, but
123 # we want libgromacs to link the functions directly
124 #if(GMX_THREAD_MPI)
125 #    add_subdirectory(thread_mpi)
126 #endif()
127 #target_link_libraries(gmx ${GMX_EXTRA_LIBRARIES} ${THREAD_MPI_LIB})
129 tmpi_get_source_list(THREAD_MPI_SOURCES ${CMAKE_SOURCE_DIR}/src/external/thread_mpi/src)
130 list(APPEND LIBGROMACS_SOURCES ${THREAD_MPI_SOURCES})
132 get_lmfit_properties(LMFIT_SOURCES LMFIT_LIBRARIES_TO_LINK LMFIT_INCLUDE_DIRECTORY LMFIT_INCLUDE_DIR_ORDER)
133 include_directories(${LMFIT_INCLUDE_DIR_ORDER} SYSTEM "${LMFIT_INCLUDE_DIRECTORY}")
134 list(APPEND LIBGROMACS_SOURCES ${LMFIT_SOURCES})
136 configure_file(version.h.cmakein version.h)
137 gmx_install_headers(
138     analysisdata.h
139     commandline.h
140     options.h
141     random.h
142     selection.h
143     trajectoryanalysis.h
144     utility.h
145     ${CMAKE_CURRENT_BINARY_DIR}/version.h
146     )
148 # This code is here instead of utility/CMakeLists.txt, because CMake
149 # custom commands and source file properties can only be set in the directory
150 # that contains the target that uses them.
151 # TODO: Generate a header instead that can be included from baseversion.c.
152 # That probably simplifies things somewhat.
153 set(GENERATED_VERSION_FILE utility/baseversion-gen.c)
154 gmx_configure_version_file(
155     utility/baseversion-gen.c.cmakein ${GENERATED_VERSION_FILE}
156     REMOTE_HASH)
157 list(APPEND LIBGROMACS_SOURCES ${GENERATED_VERSION_FILE})
159 # set up CUDA compilation with clang
160 if (GMX_CLANG_CUDA)
161     foreach (_file ${LIBGROMACS_SOURCES})
162         get_filename_component(_ext ${_file} EXT)
163         if (${_ext} STREQUAL ".cu")
164             gmx_compile_cuda_file_with_clang(${_file})
165         endif()
166     endforeach()
167 endif()
169 if (GMX_USE_CUDA)
170     # Work around FindCUDA that prevents using target_link_libraries()
171     # with keywords otherwise...
172     set(CUDA_LIBRARIES PRIVATE ${CUDA_LIBRARIES})
173     if (NOT GMX_CLANG_CUDA)
174         cuda_add_library(libgromacs ${LIBGROMACS_SOURCES})
175     else()
176         add_library(libgromacs ${LIBGROMACS_SOURCES})
177     endif()
178     target_link_libraries(libgromacs PRIVATE ${CUDA_CUFFT_LIBRARIES})
179 else()
180     add_library(libgromacs ${LIBGROMACS_SOURCES})
181 endif()
183 # Recent versions of gcc and clang give warnings on scanner.cpp, which
184 # is a generated source file. These are awkward to suppress inline, so
185 # we do it in the compilation command (after testing that the compiler
186 # supports the suppressions).
187 include(CheckCXXCompilerFlag)
188 check_cxx_compiler_flag(-Wno-unused HAS_NO_UNUSED)
189 if (HAS_NO_UNUSED)
190     set(_scanner_cpp_compiler_flags "${_scanner_cpp_compiler_flags} -Wno-unused-parameter -Wno-unused-function")
191 endif()
192 set_source_files_properties(selection/scanner.cpp PROPERTIES COMPILE_FLAGS "${_scanner_cpp_compiler_flags}")
194 gmx_setup_tng_for_libgromacs()
196 target_link_libraries(libgromacs
197                       PRIVATE
198                       ${EXTRAE_LIBRARIES}
199                       ${GMX_EXTRA_LIBRARIES}
200                       ${GMX_COMMON_LIBRARIES}
201                       ${FFT_LIBRARIES} ${LINEAR_ALGEBRA_LIBRARIES}
202                       ${LMFIT_LIBRARIES_TO_LINK}
203                       ${THREAD_LIB} ${GMX_SHARED_LINKER_FLAGS} ${OPENCL_LIBRARIES}
204                       ${GMX_STDLIB_LIBRARIES}
205                       PUBLIC
206                       ${GMX_PUBLIC_LIBRARIES}
207                       )
208 set_target_properties(libgromacs PROPERTIES
209                       OUTPUT_NAME "gromacs${GMX_LIBS_SUFFIX}"
210                       SOVERSION ${LIBRARY_SOVERSION_MAJOR}
211                       VERSION ${LIBRARY_VERSION}
212                       COMPILE_FLAGS "${OpenMP_C_FLAGS}")
214 gmx_write_installed_header_list()
216 # Only install the library in mdrun-only mode if it is actually necessary
217 # for the binary
218 if (NOT GMX_BUILD_MDRUN_ONLY OR BUILD_SHARED_LIBS)
219     install(TARGETS libgromacs
220             EXPORT libgromacs
221             LIBRARY DESTINATION ${LIB_INSTALL_DIR}
222             RUNTIME DESTINATION ${BIN_INSTALL_DIR}
223             ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
224             COMPONENT libraries)
225 endif()
227 if (NOT GMX_BUILD_MDRUN_ONLY)
228     include(InstallLibInfo.cmake)
229 endif()
231 # Technically, the user could want to do this for an OpenCL build
232 # using the CUDA runtime, but currently there's no reason to want to
233 # do that.
234 if (INSTALL_CUDART_LIB) #can be set manual by user
235     if (GMX_USE_CUDA)
236         foreach(CUDA_LIB ${CUDA_LIBRARIES})
237             string(REGEX MATCH "cudart" IS_CUDART ${CUDA_LIB})
238             if(IS_CUDART) #libcuda should not be installed
239                 #install also name-links (linker uses those)
240                 file(GLOB CUDA_LIBS ${CUDA_LIB}*)
241                 install(FILES ${CUDA_LIBS} DESTINATION
242                     ${LIB_INSTALL_DIR} COMPONENT libraries)
243             endif()
244         endforeach()
245     else()
246         message(WARNING "INSTALL_CUDART_LIB only makes sense when configuring for CUDA support")
247     endif()
248 endif()
250 if(GMX_USE_OPENCL)
251     set(OPENCL_KERNELS ${MDLIB_OPENCL_KERNELS})
253     install(FILES ${OPENCL_KERNELS} DESTINATION
254         ${OCL_INSTALL_DIR} COMPONENT libraries)
255 endif()
257 if (BUILD_TESTING)
258     add_subdirectory(compat/tests)
259 endif()