2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2012, by the GROMACS development team, led by
5 # David van der Spoel, Berk Hess, Erik Lindahl, and including many
6 # others, as listed in the AUTHORS file in the top-level source
7 # 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.
36 set(GMXPREPROCESS_SOURCES
73 gctio.c ionize.c runner.c
74 do_gct.c repl_ex.c xutils.c pme_loadbal.c
75 md.c mdrun.c genalg.c membed.c
78 add_library(gmxpreprocess ${GMXPREPROCESS_SOURCES})
79 target_link_libraries(gmxpreprocess md)
80 set_target_properties(gmxpreprocess PROPERTIES OUTPUT_NAME "gmxpreprocess${GMX_LIBS_SUFFIX}" SOVERSION ${SOVERSION} INSTALL_NAME_DIR "${LIB_INSTALL_DIR}"
81 COMPILE_FLAGS "${OpenMP_C_FLAGS}")
84 if(GMX_GPU OR GMX_OPENMM)
85 include_directories(${CMAKE_SOURCE_DIR}/src/gmxlib/gpu_utils)
89 include_directories(${OpenMM_INCLUDE_DIR})
90 link_directories(${OpenMM_LIBRARY_DIR})
91 # with this define no evn.var. is needed with OPENMM_PLUGIN_DIR
92 # if the same OpenMM installation is used for running and building
93 add_definitions( -DOPENMM_PLUGIN_DIR="${OpenMM_PLUGIN_DIR}" )
94 file(TO_CMAKE_PATH ${OpenMM_PLUGIN_DIR} _path)
95 add_library(openmm_api_wrapper STATIC openmm_wrapper.cpp)
96 target_link_libraries(openmm_api_wrapper ${OpenMM_LIBRARIES})
97 set(GMX_OPENMM_LIBRARIES openmm_api_wrapper ${OpenMM_LIBRARIES})
100 if(GMX_GPU OR GMX_OPENMM OR GMX_FORCE_CXX)
101 set_source_files_properties(main.c PROPERTIES LANGUAGE CXX)
102 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
103 set_source_files_properties(main.c PROPERTIES COMPILE_FLAGS "-x c++")
108 add_library(fahcore ${MDRUN_SOURCES})
111 list(APPEND GMX_EXTRA_LIBRARIES gmxpreprocess md ${OpenMP_LINKER_FLAGS})
113 set(GMX_KERNEL_PROGRAMS
114 grompp tpbconv pdb2gmx g_protonate gmxdump g_x2top gmxcheck)
115 if (NOT GMX_NO_QUOTES)
116 set(GMX_KERNEL_PROGRAMS ${GMX_KERNEL_PROGRAMS} g_luck)
117 endif (NOT GMX_NO_QUOTES)
120 foreach(PROGRAM ${GMX_KERNEL_PROGRAMS})
121 add_executable(${PROGRAM} ${PROGRAM}.c main.c)
122 if (NOT ${PROGRAM} STREQUAL "g_luck")
123 gmx_add_man_page(${PROGRAM})
125 target_link_libraries(${PROGRAM} ${GMX_EXTRA_LIBRARIES})
126 set_target_properties(${PROGRAM} PROPERTIES OUTPUT_NAME "${PROGRAM}${GMX_BINARY_SUFFIX}")
129 add_executable(mdrun ${MDRUN_SOURCES} main.c)
130 gmx_add_man_page(mdrun)
131 target_link_libraries(mdrun ${GMX_EXTRA_LIBRARIES} ${GMX_OPENMM_LIBRARIES})
132 set_target_properties(mdrun PROPERTIES OUTPUT_NAME "mdrun${GMX_BINARY_SUFFIX}" COMPILE_FLAGS "${OpenMP_C_FLAGS}")
134 # this is to circumvent the following MSVC error:
135 # warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs
136 # fatal error LNK1169: one or more multiply defined symbols found
137 if(GMX_OPENMM AND MSVC)
138 set_target_properties(mdrun PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT")
141 # Construct component groups for installation; note that a component may
142 # belong to only one group
143 foreach(PROGRAM ${GMX_KERNEL_PROGRAMS})
144 set(CPACK_COMPONENT_${PROGRAM}_GROUP tools)
146 set(CPACK_COMPONENT_MDRUN_GROUP mdrun)
148 foreach(PROGRAM ${GMX_KERNEL_PROGRAMS} mdrun)
149 # Manage CPack component dependencies
150 set(CPACK_COMPONENT_${PROGRAM}_DEPENDS libraries libraries-gmxpreprocess)
152 # Create custom install-xxxx target
153 if (BUILD_SHARED_LIBS)
154 # If shared libraries are used, we need to install the libraries in
155 # addition to the mdrun binary.
156 add_custom_target(install-${PROGRAM}
157 COMMAND ${CMAKE_COMMAND} -DCOMPONENT=libraries
158 -P ${CMAKE_BINARY_DIR}/cmake_install.cmake
159 COMMAND ${CMAKE_COMMAND} -DCOMPONENT=libraries-gmxpreprocess
160 -P ${CMAKE_BINARY_DIR}/cmake_install.cmake
161 COMMAND ${CMAKE_COMMAND} -DCOMPONENT=${PROGRAM}
162 -P ${CMAKE_BINARY_DIR}/cmake_install.cmake
163 COMMENT "Installing ${PROGRAM}")
165 add_custom_target(install-${PROGRAM}
166 COMMAND ${CMAKE_COMMAND} -DCOMPONENT=${PROGRAM}
167 -P ${CMAKE_BINARY_DIR}/cmake_install.cmake
168 COMMENT "Installing ${PROGRAM}")
170 add_dependencies(install-${PROGRAM} ${PROGRAM})
172 # Finally, trigger installation
176 DESTINATION ${BIN_INSTALL_DIR}
180 install(TARGETS gmxpreprocess DESTINATION ${LIB_INSTALL_DIR} COMPONENT libraries-gmxpreprocess)
182 if (INSTALL_CUDART_LIB) #can be set manual by user
183 if (GMX_OPENMM OR GMX_GPU)
184 foreach(CUDA_LIB ${CUDA_LIBRARIES})
185 string(REGEX MATCH "cudart" IS_CUDART ${CUDA_LIB})
186 if(IS_CUDART) #libcuda should not be installed
187 #install also name-links (linker uses those)
188 file(GLOB CUDA_LIBS ${CUDA_LIB}*)
189 install(FILES ${CUDA_LIBS} DESTINATION
190 ${LIB_INSTALL_DIR} COMPONENT libraries)
194 message(WARNING "INSTALL_CUDART_LIB only makes sense with GMX_OPENMM or GMX_GPU")
199 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libgmxpreprocess.pc.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libgmxpreprocess.pc @ONLY)
200 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgmxpreprocess.pc
201 DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
202 RENAME "libgmxpreprocess${GMX_LIBS_SUFFIX}.pc"
203 COMPONENT development)