-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
78 lines (64 loc) · 3.08 KB
/
CMakeLists.txt
File metadata and controls
78 lines (64 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Sourcing GMXRC from a GROMACS installation should allow discovery of exported CMake config to import `libgmxapi` target.
# If the libgmxapi dependency is satisfied by allowing setuptools to build GROMACS, it should use GROMACS_DIR to hint
# the location.
#
# find_package should find gmxapiConfig.cmake if the path to `gmx` is in PATH,
# if gmxapi_DIR is set to the GROMACS installation directory, or if
# cmake was invoked with `-DCMAKE_PREFIX_PATH=...` pointing to the GROMACS
# installation directory. We can also check now for a GROMACS_DIR environment
# variable and provide it with the HINTS option.
find_package(gmxapi 0.0.6 REQUIRED
HINTS "$ENV{GROMACS_DIR}"
)
# Build the C++ extension
pybind11_add_module(pygmx_core
core.h
core.cpp
export_context.cpp
export_md.cpp
export_system.cpp
gmxpy_api.h
pymdmodule.h
pymdmodule.cpp
pysystem.h
pysystem.cpp
)
# The target name is for clarity, but the installed module will be gmx.core
set_target_properties(pygmx_core PROPERTIES OUTPUT_NAME core)
#set(PYGMX_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
# CACHE PATH "Full path to the gmx module installation")
# Set the output to the staging area
# For installs that are part of a GROMACS install, we probably want to stage differently
# set_target_properties(
# pygmx_core
# PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${PYGMX_DIRECTORY}")
set_target_properties(pygmx_core PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/gmx)
target_include_directories(pygmx_core PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
# RPATH management
#set(PYGMX_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}" CACHE PATH
# "Set to override RPATH for Python C++ extension (as by setuptools)")
#mark_as_advanced(PYGMX_RPATH)
# don't skip the full RPATH for the build tree
set_target_properties(pygmx_core PROPERTIES SKIP_BUILD_RPATH FALSE)
# (but later on when installing)
# If building with setuptools, CMake will not be performing the install
set_target_properties(pygmx_core PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
#set_target_properties(pygmx_core PROPERTIES INSTALL_RPATH ${PYGMX_RPATH})
target_link_libraries(pygmx_core PRIVATE Gromacs::gmxapi)
include(GNUInstallDirs)
# workaround for relocated package when installing nested gromacs on readthedocs.org
if(DEFINED ENV{READTHEDOCS} OR DEFINED ENV{BUILDGROMACS})
if(UNIX AND NOT APPLE)
set_target_properties(pygmx_core PROPERTIES INSTALL_RPATH "$ORIGIN/data/gromacs/${CMAKE_INSTALL_LIBDIR}")
elseif(APPLE)
set_target_properties(pygmx_core PROPERTIES INSTALL_RPATH "@loader_path/data/gromacs/${CMAKE_INSTALL_LIBDIR}")
endif()
endif()
set_target_properties(pygmx_core PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
install(TARGETS pygmx_core
LIBRARY DESTINATION ${GMXAPI_INSTALL_PATH}
ARCHIVE DESTINATION ${GMXAPI_INSTALL_PATH}
RUNTIME DESTINATION ${GMXAPI_INSTALL_PATH})