a72b7f89965dbfb075115cbcad0e7fae147998be
[alexxy/gromacs.git] / api / gmxapi / CMakeLists.txt
1 #
2 # This file is part of the GROMACS molecular simulation package.
3 #
4 # Copyright (c) 2018,2019,2020, 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 # This list file provides the Gromacs::gmxapi cmake module.
36
37 ##########################
38 # Set up public interface.
39
40 # Note: GROMACS releases have a single-integer monotonic version in GMX_API_VERSION
41 # and LIBRARY_VERSION annotates the shared object for libgromacs. GMXAPI versioning
42 # is not synchronized to releases and may increment faster or slower.
43 #
44 # Prior to 0.1, GMXAPI patch levels are used to mark short term development cycles
45 # and allow compatibility checks for client software of the early releases.
46 #
47 # gmxapi 0.2 will be the first release candidate for gmxapi 1.0 and will attempt
48 # to establish compatibility guarantees consistent with semantic versioning.
49 # (https://semver.org). When the API is deemed suitably stable, gmxapi 1.0 should
50 # be tagged. Official GROMACS releases should be mappable to a distinct gmxapi
51 # release string. For roadmap details, see https://gitlab.com/gromacs/gromacs/-/issues/2585
52 set(GMXAPI_MAJOR 0)
53 set(GMXAPI_MINOR 1)
54 set(GMXAPI_PATCH 0)
55 set(GMXAPI_RELEASE ${GMXAPI_MAJOR}.${GMXAPI_MINOR}.${GMXAPI_PATCH})
56
57 add_library(gmxapi)
58 set_target_properties(gmxapi PROPERTIES
59                       VERSION_MAJOR ${GMXAPI_MAJOR}
60                       VERSION_MINOR ${GMXAPI_MINOR}
61                       VERSION_PATCH ${GMXAPI_PATCH}
62                       RELEASE ${GMXAPI_RELEASE})
63
64
65 if (GMX_LIB_MPI)
66     # GROMACS is built against an MPI library.
67     # Clarification should be possible with resolution of #3672.
68     set(_gmx_mpi_type "library")
69 elseif(GMX_THREAD_MPI)
70     # GROMACS is built with its internal thread-MPI implementation.
71     set(_gmx_mpi_type "tmpi")
72 else()
73     # GROMACS is built without MPI or thread-MPI.
74     set(_gmx_mpi_type "none")
75 endif ()
76 define_property(TARGET PROPERTY MPI
77                 BRIEF_DOCS "MPI capability of the GROMACS library."
78                 FULL_DOCS "Values of 'library', 'tmpi', or 'none' indicate the configure-time options of the GROMACS
79                  library build.")
80 set_target_properties(gmxapi PROPERTIES
81                       MPI ${_gmx_mpi_type})
82 unset(_gmx_mpi_type)
83
84 ##########################
85 # Define public interface.
86 #
87 # The include directory should be mostly empty so that we can use it internally as
88 # the public interface include directory during build and testing.
89 configure_file(include/gmxapiversion.h.in include/gmxapi/version.h)
90 configure_file(include/resourceassignment.cmakein.h include/gmxapi/mpi/resourceassignment.h)
91 target_include_directories(gmxapi PUBLIC
92                            $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
93                            $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
94                            $<INSTALL_INTERFACE:include>
95                            )
96
97 add_subdirectory(cpp)
98
99 ###############################
100 # Install the public interface.
101 #
102 # If any item begins in a generator expression it must evaluate to a full path,
103 # so we can't just use something like $<TARGET_PROPERTIES:gmxapiPublicHeaders,SOURCES>.
104 # Instead, we use a canonical list defined in the parent scope.
105
106 # Install public header directories.
107 install(DIRECTORY include/gmxapi
108         DESTINATION include)
109
110 # Install "configured" files from the build tree.
111 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/gmxapi/version.h
112         DESTINATION include/gmxapi)
113 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/gmxapi/mpi/resourceassignment.h
114         DESTINATION include/gmxapi/mpi)
115