This patch moves the statistics library to its own dir.
[alexxy/gromacs.git] / src / gromacs / CMakeLists.txt
1 #
2 # This file is part of the GROMACS molecular simulation package.
3 #
4 # Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
5 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 # and including many others, as listed in the AUTHORS file in the
7 # top-level source directory and at http://www.gromacs.org.
8 #
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.
13 #
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.
18 #
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.
23 #
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.
31 #
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.
34
35 set(LIBGROMACS_SOURCES)
36
37 function (gmx_install_headers DESTINATION)
38     if (NOT GMX_BUILD_MDRUN_ONLY)
39         if (DESTINATION)
40             set(DESTINATION ${INCL_INSTALL_DIR}/gromacs/${DESTINATION})
41         else()
42             set(DESTINATION ${INCL_INSTALL_DIR}/gromacs)
43         endif()
44         install(FILES ${ARGN} DESTINATION ${DESTINATION} COMPONENT development)
45     endif()
46 endfunction ()
47
48 add_subdirectory(gmxlib)
49 add_subdirectory(mdlib)
50 add_subdirectory(gmxpreprocess)
51 add_subdirectory(commandline)
52 add_subdirectory(fft)
53 add_subdirectory(linearalgebra)
54 add_subdirectory(math)
55 add_subdirectory(onlinehelp)
56 add_subdirectory(options)
57 add_subdirectory(timing)
58 add_subdirectory(utility)
59 add_subdirectory(fileio)
60 add_subdirectory(essentialdynamics)
61 add_subdirectory(pulling)
62 if (NOT GMX_BUILD_MDRUN_ONLY)
63     add_subdirectory(legacyheaders)
64     add_subdirectory(gmxana)
65     add_subdirectory(statistics)
66     add_subdirectory(analysisdata)
67     add_subdirectory(selection)
68     add_subdirectory(trajectoryanalysis)
69 endif ()
70
71 list(APPEND LIBGROMACS_SOURCES ${GMXLIB_SOURCES} ${MDLIB_SOURCES})
72
73 file(GLOB LIBGROMACS_HEADERS *.h)
74 configure_file(version.h.cmakein version.h)
75 gmx_install_headers("" ${LIBGROMACS_HEADERS})
76 gmx_install_headers("" ${CMAKE_CURRENT_BINARY_DIR}/version.h)
77
78 # Add target that generates gitversion.c every time make is run
79 # if git version info is requested
80 # This code is here instead of utility/CMakeLists.txt because CMake
81 # ignores set_source_file_properties from subdirectories.
82 if (GMX_GIT_VERSION_INFO)
83     set(GENERATED_VERSION_FILE ${CMAKE_CURRENT_BINARY_DIR}/utility/gitversion.c)
84     add_custom_target(gmx-version ALL
85             COMMAND ${CMAKE_COMMAND}
86                 -D GIT_EXECUTABLE="${GIT_EXECUTABLE}"
87                 -D PROJECT_VERSION="${PROJECT_VERSION}"
88                 -D PROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}"
89                 -D VERSION_CMAKEIN="${CMAKE_CURRENT_SOURCE_DIR}/utility/gitversion.c.cmakein"
90                 -D VERSION_OUT=${GENERATED_VERSION_FILE}
91                 -P ${CMAKE_SOURCE_DIR}/cmake/gmxGenerateVersionInfo.cmake
92             WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
93             DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/utility/gitversion.c.cmakein
94             COMMENT "Generating git version information")
95     set_source_files_properties(${GENERATED_VERSION_FILE}
96                                 PROPERTIES GENERATED true)
97     list(APPEND LIBGROMACS_SOURCES ${GENERATED_VERSION_FILE})
98 endif()
99
100 # apply gcc 4.4.x bug workaround
101 if(GMX_USE_GCC44_BUG_WORKAROUND)
102    include(gmxGCC44O3BugWorkaround)
103    gmx_apply_gcc44_bug_workaround("gmxlib/bondfree.c")
104    gmx_apply_gcc44_bug_workaround("mdlib/force.c")
105    gmx_apply_gcc44_bug_workaround("mdlib/constr.c")
106 endif()
107
108 add_library(libgromacs ${LIBGROMACS_SOURCES})
109 if (GMX_GIT_VERSION_INFO)
110     add_dependencies(libgromacs gmx-version)
111 endif ()
112
113 # Recent versions of gcc and clang give warnings on scanner.cpp, which
114 # is a generated source file. These are awkward to suppress inline, so
115 # we do it in the compilation command (after testing that the compiler
116 # supports the suppressions). Setting the properties only works after
117 # the related target has been created, e.g. after when the file is
118 # used with add_library().
119 include(CheckCXXCompilerFlag)
120 check_cxx_compiler_flag(-Wno-unused-parameter HAS_NO_UNUSED_PARAMETER)
121 check_cxx_compiler_flag(-Wno-deprecated-register HAS_NO_DEPRECATED_REGISTER)
122 if (HAS_NO_UNUSED_PARAMETER)
123     set(_scanner_cpp_compiler_flags "${_scanner_cpp_compiler_flags} -Wno-unused-parameter")
124 endif()
125 if (HAS_NO_DEPRECATED_REGISTER)
126     set(_scanner_cpp_compiler_flags "${_scanner_cpp_compiler_flags} -Wno-deprecated-register")
127 endif()
128 set_source_files_properties(selection/scanner.cpp PROPERTIES COMPILE_FLAGS "${_scanner_cpp_compiler_flags}")
129
130 target_link_libraries(libgromacs ${GMX_GPU_LIBRARIES}
131                       ${GMX_EXTRA_LIBRARIES}
132                       ${FFT_LIBRARIES} ${LINEAR_ALGEBRA_LIBRARIES}
133                       ${XML_LIBRARIES} ${GSL_LIBRARIES}
134                       ${THREAD_LIB} ${GMX_SHARED_LINKER_FLAGS})
135 set_target_properties(libgromacs PROPERTIES
136                       OUTPUT_NAME "gromacs${GMX_LIBS_SUFFIX}"
137                       SOVERSION ${LIBRARY_SOVERSION}
138                       VERSION ${LIBRARY_VERSION}
139                       COMPILE_FLAGS "${OpenMP_C_FLAGS}")
140
141 # Only install the library in mdrun-only mode if it is actually necessary
142 # for the binary
143 if (NOT GMX_BUILD_MDRUN_ONLY OR BUILD_SHARED_LIBS)
144     install(TARGETS libgromacs DESTINATION ${LIB_INSTALL_DIR} COMPONENT libraries)
145 endif()
146
147 if (NOT GMX_BUILD_MDRUN_ONLY)
148     configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libgromacs.pc.cmakein
149                    ${CMAKE_CURRENT_BINARY_DIR}/libgromacs.pc @ONLY)
150     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgromacs.pc
151             DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
152             RENAME "libgromacs${GMX_LIBS_SUFFIX}.pc"
153             COMPONENT development)
154 endif()
155
156 if (INSTALL_CUDART_LIB) #can be set manual by user
157     if (GMX_GPU)
158         foreach(CUDA_LIB ${CUDA_LIBRARIES})
159             string(REGEX MATCH "cudart" IS_CUDART ${CUDA_LIB})
160             if(IS_CUDART) #libcuda should not be installed
161                 #install also name-links (linker uses those)
162                 file(GLOB CUDA_LIBS ${CUDA_LIB}*)
163                 install(FILES ${CUDA_LIBS} DESTINATION
164                     ${LIB_INSTALL_DIR} COMPONENT libraries)
165             endif()
166         endforeach()
167     else()
168         message(WARNING "INSTALL_CUDART_LIB only makes sense with GMX_GPU")
169     endif()
170 endif ()