2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2012, by the GROMACS development team, led by
5 # David van der Spoel, Berk Hess, Erik Lindahl, and including many
6 # others, as listed in the AUTHORS file in the top-level source
7 # directory and at http://www.gromacs.org.
9 # GROMACS is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public License
11 # as published by the Free Software Foundation; either version 2.1
12 # of the License, or (at your option) any later version.
14 # GROMACS is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with GROMACS; if not, see
21 # http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 # If you want to redistribute modifications to GROMACS, please
25 # consider that scientific software is very special. Version
26 # control is crucial - bugs must be traceable. We will be happy to
27 # consider code for inclusion in the official distribution, but
28 # derived work must not be called official GROMACS. Details are found
29 # in the README & COPYING files - if they are missing, get the
30 # official version at http://www.gromacs.org.
32 # To help us fund GROMACS development, we humbly ask that you cite
33 # the research papers on the package. Check out http://www.gromacs.org.
35 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
37 add_subdirectory(nonbonded)
39 # add target that generates version.c every time a make is run
40 # only do this if we generate the version
42 add_custom_target(gmx_version ALL
43 COMMAND ${CMAKE_COMMAND}
44 -D GIT_EXECUTABLE="${GIT_EXECUTABLE}"
45 -D GIT_VERSION="${GIT_VERSION}"
46 -D PROJECT_VERSION="${PROJECT_VERSION}"
47 -D PROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}"
48 -D VERSION_C_CMAKEIN="${CMAKE_SOURCE_DIR}/src/gmxlib/version.c.cmakein"
49 -D VERSION_C_OUT="${CMAKE_CURRENT_BINARY_DIR}/version.c"
50 -P ${CMAKE_SOURCE_DIR}/cmake/gmxGenerateVersionInfo.cmake
51 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/gmxlib
52 DEPENDS ${CMAKE_SOURCE_DIR}/src/gmxlib/version.c.cmakein
53 COMMENT "Generating version information")
56 # The nonbonded directory contains subdirectories that are only
57 # conditionally built, so we cannot use a GLOB_RECURSE here.
58 file(GLOB GMXLIB_SOURCES *.c selection/*.c trajana/*.c statistics/*.c)
61 if(NOT GMX_USE_PLUGINS)
62 list(REMOVE_ITEM GMXLIB_SOURCES vmdio.c vmddlopen.c)
65 # This source file is generated
66 file(GLOB VERSION_SOURCE version.c)
69 list(REMOVE_ITEM GMXLIB_SOURCES ${VERSION_SOURCE})
72 # add version.c to the list of sources and tell cmake that it is generated
74 LIST(APPEND GMXLIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/version.c) # auto-generated
75 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/version.c
76 PROPERTIES GENERATED true)
79 # The log file output queries Cuda if GPU support is enabled
82 include_directories(${CUDA_TOOLKIT_INCLUDE})
84 set_source_files_properties(copyrite.c PROPERTIES COMPILE_FLAGS "-I${CUDA_TOOLKIT_INCLUDE}")
88 if(NOT GMX_EXTERNAL_BLAS)
89 file(GLOB BLAS_SOURCES gmx_blas/*.c)
90 endif(NOT GMX_EXTERNAL_BLAS)
92 if(NOT GMX_EXTERNAL_LAPACK)
93 file(GLOB LAPACK_SOURCES gmx_lapack/*.c)
94 endif(NOT GMX_EXTERNAL_LAPACK)
96 # This would be the standard way to include thread_mpi, but we want libgmx
97 # to link the functions directly
99 # add_subdirectory(thread_mpi)
100 #endif(GMX_THREAD_MPI)
101 #target_link_libraries(gmx ${GMX_EXTRA_LIBRARIES} ${FFT_LIBRARIES} ${THREAD_MPI_LIB})
103 # apply gcc 4.4.x bug workaround
104 if(GMX_USE_GCC44_BUG_WORKAROUND)
105 include(gmxGCC44O3BugWorkaround)
106 gmx_apply_gcc44_bug_workaround("bondfree.c")
109 # Files called xxx_test.c are test drivers with a main() function for module xxx.c,
110 # so they should not be included in the library
111 file(GLOB_RECURSE NOT_GMXLIB_SOURCES *_test.c *\#*)
112 list(REMOVE_ITEM GMXLIB_SOURCES ${NOT_GMXLIB_SOURCES})
113 # Selection has test_ instead of _test.
114 file(GLOB SELECTION_TEST selection/test*)
115 list(REMOVE_ITEM GMXLIB_SOURCES ${SELECTION_TEST})
117 # gpu utils + cuda tools module
119 add_subdirectory(cuda_tools)
120 add_subdirectory(gpu_utils)
121 set(GMX_GPU_LIBRARIES gpu_utils cuda_tools)
124 # NONBONDED_SOURCES is imported from the nonbonded subdirectory.
125 add_library(gmx ${GMXLIB_SOURCES} ${BLAS_SOURCES} ${LAPACK_SOURCES} ${THREAD_MPI_SRC} ${NONBONDED_SOURCES})
126 target_link_libraries(gmx ${GMX_GPU_LIBRARIES} ${GMX_EXTRA_LIBRARIES} ${FFT_LIBRARIES} ${THREAD_LIB} ${OpenMP_SHARED_LINKER_FLAGS})
128 add_dependencies(gmx gmx_version)
130 set_target_properties(gmx PROPERTIES OUTPUT_NAME "gmx${GMX_LIBS_SUFFIX}" SOVERSION ${SOVERSION} INSTALL_NAME_DIR "${LIB_INSTALL_DIR}"
131 COMPILE_FLAGS "${OpenMP_C_FLAGS}" COMPILE_DEFINITIONS "TMPI_EXPORTS")
133 install(TARGETS gmx DESTINATION ${LIB_INSTALL_DIR} COMPONENT libraries)
135 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libgmx.pc.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libgmx.pc @ONLY)
136 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgmx.pc
137 DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
138 RENAME "libgmx${GMX_LIBS_SUFFIX}.pc"
139 COMPONENT development)