forked from kassonlab/gmxapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
90 lines (78 loc) · 4.87 KB
/
CMakeLists.txt
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
79
80
81
82
83
84
85
86
87
88
89
90
cmake_minimum_required(VERSION 3.4.3)
# CMake modules/macros are in a subdirectory to keep this file cleaner
# This needs to be set before project() in order to pick up toolchain files
#list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# skbuild sets OS X deployment target to 10.6 for compatibility, but we want to require 10.9 and C++11 compatibility.
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9 CACHE STRING "OS X deployment target below 10.9 does not use C++11 standard library" FORCE)
# Sets the PROJECT_VERSION variable, as well...
project(gmxpy VERSION 0.0.7)
# Only interpret if() arguments as variables or keywords when unquoted.
cmake_policy(SET CMP0054 NEW)
set(CMAKE_CXX_STANDARD 11)
include(Ccache.cmake)
# If the user is not in a virtual environment and is not a privileged user and has not specified an install location
# for the Python module (GMXAPI_INSTALL_PATH), this option causes the automatic install location to query the user
# site-packages directory instead of using the default site-packages directory for the interpreter.
option(GMXAPI_USER_INSTALL
"Override the default site-packages directory with the user-specific Python packages directory. \
(Do not use with virtual environments.) \
Has no effect if GMXAPI_INSTALL_PATH is defined or cached. \
Use -UGMXAPI_INSTALL_PATH to force recalculation." OFF)
# Since a user may have multiple virtual environments with different Python interpreters, it is generally confusing to
# have a package for a virtual environment installed in the user's default user site-packages directory. For setup.py
# installs, use the `--user` flag for `pip` or `setup.py`. When using CMake directly, use GMXAPI_USER_INSTALL=ON to
# override the default site-packages install directory with the user-specific location.
unset(PYTHONINTERP_FOUND)
unset(PYTHONLIBS_FOUND)
# This will get cleaner with FindPython in CMake 3.12 and higher. We're a ways from requiring that, but
# we can add logic for it soon to be ready.
find_package(PythonInterp)
if (PYTHONINTERP_FOUND)
message(STATUS "Found Python interpreter: ${PYTHON_EXECUTABLE}")
find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT)
if (PYTHONLIBS_FOUND)
message(STATUS "Python headers in ${PYTHON_INCLUDE_DIRS}")
message(STATUS "Python libraries in ${PYTHON_LIBRARIES}")
if (GMXAPI_USER_INSTALL)
execute_process(COMMAND ${PYTHON_EXECUTABLE} "-m" "site" "--user-site"
OUTPUT_VARIABLE GMXAPI_DEFAULT_SITE_PACKAGES
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Python user site-packages directory is ${GMXAPI_DEFAULT_SITE_PACKAGES}")
else()
execute_process(COMMAND
${PYTHON_EXECUTABLE} -c
"import sys; import os; \
print(\
os.path.abspath(os.path.join(\
sys.prefix, \
'lib', \
'python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}',\
'site-packages')\
)\
)"
OUTPUT_VARIABLE GMXAPI_DEFAULT_SITE_PACKAGES
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Python site-packages directory is ${GMXAPI_DEFAULT_SITE_PACKAGES}")
endif()
else()
message(FATAL_ERROR
"Found Python interpreter ${PYTHON_EXECUTABLE} \
but this Python installation does not have developer tools."
"Set PYTHON_EXECUTABLE to the Python interpreter that was installed with a working Python.h header file.")
endif()
else()
message(FATAL_ERROR "Could not find Python interpreter. Set CMake flag -DPYTHON_EXECUTABLE=/path/to/python to hint.")
endif()
# At some point this may be part of a CMake package with several components for which a single CMAKE_INSTALL_PREFIX does
# not make sense, so let's manage the install path separately.
set(GMXAPI_INSTALL_PATH ${GMXAPI_DEFAULT_SITE_PACKAGES}/gmx CACHE PATH
"Path to Python module install location (site-packages). For an automatically determined install location based on \
the Python installation, leave undefined or explicitly undefined with -UGMXAPI_INSTALL_PATH and, optionally, set \
GMXAPI_USER_INSTALL on or off to specify the installation's site-packages directory or the 'user' site-packages \
directory.")
message(STATUS "Python module will be installed to GMXAPI_INSTALL_PATH cache value ${GMXAPI_INSTALL_PATH}")
# pybind11 is included as a subtree and updated just with squash merges.
# Refer to https://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree
add_subdirectory(pybind11)
add_subdirectory(src)
add_subdirectory(docs)