-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
124 lines (109 loc) · 5.92 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
cmake_policy(SET CMP0135 NEW)
endif()
# project_VERSION* variables undefined, handled in primary EP
project(pylibefp
LANGUAGES C CXX)
set(pylibefp_AUTHORS "Lori A. Burns")
set(pylibefp_DESCRIPTION "Python binding to I. Kaliman's libefp for Effective Fragment Potentials")
set(pylibefp_URL "https://github.com/loriab/pylibefp")
set(pylibefp_LICENSE "BSD 3-clause")
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
################ Options: Overview and Not Otherwise Mentioned ###############
# <<< CMake build overview >>>
#
# >>> ls
# external/ LICENSE pylibefp/ tests/ ...
# >>> cmake -H. -Bobjdir -DCMAKE_INSTALL_PREFIX=/path/to/install-pylibefp ...
# ...
# -- Generating done
# -- Build files have been written to: /current/dir/objdir
# >>> cd objdir && make -j`getconf _NPROCESSORS_ONLN`
# >>> make install
# <<< Required build dependencies that PylibEFP can't build itself >>>
#
# - CMake (e.g., `conda install cmake`)
# - C++ and C compilers (C++11 compliant)
# - BLAS/LAPACK (also runtime; e.g., `conda install mkl-devel`; for libefp)
# - Python (also runtime; interpreter and headers; e.g., `conda install python`)
# - through qcelemental
# - NumPy (runtime only; e.g., `conda install numpy`)
# - pint (runtime only; e.g., `conda install pint -c conda-forge` or `pip install pint`)
# - deepdiff (testing only; e.g., `conda install deepdiff -c conda-forge` or `pip install deepdiff`)
############################ Options: Build How? #############################
include(psi4OptionsTools)
option_with_flags(ENABLE_XHOST "Enables processor-specific optimization" ON
"-xHost" "-march=native")
option_with_default(CMAKE_BUILD_TYPE "Build type (Release or Debug)" Release)
option_with_default(CMAKE_INSTALL_LIBDIR "Directory to which libraries installed" lib)
option_with_default(PYMOD_INSTALL_LIBDIR "Location within CMAKE_INSTALL_LIBDIR to which python modules are installed" /)
option_with_default(ENABLE_GENERIC "Enables mostly static linking of system libraries for shared library" OFF)
option_with_default(pylibefp_CXX_STANDARD "Specify C++ standard for core pylibefp" 11)
option_with_default(PYLIBEFP_CMAKECONFIG_INSTALL_DIR "Directory within CMAKE_INSTALL_PREFIX to which CMake configuration files installed" "share/cmake/pylibefp")
option_with_default(LIBEFP_CMAKECONFIG_INSTALL_DIR "Directory within CMAKE_INSTALL_PREFIX to which CMake configuration files installed" "share/cmake/libefp")
######################## Process & Validate Options ##########################
include(GNUInstallDirs)
include(autocmake_safeguards)
include(custom_color_messages)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/usr/local/pylibefp" CACHE PATH "Install path" FORCE)
endif()
message(STATUS "pylibefp install: ${CMAKE_INSTALL_PREFIX}")
set(Python_ADDITIONAL_VERSIONS 3.11 3.10 3.9 3.8) # adjust with CMake minimum FindPythonInterp
find_package(Python 3.8 COMPONENTS Interpreter Development REQUIRED)
message(STATUS "${Cyan}Found Python ${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}${ColourReset}: ${Python_EXECUTABLE} (found version ${Python_VERSION})")
set(STAGED_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/stage)
message(STATUS "PylibEFP staging: ${STAGED_INSTALL_PREFIX}")
add_subdirectory(external/upstream)
# external projects manage their own OpenMP and c++YY flags, so only add to CXX_FLAGS for pylibefp-core
include(custom_cxxstandard)
include(custom_static_library)
################################ Main Project ################################
include(ExternalProject)
ExternalProject_Add(pylibefp-core
DEPENDS #lapack_external
libefp_external
pybind11_external
#qcelemental_external
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/pylibefp
CMAKE_ARGS -G${CMAKE_GENERATOR}
-DCMAKE_INSTALL_PREFIX=${STAGED_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_CXX_STANDARD=${pylibefp_CXX_STANDARD}
-DCMAKE_CXX_STANDARD_REQUIRED=ON
-DCMAKE_CXX_EXTENSIONS=OFF
-DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR}
-DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR}
-DCMAKE_INSTALL_DATADIR=${CMAKE_INSTALL_DATADIR}
-DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR}
-DPYLIBEFP_CMAKECONFIG_INSTALL_DIR=${PYLIBEFP_CMAKECONFIG_INSTALL_DIR}
-DPYMOD_INSTALL_LIBDIR=${PYMOD_INSTALL_LIBDIR}
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
-DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=${CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS}
-DPython_EXECUTABLE=${Python_EXECUTABLE}
-DPython_INCLUDE_DIR=${Python_INCLUDE_DIR}
-DPython_LIBRARY=${Python_LIBRARY}
-DPYLIBEFP_ROOT=${CMAKE_CURRENT_SOURCE_DIR}
-DTargetLAPACK_DIR=${TargetLAPACK_DIR}
-Dlibefp_DIR=${libefp_DIR}
-Dpybind11_DIR=${pybind11_DIR}
-DLIBC_INTERJECT=${LIBC_INTERJECT}
CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
-DCMAKE_C_COMPILER_ARG1:STRING=${CMAKE_C_COMPILER_ARG1}
-DCMAKE_CXX_COMPILER_ARG1:STRING=${CMAKE_CXX_COMPILER_ARG1}
BUILD_ALWAYS 1)
add_subdirectory(doc)
add_subdirectory(tests)
# <<< Install >>>
install(DIRECTORY ${STAGED_INSTALL_PREFIX}/
DESTINATION ${CMAKE_INSTALL_PREFIX}
USE_SOURCE_PERMISSIONS
PATTERN "*.pyc" EXCLUDE)