2 set(GMXPREPROCESS_SOURCES
37 gctio.c ionize.c runner.c
38 do_gct.c repl_ex.c xutils.c
39 md.c mdrun.c genalg.c membed.c
42 add_library(gmxpreprocess ${GMXPREPROCESS_SOURCES})
43 target_link_libraries(gmxpreprocess md)
44 set_target_properties(gmxpreprocess PROPERTIES OUTPUT_NAME "gmxpreprocess${GMX_LIBS_SUFFIX}" SOVERSION ${SOVERSION} INSTALL_NAME_DIR "${LIB_INSTALL_DIR}")
45 set_target_properties(md PROPERTIES OUTPUT_NAME "md${GMX_LIBS_SUFFIX}" SOVERSION ${SOVERSION} INSTALL_NAME_DIR "${LIB_INSTALL_DIR}")
49 add_subdirectory(gmx_gpu_utils)
50 include_directories(./gmx_gpu_utils ${OpenMM_INCLUDE_DIR})
51 link_directories(${OpenMM_LIBRARY_DIR})
52 # only define if this is a local build not a release
53 # we assume that the auto-generated version is not used &&
54 # version string does not contain "-dev" => it's a release build
55 if(NOT USE_VERSION_H AND NOT PROJECT_VERSION MATCHES ".*-dev.*")
56 add_definitions( -DOPENMM_PLUGIN_DIR="${OpenMM_PLUGIN_DIR}" )
58 add_definitions( -DOPENMM_PLUGIN_DIR="" )
60 add_library(openmm_api_wrapper STATIC openmm_wrapper.cpp)
61 target_link_libraries(openmm_api_wrapper gmx_gpu_utils ${OpenMM_LIBRARIES})
62 set(GMX_OPENMM_LIBRARIES openmm_api_wrapper gmx_gpu_utils ${OpenMM_LIBRARIES})
66 add_library(fahcore ${MDRUN_SOURCES})
69 list(APPEND GMX_EXTRA_LIBRARIES gmxpreprocess md)
71 add_executable(grompp grompp.c)
72 target_link_libraries(grompp ${GMX_EXTRA_LIBRARIES})
73 set_target_properties(grompp PROPERTIES OUTPUT_NAME "grompp${GMX_BINARY_SUFFIX}")
75 add_executable(tpbconv tpbconv.c)
76 target_link_libraries(tpbconv ${GMX_EXTRA_LIBRARIES})
77 set_target_properties(tpbconv PROPERTIES OUTPUT_NAME "tpbconv${GMX_BINARY_SUFFIX}")
79 add_executable(pdb2gmx pdb2gmx.c)
80 target_link_libraries(pdb2gmx ${GMX_EXTRA_LIBRARIES})
81 set_target_properties(pdb2gmx PROPERTIES OUTPUT_NAME "pdb2gmx${GMX_BINARY_SUFFIX}")
83 add_executable(g_protonate g_protonate.c)
84 target_link_libraries(g_protonate ${GMX_EXTRA_LIBRARIES})
85 set_target_properties(g_protonate PROPERTIES OUTPUT_NAME "g_protonate${GMX_BINARY_SUFFIX}")
87 add_executable(g_luck g_luck.c)
88 target_link_libraries(g_luck ${GMX_EXTRA_LIBRARIES})
89 set_target_properties(g_luck PROPERTIES OUTPUT_NAME "g_luck${GMX_BINARY_SUFFIX}")
91 add_executable(gmxdump gmxdump.c)
92 target_link_libraries(gmxdump ${GMX_EXTRA_LIBRARIES})
93 set_target_properties(gmxdump PROPERTIES OUTPUT_NAME "gmxdump${GMX_BINARY_SUFFIX}")
95 add_executable(g_x2top g_x2top.c)
96 target_link_libraries(g_x2top ${GMX_EXTRA_LIBRARIES})
97 set_target_properties(g_x2top PROPERTIES OUTPUT_NAME "g_x2top${GMX_BINARY_SUFFIX}")
99 add_executable(gmxcheck gmxcheck.c)
100 target_link_libraries(gmxcheck ${GMX_EXTRA_LIBRARIES})
101 set_target_properties(gmxcheck PROPERTIES OUTPUT_NAME "gmxcheck${GMX_BINARY_SUFFIX}")
103 add_executable(mdrun ${MDRUN_SOURCES})
104 target_link_libraries(mdrun ${GMX_EXTRA_LIBRARIES} ${GMX_OPENMM_LIBRARIES})
105 set_target_properties(mdrun PROPERTIES OUTPUT_NAME "mdrun${GMX_BINARY_SUFFIX}")
107 # this is to circumvent the following MSVC error:
108 # warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs
109 # fatal error LNK1169: one or more multiply defined symbols found
110 if(GMX_OPENMM AND MSVC)
111 set_target_properties(mdrun PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT")
125 gmxpreprocess DESTINATION ${LIB_INSTALL_DIR}
126 RUNTIME DESTINATION ${BIN_INSTALL_DIR})
129 # if we build shared gromacs libs, when installing throught the install-mdrun target
130 # these libs need to be installed as well
131 if(BUILD_SHARED_LIBS)
132 # in MDRUN_LIBS we store the libraries MDRUN links against (NOTE: hardcoded!!!)
133 set(MDRUN_LIBS gmxpreprocess md gmx)
135 # generate install-libXXX custom target for each shared lib that mdrun links against
136 foreach(_lib ${MDRUN_LIBS})
137 # double-check that the type is SHARED
138 get_target_property(_type ${_lib} TYPE)
139 if(NOT ${_type} STREQUAL "SHARED_LIBRARY")
140 message(FATAL_ERROR " Internal error: library ${_lib} is not shared so it's not supposed to be processed for installing")
143 # figure out the path and filename under which the lib will be installed
144 # (libname with pre- and suffix)
145 get_target_property(_lib_path ${_lib} LOCATION)
146 string(REGEX REPLACE "/" ";" _lib_fname ${_lib_path})
147 list(REVERSE _lib_fname)
148 list(GET _lib_fname 0 _lib_fname)
150 # create custom target for copying each library to the install location
151 # TODO: need to fix this to have the .so.6 form
152 add_custom_target(install-${_lib}
153 COMMAND ${CMAKE_COMMAND} -E copy
154 "${_lib_path}" "${LIB_INSTALL_DIR}/${_lib_fname}.${SOVERSION}"
155 COMMAND ${CMAKE_COMMAND} -E create_symlink
156 "${_lib_fname}.${SOVERSION}" "${LIB_INSTALL_DIR}/${_lib_fname}"
157 COMMENT "Installing library ${_lib}")
158 add_dependencies(install-${_lib} ${_lib})
160 # gather the custom target names in a string
161 # set(_lib_install_targets "${_lib_install_targets} install-lib${_lib}")
162 list(APPEND _lib_install_targets "install-${_lib}")
164 endif(BUILD_SHARED_LIBS)
166 get_target_property(_mdrun_path mdrun LOCATION)
167 add_custom_target(install-mdrun
168 COMMAND ${CMAKE_COMMAND} -E copy "${_mdrun_path}"
169 "${BIN_INSTALL_DIR}/${_mdrun_exec_name}"
170 COMMENT "Installing mdrun")
171 add_dependencies(install-mdrun mdrun ${_lib_install_targets})
175 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libgmxpreprocess.pc.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libgmxpreprocess.pc @ONLY)
176 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgmxpreprocess.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
177 RENAME "libgmxpreprocess${GMX_LIBS_SUFFIX}.pc")