-
Notifications
You must be signed in to change notification settings - Fork 98
/
CMakeLists.txt
125 lines (102 loc) · 3.72 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
125
if (CMAKE_HOST_WIN32)
cmake_minimum_required(VERSION 3.21)
else()
cmake_minimum_required(VERSION 3.16)
endif()
cmake_policy(SET CMP0079 NEW)
project(libint2-python)
if (NOT TARGET Python::Module)
find_package(Python COMPONENTS Interpreter Development REQUIRED)
endif()
find_package(pybind11 2.6.0 CONFIG)
if (NOT TARGET pybind11::pybind11)
message(STATUS "Suitable pybind11 could not be located, building pybind11 instead.")
# [LAB May 2023] For a long time this was fixed at v2.4.3 from a Valeev group clone.
# * recently noticed that C++17 is not getting processed right for this version (at least with the Ubuntu GHA setup)
# * so bumping the backup tag to v2.6.0 (c.2021). the v2.4.3 could probably be revived if needed.
include(FetchContent)
FetchContent_Declare(
pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG v2.6.0 # sync below!
# GIT_REPOSITORY https://github.com/ValeevGroup/pybind11.git
# GIT_TAG 80d452484c5409444b0ec19383faa84bb7a4d351 # v2.4.3
# FIND_PACKAGE_ARGS 2.4.3 CONFIG # CMake 3.24 integrates find_package() call above into FC_Declare
)
FetchContent_MakeAvailable(pybind11)
set(pybind11_VERSION "2.6.0") # getting the fetched version isn't reliable from ${CMAKE_PROJECT_VERSION}), so sync explicitly from tag above
endif()
if (pybind11_VERSION VERSION_LESS_EQUAL 2.5.0)
# remove after minimum pb11 advances beyond v2.5.0 and let cxx_std_17 below do the work
set(CMAKE_CXX_STANDARD 17)
endif()
if (pybind11_VERSION VERSION_GREATER_EQUAL 2.11.0)
# ipo/lto triggering changed https://github.com/pybind/pybind11/pull/4643
if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC"))
# clang-cl
# this variable needs to be defined, not the property
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)
endif()
endif()
pybind11_add_module(
libint2-python MODULE
#EXCLUDE_FROM_ALL
src/libint2/libint2.cc
src/libint2/engine.cc
)
target_compile_features(libint2-python PRIVATE "cxx_std_17")
if (pybind11_VERSION VERSION_GREATER_EQUAL 2.7.0)
# suppress error in L2
# * https://github.com/pybind/pybind11/pull/2919
target_compile_definitions(libint2-python PRIVATE NDEBUG=1)
endif()
target_compile_options(libint2-python
PRIVATE
# too many warnings on Windows
# $<$<CXX_COMPILER_ID:MSVC>:/W4>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall>
)
#find_package(Eigen3 3.3 REQUIRED)
set_target_properties(
libint2-python
PROPERTIES
#PREFIX ""
OUTPUT_NAME libint2
)
if (TARGET libint2_obj)
set(libint2_python_target libint2_obj)
if(MSVC)
target_compile_definitions(libint2-python PUBLIC _USE_MATH_DEFINES)
target_compile_options(libint2-python PUBLIC "/EHsc")
endif()
target_link_libraries(libint2-python PRIVATE libint2_obj)
target_link_libraries(libint2-python PRIVATE Boost::boost)
else()
find_package(Libint2 REQUIRED)
target_link_libraries(libint2-python PRIVATE Libint2::cxx)
endif()
# if (Eigen3::Eigen)
# target_link_libraries(libint2-python INTERFACE Eigen3::Eigen)
# else()
# include_directories(${EIGEN3_INCLUDE_DIR})
# endif()
configure_file(setup.py.in ${PROJECT_BINARY_DIR}/setup.py)
add_custom_target(
libint2-python-test
DEPENDS libint2-python
COMMAND ${Python_EXECUTABLE} -m setup test
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)
add_custom_target(
libint2-python-wheel
DEPENDS libint2-python
COMMAND ${Python_EXECUTABLE} -m setup bdist_wheel
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)
enable_testing()
# add the executable
add_test(
NAME libint2-python
COMMAND ${Python_EXECUTABLE} -m setup test
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)