-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
146 lines (124 loc) · 3.71 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
cmake_minimum_required(VERSION 3.20)
include(cmake/prelude.cmake)
project(
pyoperon
VERSION 0.4.0
DESCRIPTION "Scikit-learn module and python bindings and for the Operon library"
HOMEPAGE_URL "https://operongp.readthedocs.io/en/latest/"
LANGUAGES CXX
)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
docs_early_return()
include(cmake/project-is-top-level.cmake)
include(cmake/variables.cmake)
# ---- Find dependencies ----
find_package(AriaCsvParser REQUIRED)
find_package(Ceres CONFIG)
find_package(Eigen3 REQUIRED)
find_package(FastFloat REQUIRED)
find_package(Threads REQUIRED)
find_package(byte-lite REQUIRED)
find_package(span-lite REQUIRED)
find_package(lbfgs REQUIRED)
find_package(libassert REQUIRED)
find_package(mdspan REQUIRED)
find_package(operon REQUIRED)
find_package(outcome REQUIRED)
find_package(pratt-parser REQUIRED)
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
find_package(pybind11 CONFIG REQUIRED)
find_package(unordered_dense REQUIRED)
find_package(xxHash)
if(NOT xxHash_FOUND)
find_package(PkgConfig REQUIRED)
pkg_check_modules(xxhash IMPORTED_TARGET xxhash)
if (NOT xxhash_FOUND)
pkg_check_modules(xxhash IMPORTED_TARGET libxxhash)
endif()
endif()
# ---- Declare library ----
pybind11_add_module(
pyoperon_pyoperon
MODULE
source/algorithm.cpp
source/benchmark.cpp
source/creator.cpp
source/crossover.cpp
source/dataset.cpp
source/evaluator.cpp
source/generator.cpp
source/initializer.cpp
source/mutation.cpp
source/node.cpp
source/non_dominated_sorter.cpp
source/optimizer.cpp
source/problem.cpp
source/pset.cpp
source/pyoperon.cpp
source/reinserter.cpp
source/selection.cpp
source/tree.cpp
)
add_library(pyoperon::pyoperon ALIAS pyoperon_pyoperon)
# when operon is statically linked, dependency information will not be available
# via any external means (e.g., ldd), therefore cmake treats all PRIVATE deps as PUBLIC
# all of the below will be added to INTERFACE_LINK_LIBRARIES, therefore we try to find them
find_package(PkgConfig REQUIRED)
pkg_check_modules(openlibm IMPORTED_TARGET openlibm)
find_package(Taskflow)
find_package(cpp-sort)
find_package(fmt)
find_package(libassert)
find_package(vstat)
find_package(eve)
find_package(openlibm)
include(GenerateExportHeader)
generate_export_header(
pyoperon_pyoperon
BASE_NAME pyoperon
EXPORT_FILE_NAME export/pyoperon/pyoperon_export.hpp
CUSTOM_CONTENT_FROM_VARIABLE pragma_suppress_c4251
)
set_target_properties(
pyoperon_pyoperon PROPERTIES
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN YES
VERSION "${PROJECT_VERSION}"
SOVERSION "${PROJECT_VERSION_MAJOR}"
EXPORT_NAME pyoperon
OUTPUT_NAME pyoperon
)
target_include_directories(
pyoperon_pyoperon ${pyoperon_warning_guard}
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
)
target_include_directories(
pyoperon_pyoperon SYSTEM
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/export>"
)
target_compile_features(pyoperon_pyoperon PUBLIC cxx_std_20)
# this will link in operon's public dependencies: fmt, ceres, etc.
target_link_libraries(pyoperon_pyoperon PRIVATE operon::operon)
if (MSVC)
target_compile_options(pyoperon_pyoperon PRIVATE "/std:c++latest")
endif()
if (APPLE)
set_target_properties(pyoperon_pyoperon PROPERTIES VERSION "")
endif()
# ---- Install rules ----
if(NOT CMAKE_SKIP_INSTALL_RULES)
include(cmake/install-rules.cmake)
endif()
# ---- Developer mode ----
if(NOT pyoperon_DEVELOPER_MODE)
return()
elseif(NOT PROJECT_IS_TOP_LEVEL)
message(
AUTHOR_WARNING
"Developer mode is intended for developers of pyoperon"
)
endif()
include(cmake/dev-mode.cmake)