-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
206 lines (193 loc) · 8.14 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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# required cmake version
cmake_minimum_required(VERSION 3.10)
project(EikonalXX VERSION 0.2.0 LANGUAGES CXX)
enable_testing()
option(WRAP_PYTHON "Compile the Python bindings" OFF)
include(CheckCXXCompilerFlag)
include(FindOpenMP QUIET)
if (OPENMP_FOUND)
message("OpenMP found")
string(APPEND CMAKE_CXX_FLAGS " ${OpenMP_CXX_FLAGS}")
endif()
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(GTest REQUIRED)
find_package(Boost COMPONENTS graph math)
find_package(spdlog REQUIRED)
find_package(Threads REQUIRED)
set(FindTBB_DIR ${CMAKE_SOURCE_DIR}/cmake)
find_package(FindTBB REQUIRED)
configure_file(${CMAKE_SOURCE_DIR}/include/private/version.hpp.in
${CMAKE_SOURCE_DIR}/include/eikonalxx/version.hpp)
set(PUBLIC_HEADER_DIRECTORIES
${CMAKE_SOURCE_DIR}/include/eikonalxx)
set(PRIVATE_HEADER_DIRECTORIES
${CMAKE_SOURCE_DIR}/include/private)
set(LIBSRC
src/version.cpp
src/solverOptions.cpp
src/geometry2d.cpp src/geometry3d.cpp
src/graph3d.cpp
src/model2d.cpp src/model3d.cpp
src/source2d.cpp
src/source3d.cpp
src/solver2d.cpp
src/solver3d.cpp
src/station2d.cpp src/station3d.cpp
src/analytic/homogeneous2d.cpp src/analytic/homogeneous3d.cpp
src/analytic/linearGradient2d.cpp src/analytic/linearGradient3d.cpp
src/ray/gradientTracer2d.cpp
src/ray/gradientTracerOptions.cpp
src/ray/layerSolver.cpp
src/ray/path2d.cpp src/ray/path3d.cpp
src/ray/point2d.cpp src/ray/point3d.cpp
src/ray/segment2d.cpp src/ray/segment3d.cpp
src/io/vtkRectilinearGrid2d.cpp src/io/vtkRectilinearGrid3d.cpp
src/io/vtkLines2d.cpp)
set(BUILD_SHARED_LIBS YES)
add_library(eikonalxx ${LIBSRC})
set_target_properties(eikonalxx PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
if (${Boost_FOUND})
target_compile_definitions(eikonalxx PRIVATE USE_BOOST)
#target_include_directories(eikonalxx PRIVATE ${Boost_INCLUDE_DIRS})
endif()
target_include_directories(eikonalxx
PRIVATE $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
PRIVATE sycl
PRIVATE spdlog::spdlog Threads::Threads Boost::Math
PRIVATE ${TBB_INCLUDE_DIR} ${Boost_INCLUDE_DIRS})
# PUBLIC $<INSTALL_INTERFACE:${CMAKE_SOURCE_DIR}/include/eikonalxx>)
target_link_libraries(eikonalxx PRIVATE sycl ${TBB_LIBRARY} Threads::Threads)# stdc++fs)
if (${WRAP_PYTHON})
find_package(Python COMPONENTS Interpreter Development)
find_package(pybind11 REQUIRED)
add_library(pyEikonalXX MODULE
python/pyEikonalXX.cpp
python/pySolverOptions.cpp
python/pyGeometry2d.cpp python/pyGeometry3d.cpp
python/pyModel2d.cpp
python/pyRay2d.cpp
python/pySolver2d.cpp
python/pySource2d.cpp
python/pySource3d.cpp
python/pyStation2d.cpp
python/pyStation3d.cpp)
target_link_libraries(pyEikonalXX PRIVATE
pybind11::module eikonalxx)
set_target_properties(pyEikonalXX PROPERTIES
PREFIX ""
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
target_include_directories(pyEikonalXX
PRIVATE pybind11
PRIVATE $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>)
endif()
##########################################################################################
# Testing #
##########################################################################################
add_executable(unitTests
testing/main.cpp
testing/geometry.cpp
testing/source.cpp
testing/station.cpp
testing/model.cpp
testing/solverOptions.cpp
testing/graph.cpp
testing/analytic.cpp
testing/solver2d.cpp
testing/solver3d.cpp
testing/gradient.cpp
testing/ray.cpp
testing/layerSolver.cpp
)
target_link_libraries(unitTests PRIVATE eikonalxx ${GTEST_BOTH_LIBRARIES} ${TBB_LIBRARY}
OpenCL Threads::Threads)
target_include_directories(unitTests PRIVATE ${GTEST_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/src)
set_target_properties(unitTests PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
add_test(NAME unitTest
COMMAND unitTests)
add_executable(converge2d
testing/converge2d.cpp)
target_link_libraries(converge2d PRIVATE eikonalxx)
target_include_directories(converge2d PRIVATE ${CMAKE_SOURCE_DIR}/include)
set_target_properties(converge2d PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
##########################################################################################
# Installation #
##########################################################################################
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
configure_package_config_file(
cmake/EikonalXXConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION "${version}"
COMPATIBILITY AnyNewerVersion
)
if (WRAP_PYTHON)
install(TARGETS eikonalxx pyEikonalXX
EXPORT ${PROJECT_NAME}-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT Runtime)
else()
install(TARGETS eikonalxx
EXPORT ${PROJECT_NAME}-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT Runtime)
endif()
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/eikonalxx
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
export(EXPORT ${PROJECT_NAME}-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
install(EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}Targets.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
##########################################################################################
# CPACK Packaging #
##########################################################################################
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_VENDOR "University of Utah Seismograph Stations")
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_PACKAGE_LICENSE "MIT")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A library for solving the eikonal equation.")
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
set(CPACK_VERBATIM_VARIABLES YES)
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_COMPONENTS_ALL libraries headers)
if (WIN32)
set(CPACK_GENERATOR ZIP WIX)
elseif (APPLE)
set(CPACK_GENERATOR TGZ productbuild)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CPACK_GENERATOR TGZ RPM)
else()
set(CPACK_GENERATOR TGZ)
endif()
set(CPACK_SOURCE_IGNORE_FILES
/\\.git/
\\.swp
\\.orig
/CMakeLists\\.txt\\.user
/private/
)
include(CPack) # Put this last!