Fixing copyright issues and code contributors
[alexxy/gromacs.git] / src / gmxlib / CMakeLists.txt
1 #
2 # This file is part of the GROMACS molecular simulation package.
3 #
4 # Copyright (c) 2012,2013, 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.
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 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
36
37 add_subdirectory(nonbonded)
38
39 # add target that generates version.c every time a make is run
40 # only do this if we generate the version
41 if(USE_VERSION_H)
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")
54 endif()
55
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)
59
60 if(NOT GMX_USE_PLUGINS)
61   list(REMOVE_ITEM GMXLIB_SOURCES vmdio.c vmddlopen.c)
62 endif()
63
64 # This source file is generated
65 file(GLOB VERSION_SOURCE version.c)
66
67 if(VERSION_SOURCE)
68         list(REMOVE_ITEM GMXLIB_SOURCES ${VERSION_SOURCE})
69 endif(VERSION_SOURCE)
70
71 # add version.c to the list of sources and tell cmake that it is generated
72 if(USE_VERSION_H)
73 LIST(APPEND GMXLIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/version.c) # auto-generated
74 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/version.c 
75                 PROPERTIES GENERATED true)
76 endif()
77
78 if(NOT GMX_EXTERNAL_BLAS)
79   file(GLOB BLAS_SOURCES gmx_blas/*.c)
80 endif(NOT GMX_EXTERNAL_BLAS)
81
82 if(NOT GMX_EXTERNAL_LAPACK)
83   file(GLOB LAPACK_SOURCES gmx_lapack/*.c)
84 endif(NOT GMX_EXTERNAL_LAPACK)
85
86 # This would be the standard way to include thread_mpi, but we want libgmx
87 # to link the functions directly
88 #if(GMX_THREAD_MPI)
89 #    add_subdirectory(thread_mpi)
90 #endif(GMX_THREAD_MPI)
91 #target_link_libraries(gmx ${GMX_EXTRA_LIBRARIES} ${FFT_LIBRARIES} ${THREAD_MPI_LIB})
92
93 # apply gcc 4.4.x bug workaround
94 if(GMX_USE_GCC44_BUG_WORKAROUND)
95    include(gmxGCC44O3BugWorkaround)
96    gmx_apply_gcc44_bug_workaround("bondfree.c")
97 endif()
98
99 # Files called xxx_test.c are test drivers with a main() function for module xxx.c,
100 # so they should not be included in the library
101 file(GLOB_RECURSE NOT_GMXLIB_SOURCES *_test.c *\#*)
102 list(REMOVE_ITEM GMXLIB_SOURCES ${NOT_GMXLIB_SOURCES})  
103 # Selection has test_ instead of _test.
104 file(GLOB SELECTION_TEST selection/test*)
105 list(REMOVE_ITEM GMXLIB_SOURCES ${SELECTION_TEST})
106
107 # gpu utils + cuda tools module
108 if(GMX_GPU)
109     add_subdirectory(cuda_tools)
110     add_subdirectory(gpu_utils)   
111     set(GMX_GPU_LIBRARIES gpu_utils cuda_tools)
112 endif()
113
114 # NONBONDED_SOURCES is imported from the nonbonded subdirectory.
115 add_library(gmx ${GMXLIB_SOURCES} ${BLAS_SOURCES} ${LAPACK_SOURCES} ${THREAD_MPI_SRC} ${NONBONDED_SOURCES})
116 target_link_libraries(gmx ${GMX_GPU_LIBRARIES} ${GMX_EXTRA_LIBRARIES} ${FFT_LIBRARIES} ${THREAD_LIB} ${OpenMP_SHARED_LINKER_FLAGS})
117 if(USE_VERSION_H)
118         add_dependencies(gmx gmx_version) 
119 endif()
120 set_target_properties(gmx PROPERTIES OUTPUT_NAME "gmx${GMX_LIBS_SUFFIX}" SOVERSION ${SOVERSION} INSTALL_NAME_DIR "${LIB_INSTALL_DIR}"
121     COMPILE_FLAGS "${OpenMP_C_FLAGS}" COMPILE_DEFINITIONS "TMPI_EXPORTS")
122
123 install(TARGETS gmx DESTINATION ${LIB_INSTALL_DIR} COMPONENT libraries)
124
125 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libgmx.pc.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libgmx.pc @ONLY)
126 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgmx.pc
127         DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
128         RENAME "libgmx${GMX_LIBS_SUFFIX}.pc"
129         COMPONENT development)
130