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)
48 add_subdirectory(gmxlib)
49 add_subdirectory(mdlib)
50 add_subdirectory(gmxpreprocess)
51 add_subdirectory(commandline)
53 add_subdirectory(linearalgebra)
54 add_subdirectory(math)
55 add_subdirectory(random)
56 add_subdirectory(onlinehelp)
57 add_subdirectory(options)
58 add_subdirectory(timing)
59 add_subdirectory(utility)
60 add_subdirectory(fileio)
61 add_subdirectory(swap)
62 add_subdirectory(essentialdynamics)
63 add_subdirectory(pulling)
64 add_subdirectory(simd)
66 if (NOT GMX_BUILD_MDRUN_ONLY)
67 add_subdirectory(legacyheaders)
68 add_subdirectory(gmxana)
69 add_subdirectory(statistics)
70 add_subdirectory(analysisdata)
71 add_subdirectory(selection)
72 add_subdirectory(trajectoryanalysis)
73 add_subdirectory(tools)
76 list(APPEND LIBGROMACS_SOURCES ${GMXLIB_SOURCES} ${MDLIB_SOURCES})
78 # This would be the standard way to include thread_mpi, but
79 # we want libgromacs to link the functions directly
81 # add_subdirectory(thread_mpi)
83 #target_link_libraries(gmx ${GMX_EXTRA_LIBRARIES} ${THREAD_MPI_LIB})
85 tmpi_get_source_list(THREAD_MPI_SOURCES ${CMAKE_SOURCE_DIR}/src/external/thread_mpi/src)
86 list(APPEND LIBGROMACS_SOURCES ${THREAD_MPI_SOURCES})
88 file(GLOB LIBGROMACS_HEADERS *.h)
89 configure_file(version.h.cmakein version.h)
90 gmx_install_headers("" ${LIBGROMACS_HEADERS})
91 gmx_install_headers("" ${CMAKE_CURRENT_BINARY_DIR}/version.h)
93 # Add target that generates baseversion-gen.c every time make is run
94 # if git version info is requested, or create it statically.
95 # This code is here instead of utility/CMakeLists.txt because CMake
96 # ignores set_source_file_properties from subdirectories.
97 set(GENERATED_VERSION_FILE
98 ${CMAKE_CURRENT_BINARY_DIR}/utility/baseversion-gen.c)
99 set(GENERATED_VERSION_FILE_SOURCE
100 ${CMAKE_CURRENT_SOURCE_DIR}/utility/baseversion-gen.c.cmakein)
101 if (GMX_GIT_VERSION_INFO)
102 add_custom_target(gmx-version ALL
103 COMMAND ${CMAKE_COMMAND}
104 -D GIT_EXECUTABLE="${GIT_EXECUTABLE}"
105 -D PROJECT_VERSION="${PROJECT_VERSION}"
106 -D PROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}"
107 -D VERSION_CMAKEIN=${GENERATED_VERSION_FILE_SOURCE}
108 -D VERSION_OUT=${GENERATED_VERSION_FILE}
109 -P ${CMAKE_SOURCE_DIR}/cmake/gmxGenerateVersionInfo.cmake
110 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
111 DEPENDS ${GENERATED_VERSION_FILE_SOURCE}
112 COMMENT "Generating git version information")
113 set_source_files_properties(${GENERATED_VERSION_FILE}
114 PROPERTIES GENERATED true)
116 set(GMX_PROJECT_VERSION_STR ${PROJECT_VERSION})
117 configure_file(${GENERATED_VERSION_FILE_SOURCE} ${GENERATED_VERSION_FILE})
119 list(APPEND LIBGROMACS_SOURCES ${GENERATED_VERSION_FILE})
121 # apply gcc 4.4.x bug workaround
122 if(GMX_USE_GCC44_BUG_WORKAROUND)
123 include(gmxGCC44O3BugWorkaround)
124 gmx_apply_gcc44_bug_workaround("gmxlib/bondfree.c")
125 gmx_apply_gcc44_bug_workaround("mdlib/force.c")
126 gmx_apply_gcc44_bug_workaround("mdlib/constr.c")
129 add_library(libgromacs ${LIBGROMACS_SOURCES})
130 if (GMX_GIT_VERSION_INFO)
131 add_dependencies(libgromacs gmx-version)
134 # Recent versions of gcc and clang give warnings on scanner.cpp, which
135 # is a generated source file. These are awkward to suppress inline, so
136 # we do it in the compilation command (after testing that the compiler
137 # supports the suppressions). Setting the properties only works after
138 # the related target has been created, e.g. after when the file is
139 # used with add_library().
140 include(CheckCXXCompilerFlag)
141 check_cxx_compiler_flag(-Wno-unused-parameter HAS_NO_UNUSED_PARAMETER)
142 if (HAS_NO_UNUSED_PARAMETER)
143 set(_scanner_cpp_compiler_flags "${_scanner_cpp_compiler_flags} -Wno-unused-parameter")
145 check_cxx_compiler_flag(-Wno-deprecated-register HAS_NO_DEPRECATED_REGISTER)
146 if (HAS_NO_DEPRECATED_REGISTER)
147 set(_scanner_cpp_compiler_flags "${_scanner_cpp_compiler_flags} -Wno-deprecated-register")
149 check_cxx_compiler_flag(-Wno-deprecated HAS_NO_DEPRECATED)
150 if (HAS_NO_DEPRECATED)
151 set(_scanner_cpp_compiler_flags "${_scanner_cpp_compiler_flags} -Wno-deprecated")
154 set_source_files_properties(selection/scanner.cpp PROPERTIES COMPILE_FLAGS "${_scanner_cpp_compiler_flags}")
156 target_link_libraries(libgromacs
159 ${GMX_EXTRA_LIBRARIES}
161 ${FFT_LIBRARIES} ${LINEAR_ALGEBRA_LIBRARIES}
163 ${THREAD_LIB} ${GMX_SHARED_LINKER_FLAGS})
164 set_target_properties(libgromacs PROPERTIES
165 OUTPUT_NAME "gromacs${GMX_LIBS_SUFFIX}"
166 SOVERSION ${LIBRARY_SOVERSION}
167 VERSION ${LIBRARY_VERSION}
168 COMPILE_FLAGS "${OpenMP_C_FLAGS}")
170 # Only install the library in mdrun-only mode if it is actually necessary
172 if (NOT GMX_BUILD_MDRUN_ONLY OR BUILD_SHARED_LIBS)
173 install(TARGETS libgromacs DESTINATION ${LIB_INSTALL_DIR} COMPONENT libraries)
176 if (NOT GMX_BUILD_MDRUN_ONLY)
177 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libgromacs.pc.cmakein
178 ${CMAKE_CURRENT_BINARY_DIR}/libgromacs.pc @ONLY)
179 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgromacs.pc
180 DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
181 RENAME "libgromacs${GMX_LIBS_SUFFIX}.pc"
182 COMPONENT development)
185 if (INSTALL_CUDART_LIB) #can be set manual by user
187 foreach(CUDA_LIB ${CUDA_LIBRARIES})
188 string(REGEX MATCH "cudart" IS_CUDART ${CUDA_LIB})
189 if(IS_CUDART) #libcuda should not be installed
190 #install also name-links (linker uses those)
191 file(GLOB CUDA_LIBS ${CUDA_LIB}*)
192 install(FILES ${CUDA_LIBS} DESTINATION
193 ${LIB_INSTALL_DIR} COMPONENT libraries)
197 message(WARNING "INSTALL_CUDART_LIB only makes sense with GMX_GPU")