1 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
3 add_subdirectory(nonbonded)
5 # add target that generates version.c every time a make is run
6 # only do this if we generate the version
8 add_custom_target(gmx_version ALL
9 COMMAND ${CMAKE_COMMAND}
10 -D GIT_EXECUTABLE="${GIT_EXECUTABLE}"
11 -D GIT_VERSION="${GIT_VERSION}"
12 -D PROJECT_VERSION="${PROJECT_VERSION}"
13 -D PROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}"
14 -D VERSION_C_CMAKEIN="${CMAKE_SOURCE_DIR}/src/gmxlib/version.c.cmakein"
15 -D VERSION_C_OUT="${CMAKE_CURRENT_BINARY_DIR}/version.c"
16 -P ${CMAKE_SOURCE_DIR}/cmake/gmxGenerateVersionInfo.cmake
17 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/gmxlib
18 DEPENDS ${CMAKE_SOURCE_DIR}/src/gmxlib/version.c.cmakein
19 COMMENT "Generating version information")
22 # The nonbonded directory contains subdirectories that are only
23 # conditionally built, so we cannot use a GLOB_RECURSE here.
24 file(GLOB GMXLIB_SOURCES *.c selection/*.c trajana/*.c statistics/*.c)
27 if(NOT GMX_USE_PLUGINS)
28 list(REMOVE_ITEM GMXLIB_SOURCES vmdio.c vmddlopen.c)
31 # This source file is generated
32 file(GLOB VERSION_SOURCE version.c)
35 list(REMOVE_ITEM GMXLIB_SOURCES ${VERSION_SOURCE})
38 # add version.c to the list of sources and tell cmake that it is generated
40 LIST(APPEND GMXLIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/version.c) # auto-generated
41 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/version.c
42 PROPERTIES GENERATED true)
45 if(NOT GMX_EXTERNAL_BLAS)
46 file(GLOB BLAS_SOURCES gmx_blas/*.c)
47 endif(NOT GMX_EXTERNAL_BLAS)
49 if(NOT GMX_EXTERNAL_LAPACK)
50 file(GLOB LAPACK_SOURCES gmx_lapack/*.c)
51 endif(NOT GMX_EXTERNAL_LAPACK)
53 # This would be the standard way to include thread_mpi, but we want libgmx
54 # to link the functions directly
56 # add_subdirectory(thread_mpi)
57 #endif(GMX_THREAD_MPI)
58 #target_link_libraries(gmx ${GMX_EXTRA_LIBRARIES} ${THREAD_MPI_LIB})
60 # apply gcc 4.4.x bug workaround
61 if(GMX_USE_GCC44_BUG_WORKAROUND)
62 include(gmxGCC44O3BugWorkaround)
63 gmx_apply_gcc44_bug_workaround("bondfree.c")
66 # Files called xxx_test.c are test drivers with a main() function for module xxx.c,
67 # so they should not be included in the library
68 file(GLOB_RECURSE NOT_GMXLIB_SOURCES *_test.c *\#*)
69 list(REMOVE_ITEM GMXLIB_SOURCES ${NOT_GMXLIB_SOURCES})
70 # Selection has test_ instead of _test.
71 file(GLOB SELECTION_TEST selection/test*)
72 list(REMOVE_ITEM GMXLIB_SOURCES ${SELECTION_TEST})
74 # gpu utils + cuda tools module
76 add_subdirectory(cuda_tools)
77 add_subdirectory(gpu_utils)
78 set(GMX_GPU_LIBRARIES gpu_utils cuda_tools)
81 # NONBONDED_SOURCES is imported from the nonbonded subdirectory.
82 add_library(gmx ${GMXLIB_SOURCES} ${BLAS_SOURCES} ${LAPACK_SOURCES} ${THREAD_MPI_SRC} ${NONBONDED_SOURCES})
83 target_link_libraries(gmx ${GMX_GPU_LIBRARIES} ${GMX_EXTRA_LIBRARIES} ${THREAD_LIB} ${OpenMP_SHARED_LINKER_FLAGS})
85 add_dependencies(gmx gmx_version)
87 set_target_properties(gmx PROPERTIES OUTPUT_NAME "gmx${GMX_LIBS_SUFFIX}" SOVERSION ${SOVERSION} INSTALL_NAME_DIR "${LIB_INSTALL_DIR}"
88 COMPILE_FLAGS "${OpenMP_C_FLAGS}")
90 install(TARGETS gmx DESTINATION ${LIB_INSTALL_DIR} COMPONENT libraries)
92 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libgmx.pc.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libgmx.pc @ONLY)
93 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgmx.pc
94 DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
95 RENAME "libgmx${GMX_LIBS_SUFFIX}.pc"
96 COMPONENT development)