cce39574e7c1c99a0e9e0d05613515010423bdd4
[alexxy/gromacs.git] / src / mdlib / CMakeLists.txt
1 # The nbnxn kernel files take the longest time to compile, so we sneak
2 # them in first to take best advantage of make-time parallelisation.
3 file(GLOB MDLIB_SOURCES nbnxn_kernels/*.c *.c)
4
5 if(GMX_GPU)
6     add_subdirectory(nbnxn_cuda)
7     set(GMX_GPU_LIBRARIES nbnxn_cuda)
8 endif()
9
10 # apply gcc 4.4.x bug workaround
11 if(GMX_USE_GCC44_BUG_WORKAROUND)
12    include(gmxGCC44O3BugWorkaround)
13    gmx_apply_gcc44_bug_workaround("force.c")
14    gmx_apply_gcc44_bug_workaround("constr.c")
15 endif()
16
17 # Files called xxx_test.c are test drivers with a main() function for 
18 # module xxx.c, so they should not be included in the library
19
20 if(NOT GMX_FFT_FFTPACK)
21 list(REMOVE_ITEM MDLIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/fftpack.c)
22 endif()
23
24 add_library(md ${MDLIB_SOURCES})
25
26 target_link_libraries(md ${GMX_GPU_LIBRARIES} gmx ${GMX_EXTRA_LIBRARIES} ${FFT_LIBRARIES} ${OpenMP_SHARED_LINKER_FLAGS})
27 if(GMX_BUILD_OWN_FFTW)
28     # This dependency has to be made here rather than the CMakeLists.txt that
29     # does the FFTW build, because of the order in which
30     # add_subdirectory() calls are made in the top-level CMakeLists.txt; the
31     # md library target does not necessarily exist yet. Also enabling and
32     # disabling GMX_BUILD_OWN_FFTW changes dependencies correctly.
33     add_dependencies(md gmxfftw)
34 endif()
35 set_target_properties(md PROPERTIES OUTPUT_NAME "md${GMX_LIBS_SUFFIX}" SOVERSION ${SOVERSION} INSTALL_NAME_DIR "${LIB_INSTALL_DIR}"
36     COMPILE_FLAGS "${OpenMP_C_FLAGS}")
37
38 install(TARGETS md DESTINATION ${LIB_INSTALL_DIR} COMPONENT libraries)
39
40 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libmd.pc.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libmd.pc @ONLY)
41 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libmd.pc
42         DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
43         RENAME "libmd${GMX_LIBS_SUFFIX}.pc"
44         COMPONENT development)