2 set(GMXPREPROCESS_SOURCES
36 gctio.c ionize.c runner.c
37 do_gct.c repl_ex.c xutils.c
38 md.c mdrun.c genalg.c md_openmm.c)
40 add_library(gmxpreprocess ${GMXPREPROCESS_SOURCES})
41 target_link_libraries(gmxpreprocess md)
42 set_target_properties(gmxpreprocess PROPERTIES OUTPUT_NAME "gmxpreprocess${GMX_LIBS_SUFFIX}" SOVERSION ${SOVERSION} INSTALL_NAME_DIR "${LIB_INSTALL_DIR}")
43 set_target_properties(md PROPERTIES OUTPUT_NAME "md${GMX_LIBS_SUFFIX}" SOVERSION ${SOVERSION} INSTALL_NAME_DIR "${LIB_INSTALL_DIR}")
47 add_subdirectory(gmx_gpu_utils)
48 include_directories(./gmx_gpu_utils ${OpenMM_INCLUDE_DIR})
49 link_directories(${OpenMM_LIBRARY_DIR})
50 # only define if this is a local build not a release
51 # we assume that the auto-generated version is not used &&
52 # version string does not contain "-dev" => it's a release build
53 if(NOT USE_VERSION_H AND NOT PROJECT_VERSION MATCHES ".*-dev.*")
54 add_definitions( -DOPENMM_PLUGIN_DIR="${OpenMM_PLUGIN_DIR}" )
56 add_definitions( -DOPENMM_PLUGIN_DIR="" )
58 add_library(openmm_api_wrapper STATIC openmm_wrapper.cpp)
59 target_link_libraries(openmm_api_wrapper gmx_gpu_utils ${OpenMM_LIBRARIES})
60 set(GMX_OPENMM_LIBRARIES openmm_api_wrapper gmx_gpu_utils ${OpenMM_LIBRARIES})
64 add_library(fahcore ${MDRUN_SOURCES})
67 list(APPEND GMX_EXTRA_LIBRARIES gmxpreprocess md)
69 add_executable(grompp grompp.c)
70 target_link_libraries(grompp ${GMX_EXTRA_LIBRARIES})
71 set_target_properties(grompp PROPERTIES OUTPUT_NAME "grompp${GMX_BINARY_SUFFIX}")
73 add_executable(tpbconv tpbconv.c)
74 target_link_libraries(tpbconv ${GMX_EXTRA_LIBRARIES})
75 set_target_properties(tpbconv PROPERTIES OUTPUT_NAME "tpbconv${GMX_BINARY_SUFFIX}")
77 add_executable(pdb2gmx pdb2gmx.c)
78 target_link_libraries(pdb2gmx ${GMX_EXTRA_LIBRARIES})
79 set_target_properties(pdb2gmx PROPERTIES OUTPUT_NAME "pdb2gmx${GMX_BINARY_SUFFIX}")
81 add_executable(g_protonate g_protonate.c)
82 target_link_libraries(g_protonate ${GMX_EXTRA_LIBRARIES})
83 set_target_properties(g_protonate PROPERTIES OUTPUT_NAME "g_protonate${GMX_BINARY_SUFFIX}")
85 add_executable(g_luck g_luck.c)
86 target_link_libraries(g_luck ${GMX_EXTRA_LIBRARIES})
87 set_target_properties(g_luck PROPERTIES OUTPUT_NAME "g_luck${GMX_BINARY_SUFFIX}")
89 add_executable(gmxdump gmxdump.c)
90 target_link_libraries(gmxdump ${GMX_EXTRA_LIBRARIES})
91 set_target_properties(gmxdump PROPERTIES OUTPUT_NAME "gmxdump${GMX_BINARY_SUFFIX}")
93 add_executable(g_x2top g_x2top.c)
94 target_link_libraries(g_x2top ${GMX_EXTRA_LIBRARIES})
95 set_target_properties(g_x2top PROPERTIES OUTPUT_NAME "g_x2top${GMX_BINARY_SUFFIX}")
97 add_executable(gmxcheck gmxcheck.c)
98 target_link_libraries(gmxcheck ${GMX_EXTRA_LIBRARIES})
99 set_target_properties(gmxcheck PROPERTIES OUTPUT_NAME "gmxcheck${GMX_BINARY_SUFFIX}")
101 add_executable(mdrun ${MDRUN_SOURCES})
102 target_link_libraries(mdrun ${GMX_EXTRA_LIBRARIES} ${GMX_OPENMM_LIBRARIES})
103 # set binary name to mdrun-gpu
105 set(_mdrun_exec_name "mdrun-gpu")
107 set(_mdrun_exec_name "mdrun${GMX_BINARY_SUFFIX}")
109 set_target_properties(mdrun PROPERTIES OUTPUT_NAME "${_mdrun_exec_name}")
111 # this is to circumvent the following MSVC error:
112 # warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs
113 # fatal error LNK1169: one or more multiply defined symbols found
114 if(GMX_OPENMM AND MSVC)
115 set_target_properties(mdrun PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT")
129 gmxpreprocess DESTINATION ${LIB_INSTALL_DIR}
130 RUNTIME DESTINATION ${BIN_INSTALL_DIR})
133 # if we build shared gromacs libs, when installing throught the install-mdrun target
134 # these libs need to be installed as well
135 if(BUILD_SHARED_LIBS)
136 # in MDRUN_LIBS we store the libraries MDRUN links against (NOTE: hardcoded!!!)
137 set(MDRUN_LIBS gmxpreprocess md gmx)
139 # generate install-libXXX custom target for each shared lib that mdrun links against
140 foreach(_lib ${MDRUN_LIBS})
141 # double-check that the type is SHARED
142 get_target_property(_type ${_lib} TYPE)
143 if(NOT ${_type} STREQUAL "SHARED_LIBRARY")
144 message(FATAL_ERROR " Internal error: library ${_lib} is not shared so it's not supposed to be processed for installing")
147 # figure out the path and filename under which the lib will be installed
148 # (libname with pre- and suffix)
149 get_target_property(_lib_path ${_lib} LOCATION)
150 string(REGEX REPLACE "/" ";" _lib_fname ${_lib_path})
151 list(REVERSE _lib_fname)
152 list(GET _lib_fname 0 _lib_fname)
154 # prepare path and filename for the pkgconfig stuff
155 string(REGEX REPLACE ".so$" ".pc" _lib_pc_path ${_lib_path})
156 string(REGEX REPLACE ".so$" ".pc" _lib_pc_fname ${_lib_fname})
157 # create custom target for copying each library to the install location
158 # TODO: need to fix this to have the .so.6 form
159 add_custom_target(install-${_lib}
160 COMMAND ${CMAKE_COMMAND} -E copy
161 "${_lib_path}" "${LIB_INSTALL_DIR}/${_lib_fname}.${SOVERSION}"
162 COMMAND ${CMAKE_COMMAND} -E create_symlink
163 "${_lib_fname}.${SOVERSION}" "${LIB_INSTALL_DIR}/${_lib_fname}"
164 COMMAND ${CMAKE_COMMAND} -E copy
165 "${_lib_pc_path}" "${LIB_INSTALL_DIR}/pkgconfig/${_lib_pc_fname}"
166 # DEPENDS ${_lib_pcpath}
167 COMMENT "Installing library ${_lib}")
168 add_dependencies(install-${_lib} ${_lib})
170 # gather the custom target names in a string
171 # set(_lib_install_targets "${_lib_install_targets} install-lib${_lib}")
172 list(APPEND _lib_install_targets "install-${_lib}")
174 endif(BUILD_SHARED_LIBS)
176 get_target_property(_mdrun_path mdrun LOCATION)
177 add_custom_target(install-mdrun
178 COMMAND ${CMAKE_COMMAND} -E copy "${_mdrun_path}"
179 "${BIN_INSTALL_DIR}/${_mdrun_exec_name}"
180 COMMENT "Installing mdrun")
181 add_dependencies(install-mdrun mdrun ${_lib_install_targets})
185 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libgmxpreprocess.pc.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libgmxpreprocess.pc @ONLY)
186 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgmxpreprocess.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
187 RENAME "libgmxpreprocess${GMX_LIBS_SUFFIX}.pc")