50f77476416a1d1045fb450c7dbbefe2bbf094c7
[alexxy/gromacs.git] / src / kernel / CMakeLists.txt
1
2 set(GMXPREPROCESS_SOURCES 
3     add_par.c       
4     compute_io.c    
5     convparm.c      
6     gen_ad.c        
7     gen_vsite.c     
8     genhydro.c   
9     gpp_atomtype.c  
10     gpp_bond_atomtype.c     
11     h_db.c          
12     hackblock.c             
13     hizzie.c        
14     nm2type.c
15     pdb2top.c       
16     pgutil.c        
17     readir.c        
18     readpull.c      
19     readadress.c      
20     readrot.c
21     resall.c        
22     sorting.c       
23     specbond.c      
24     ter_db.c        
25     tomorse.c       
26     topdirs.c       
27     topexcl.c       
28     topio.c         
29     toppush.c       
30     topshake.c      
31     toputil.c       
32     tpbcmp.c        
33     vsite_parm.c    
34     fflibutil.c
35     xlate.c)
36
37 set(MDRUN_SOURCES 
38     gctio.c    ionize.c runner.c
39     do_gct.c     repl_ex.c  xutils.c
40     md.c         mdrun.c    genalg.c membed.c
41     md_openmm.c)
42
43 add_library(gmxpreprocess ${GMXPREPROCESS_SOURCES})
44 target_link_libraries(gmxpreprocess md)
45 set_target_properties(gmxpreprocess PROPERTIES OUTPUT_NAME "gmxpreprocess${GMX_LIBS_SUFFIX}" SOVERSION ${SOVERSION} INSTALL_NAME_DIR "${LIB_INSTALL_DIR}"
46     COMPILE_FLAGS "${OpenMP_C_FLAGS}")
47
48
49 if(GMX_OPENMM) 
50     add_subdirectory(gmx_gpu_utils)
51     include_directories(./gmx_gpu_utils ${OpenMM_INCLUDE_DIR})
52     link_directories(${OpenMM_LIBRARY_DIR}) 
53     # with this define no evn.var. is needed with OPENMM_PLUGIN_DIR
54     # if the same OpenMM installation is used for running and building 
55     add_definitions( -DOPENMM_PLUGIN_DIR="${OpenMM_PLUGIN_DIR}" ) 
56     file(TO_CMAKE_PATH ${OpenMM_PLUGIN_DIR} _path)
57     add_library(openmm_api_wrapper STATIC openmm_wrapper.cpp)
58     target_link_libraries(openmm_api_wrapper gmx_gpu_utils ${OpenMM_LIBRARIES})
59     set(GMX_OPENMM_LIBRARIES openmm_api_wrapper gmx_gpu_utils ${OpenMM_LIBRARIES})   
60 endif(GMX_OPENMM)
61
62 if(GMX_FAHCORE)
63   add_library(fahcore ${MDRUN_SOURCES})
64 else(GMX_FAHCORE)
65
66 list(APPEND GMX_EXTRA_LIBRARIES gmxpreprocess md ${OpenMP_LINKER_FLAGS})
67
68 set(GMX_KERNEL_PROGRAMS
69     grompp tpbconv pdb2gmx g_protonate g_luck gmxdump g_x2top gmxcheck)
70
71 foreach(PROGRAM ${GMX_KERNEL_PROGRAMS})
72     add_executable(${PROGRAM} ${PROGRAM}.c)
73     if (NOT ${PROGRAM} STREQUAL "g_luck")
74         gmx_add_man_page(${PROGRAM})
75     endif()
76     target_link_libraries(${PROGRAM} ${GMX_EXTRA_LIBRARIES})
77     set_target_properties(${PROGRAM} PROPERTIES OUTPUT_NAME "${PROGRAM}${GMX_BINARY_SUFFIX}")
78 endforeach()
79
80 add_executable(mdrun ${MDRUN_SOURCES})
81 gmx_add_man_page(mdrun)
82 target_link_libraries(mdrun ${GMX_EXTRA_LIBRARIES} ${GMX_OPENMM_LIBRARIES})
83 set_target_properties(mdrun PROPERTIES OUTPUT_NAME "mdrun${GMX_BINARY_SUFFIX}" COMPILE_FLAGS "${OpenMP_C_FLAGS}")
84
85 # this is to circumvent the following MSVC error: 
86 # warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs
87 # fatal error LNK1169: one or more multiply defined symbols found
88 if(GMX_OPENMM AND MSVC)
89     set_target_properties(mdrun PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT")
90 endif()
91
92 # Construct component groups for installation
93 foreach(PROGRAM ${GMX_KERNEL_PROGRAMS} mdrun)
94     set(CPACK_COMPONENT_${PROGRAM}_GROUP tools)
95 endforeach()
96 set(CPACK_COMPONENT_MDRUN_GROUP mdrun)
97
98 # Create custom install-xxxx targets, component dependences,
99 # and trigger the installation
100 foreach(PROGRAM ${GMX_KERNEL_PROGRAMS} mdrun)
101     set(CPACK_COMPONENT_${PROGRAM}_DEPENDS libraries)
102     if (BUILD_SHARED_LIBS)
103     # If shared libraries are used, we need to install the libraries in
104     # addition to the mdrun binary.
105        add_custom_target(install-${PROGRAM}
106            COMMAND ${CMAKE_COMMAND} -DCOMPONENT=libraries
107                    -P ${CMAKE_BINARY_DIR}/cmake_install.cmake
108            COMMAND ${CMAKE_COMMAND} -DCOMPONENT=${PROGRAM}
109                    -P ${CMAKE_BINARY_DIR}/cmake_install.cmake
110            COMMENT "Installing ${PROGRAM}")
111     else()
112        add_custom_target(install-${PROGRAM}
113            COMMAND ${CMAKE_COMMAND} -DCOMPONENT=${PROGRAM}
114                    -P ${CMAKE_BINARY_DIR}/cmake_install.cmake
115            COMMENT "Installing ${PROGRAM}")
116     endif()
117     add_dependencies(install-${PROGRAM} ${PROGRAM})
118     install(
119       TARGETS ${PROGRAM}
120       COMPONENT ${PROGRAM}
121       DESTINATION ${BIN_INSTALL_DIR}
122       )
123 endforeach()
124
125 install(TARGETS gmxpreprocess DESTINATION ${LIB_INSTALL_DIR} COMPONENT libraries)
126
127 endif(GMX_FAHCORE)
128
129 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libgmxpreprocess.pc.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libgmxpreprocess.pc @ONLY)
130 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgmxpreprocess.pc
131         DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
132         RENAME "libgmxpreprocess${GMX_LIBS_SUFFIX}.pc"
133         COMPONENT development)