2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2018,2019, 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.
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 # This list file provides the Gromacs::gmxapi cmake module.
37 ##########################
38 # Set up public interface.
40 # The parent (src/api/) CMake scope provides a variable named
41 # GMXAPI_PUBLIC_HEADERS containing the full paths to the public
42 # headers that are being installed. The headers are segregated into a
43 # subdirectory here so that their build-time include directory path
44 # does not expose lower level headers.
46 add_subdirectory(include)
48 # The include directory should be mostly empty so that we can use it internally as
49 # the public interface include directory during build and testing.
50 configure_file(include/version.h.in include/gmxapi/version.h)
52 add_library(gmxapi SHARED
64 gmx_target_compile_options(gmxapi)
65 target_compile_definitions(gmxapi PRIVATE HAVE_CONFIG_H)
66 target_include_directories(gmxapi SYSTEM BEFORE PRIVATE ${PROJECT_SOURCE_DIR}/src/external/thread_mpi/include)
68 # Define public interface. Make sure targets linking against `gmxapi` in the build
69 # system don't accidentally have the implementation headers (this directory))
70 # in a default include path.
71 target_include_directories(gmxapi PUBLIC
72 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
73 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
74 $<INSTALL_INTERFACE:include>
76 # Define implementation interface
77 target_include_directories(gmxapi PRIVATE
78 ${CMAKE_CURRENT_SOURCE_DIR}
81 ###############################
82 # Install the public interface.
84 # If any item begins in a generator expression it must evaluate to a full path,
85 # so we can't just use something like $<TARGET_PROPERTIES:gmxapiPublicHeaders,SOURCES>.
86 # Instead, we use a canonical list defined in the parent scope.
87 install(DIRECTORY include/gmxapi
89 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/gmxapi/version.h
90 DESTINATION include/gmxapi)
92 # Ref. https://cmake.org/Wiki/CMake_RPATH_handling
93 # use, i.e. don't skip the full RPATH for the build tree
94 set_target_properties(gmxapi PROPERTIES SKIP_BUILD_RPATH FALSE)
96 # when building, don't use the install RPATH already
97 # (but later on when installing)
98 set_target_properties(gmxapi PROPERTIES BUILD_WITH_INSTALL_RPATH FALSE)
100 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
101 set_target_properties(gmxapi PROPERTIES INSTALL_NAME_DIR "\@rpath")
104 set_target_properties(gmxapi PROPERTIES
105 INSTALL_RPATH_USE_LINK_PATH TRUE
106 SOVERSION ${GMXAPI_MAJOR}
107 VERSION ${GMXAPI_RELEASE}
110 target_link_libraries(gmxapi PRIVATE libgromacs)
113 ################################################
114 # Install and export gmxapi and Gromacs::gmxapi.
116 # Install the gmxapi target and simultaneously define the export target for
117 # which CMake will create a helper file. Specify the directory for clients to
118 # add to their include path to be able to `#include "gmxapi/some_header.h"`
119 install(TARGETS gmxapi
121 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
122 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
123 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
124 INCLUDES DESTINATION include
127 # Create the CMake exports file to help other projects build against libgmxapi
128 # as a CMake import target Gromacs::gmxapi.
129 install(EXPORT gmxapi
131 DESTINATION share/cmake/gmxapi/
133 add_library(Gromacs::gmxapi ALIAS gmxapi )
135 include(CMakePackageConfigHelpers)
137 configure_package_config_file(
138 cmake/gmxapi-config.cmake.in
139 "${CMAKE_CURRENT_BINARY_DIR}/cmake/gmxapi-config.cmake"
140 INSTALL_DESTINATION share/cmake/gmxapi/
142 write_basic_package_version_file(
143 ${CMAKE_CURRENT_BINARY_DIR}/cmake/gmxapi-config-version.cmake
144 VERSION ${GMXAPI_RELEASE}
145 COMPATIBILITY SameMajorVersion
150 ${CMAKE_CURRENT_BINARY_DIR}/cmake/gmxapi-config-version.cmake
151 ${CMAKE_CURRENT_BINARY_DIR}/cmake/gmxapi-config.cmake
152 DESTINATION share/cmake/gmxapi/
155 # We need a CMake target to provide the internal interface(s) of the gmxapi
156 # library implementation.
157 add_library(gmxapi-detail INTERFACE)
158 target_include_directories(gmxapi-detail
159 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
162 add_subdirectory(tests)
163 add_subdirectory(workflow/tests)