-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
190 lines (161 loc) · 4.52 KB
/
Copy pathCMakeLists.txt
File metadata and controls
190 lines (161 loc) · 4.52 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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
cmake_minimum_required(VERSION 3.15)
file(STRINGS "version.txt" project_version)
project(slope LANGUAGES CXX VERSION ${project_version})
option(BUILD_DOCS "Build documentation" OFF)
option(ENABLE_COVERAGE "Generate coverage report" OFF)
option(DAP_DEBUG "Interactive debugging" OFF)
option(BUILD_JULIA_BINDINGS "Build Julia bindings" OFF)
option(USE_OPENMP "Enable OpenMP support" ON)
include(CTest)
include(FetchContent)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(OpenMP_RUNTIME_MSVC "llvm")
if(USE_OPENMP)
find_package(OpenMP QUIET)
endif()
find_package(Eigen3 REQUIRED NO_MODULE)
if(Eigen3_VERSION VERSION_LESS 3.4)
message(FATAL_ERROR "Eigen 3.4 or newer required")
endif()
add_subdirectory(src)
add_library(slope::slope ALIAS slope)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
install(
TARGETS slope
EXPORT slopeTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.hpp"
)
install(
EXPORT slopeTargets
FILE slopeTargets.cmake
NAMESPACE slope::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/slope
)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/slopeConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/slopeConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/slope
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/slopeConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/slopeConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/slopeConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/slope
)
if(BUILD_TESTING)
find_package(Catch2 3 REQUIRED)
add_executable(
tests
tests/alpha_est.cpp
tests/assertions.cpp
tests/benchmarks.cpp
tests/clusters.cpp
tests/cv.cpp
tests/generate_data.cpp
tests/hybrid.cpp
tests/input_validation.cpp
tests/interrupt.cpp
tests/lambda_sequence.cpp
tests/load_data.cpp
tests/logger.cpp
tests/logistic.cpp
tests/map.cpp
tests/math.cpp
tests/multinomial.cpp
tests/normalization.cpp
tests/path.cpp
tests/poisson.cpp
tests/predictions.cpp
tests/prox.cpp
tests/qnorm.cpp
tests/quadratic.cpp
tests/real_data.cpp
tests/relax.cpp
tests/score.cpp
tests/screening.cpp
tests/sparse.cpp
tests/thresholding.cpp
tests/utils.cpp
tests/views.cpp
tests/zero_variance.cpp
)
target_link_libraries(
tests
PRIVATE slope Catch2::Catch2WithMain Eigen3::Eigen
)
target_include_directories(tests PUBLIC tests/ "${PROJECT_BINARY_DIR}")
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
include(Catch)
catch_discover_tests(tests)
if(ENABLE_COVERAGE)
find_package(codecov)
add_coverage(tests)
add_coverage(slope)
set(LCOV_REMOVE_PATTERNS "*/tests/*")
coverage_evaluate(tests-gcov)
endif()
endif()
if(BUILD_JULIA_BINDINGS)
add_subdirectory(bindings/julia)
endif()
if(BUILD_DOCS)
find_package(Doxygen REQUIRED)
string(
CONCAT AWESOME_CSS_URL
"https://github.com/jothepro/"
"doxygen-awesome-css/archive/refs/heads/main.zip"
)
FetchContent_Declare(
doxygen-awesome-css
URL ${AWESOME_CSS_URL}
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
FetchContent_MakeAvailable(doxygen-awesome-css)
FetchContent_GetProperties(doxygen-awesome-css SOURCE_DIR AWESOME_CSS_DIR)
# Generate the Doxyfile
set(DOXYGEN_IMAGE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/assets")
set(
DOXYGEN_HTML_EXTRA_STYLESHEET
"${AWESOME_CSS_DIR}/doxygen-awesome.css"
"${AWESOME_CSS_DIR}/doxygen-awesome-sidebar-only.css"
)
set(DOXYGEN_DISABLE_INDEX NO)
set(DOXYGEN_EXCLUDE_SYMBOLS slope::detail)
set(DOXYGEN_FULL_SIDEBAR NO)
set(DOXYGEN_GENERATE_TREEVIEW YES)
set(DOXYGEN_HTML_COLORSTYLE LIGHT)
set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs)
set(DOXYGEN_PROJECT_LOGO "${CMAKE_CURRENT_SOURCE_DIR}/assets/slope-logo.png")
set(DOXYGEN_USE_MATHJAX YES)
set(DOXYGEN_SOURCE_BROWSER YES)
doxygen_add_docs(
docs
docs/dependencies.md
docs/getting_started.md
docs/mainpage.md
include/
ALL
COMMENT "Generate package documentation"
)
endif()
install(
FILES LICENSE
DESTINATION ${CMAKE_INSTALL_DATADIR}/licenses/${PROJECT_NAME}
)