forked from ariadne-cps/ariadne
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
226 lines (192 loc) · 7.78 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
cmake_minimum_required(VERSION 3.9)
message(STATUS "CMake version ${CMAKE_VERSION}")
project(Ariadne VERSION 1.9)
if(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
message(WARNING "Intel compiler not supported.")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
message(WARNING "Microsoft compiler not supported.")
endif()
set(COMPILER_WARN all extra pedantic sign-conversion shadow cast-qual disabled-optimization
init-self missing-include-dirs sign-promo switch-default undef redundant-decls)
set(COMPILER_DONT_WARN strict-aliasing unused-parameter)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
set(CMAKE_MACOSX_RPATH 1)
set(BUILD_SHARED_LIBS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_STANDARD 17)
set(PYBIND_SUBMODULE_COMMIT 435dbdd)
foreach(WARN ${COMPILER_WARN})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W${WARN}")
endforeach()
foreach(WARN ${COMPILER_DONT_WARN})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-${WARN}")
endforeach()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-non-template-friend")
endif()
if(WERROR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
endif()
option(COVERAGE "Enable coverage reporting" OFF)
add_library(coverage_config INTERFACE)
if(COVERAGE)
message(STATUS "Enabled coverage reporting")
target_compile_options(coverage_config INTERFACE -O0 -g --coverage)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
target_link_options(coverage_config INTERFACE --coverage)
else()
target_link_libraries(coverage_config INTERFACE --coverage)
endif()
endif()
enable_testing()
include(CTest)
include(cotire)
include(UseDoxygen OPTIONAL)
include(CheckTypeSize)
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckIncludeFileCXX)
include(CheckLibraryExists)
check_type_size("char" SIZEOF_CHAR)
check_type_size("short int" SIZEOF_SHORT_INT)
check_type_size("int" SIZEOF_INT)
check_type_size("long int" SIZEOF_LONG_INT)
check_type_size("long long int" SIZEOF_LONG_LONG_INT)
check_type_size("float" SIZEOF_FLOAT)
check_type_size("double" SIZEOF_DOUBLE)
check_type_size("long double" SIZEOF_LONG_DOUBLE)
check_include_file("dlfcn.h" HAVE_DLFCN_H)
check_include_file("execinfo.h" HAVE_EXECINFO_H)
check_include_file_cxx("cxxabi.h" HAVE_CXXABI_H)
if((${HAVE_DLFCN_H}) AND (${HAVE_EXECINFO_H}) AND (${HAVE_CXXABI_H}))
set(ARIADNE_ENABLE_STACK_TRACE ON)
endif()
find_package(GMP)
if(GMP_FOUND)
include_directories(SYSTEM ${GMP_INCLUDES})
else()
message(FATAL_ERROR "Unable to find GMP.")
endif()
find_package(GMPXX)
if(GMPXX_FOUND)
set(HAVE_GMPXX_H ON)
include_directories(SYSTEM ${GMPXX_INCLUDE_DIR})
else()
message(WARNING "Unable to find GMPXX. Related functionality will be disabled.")
endif()
find_package(MPFR)
if(MPFR_FOUND)
include_directories(SYSTEM ${MPFR_INCLUDES})
else()
message(FATAL_ERROR "Unable to find MPFR.")
endif()
find_package(Cairo)
if(CAIRO_FOUND)
set(HAVE_CAIRO_H ON)
include_directories(SYSTEM ${CAIRO_INCLUDE_DIRS})
else()
message(WARNING "Unable to find Cairo. You will not be able to use graphics.")
endif()
include("./cmake/FindCUDA.cmake")
configure_file(${PROJECT_SOURCE_DIR}/cmake/config.hpp.cmake ${PROJECT_SOURCE_DIR}/source/config.hpp)
include_directories(${PROJECT_SOURCE_DIR}/source)
find_package(Kirk)
#[[ This section has been commented out because otherwise this flag gets used for NVCC as well as the CXX compiler, which leads to a fatal error
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_definitions(-Wno-non-template-friend)
endif()
]]
# Inside the "source" CMAKE, a sub_directory(cuda) has been added
add_subdirectory(source)
#add_subdirectory(tests)
#add_subdirectory(examples)
#add_subdirectory(tutorials)
#add_subdirectory(experimental EXCLUDE_FROM_ALL)
find_package(PythonLibs)
if(PYTHONLIBS_FOUND)
message(STATUS "PythonLibs found: Python bindings will be built.")
if(NOT EXISTS ${PROJECT_SOURCE_DIR}/external/pybind11/CMakeLists.txt)
message(STATUS "pybind11 dependency not available.")
find_package(Git)
if(GIT_FOUND)
message(STATUS "Downloading pybind11 repository...")
if (NOT EXISTS ${PROJECT_SOURCE_DIR}/.git)
execute_process(COMMAND git init WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_QUIET ERROR_QUIET)
execute_process(COMMAND rm -Rf ${PROJECT_SOURCE_DIR}/external/pybind11 OUTPUT_QUIET ERROR_QUIET)
execute_process(COMMAND git submodule add -f https://github.com/pybind/pybind11 external/pybind11 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_QUIET ERROR_QUIET)
execute_process(COMMAND git checkout ${PYBIND_SUBMODULE_COMMIT} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/external/pybind11 OUTPUT_QUIET ERROR_QUIET)
execute_process(COMMAND git submodule update --init --recursive WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/external/pybind11 OUTPUT_QUIET ERROR_QUIET)
else()
execute_process(COMMAND git submodule update --init --recursive WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_QUIET ERROR_QUIET)
endif()
if(NOT EXISTS ${PROJECT_SOURCE_DIR}/external/pybind11/CMakeLists.txt)
message(ERROR "pybind11 download failure.")
else()
message(STATUS "Downloaded pybind11 dependency successfully.")
endif()
else()
message(ERROR "Git not found, pybind11 dependency could not be downloaded.")
endif()
endif()
add_subdirectory(external/pybind11)
add_subdirectory(python)
endif()
add_library(ariadne-core SHARED
$<TARGET_OBJECTS:ariadne-utility>
$<TARGET_OBJECTS:ariadne-numeric>
$<TARGET_OBJECTS:ariadne-algebra>
source/geometry/interval.cpp
)
add_library(ariadne-kernel SHARED
$<TARGET_OBJECTS:ariadne-utility>
$<TARGET_OBJECTS:ariadne-numeric>
$<TARGET_OBJECTS:ariadne-algebra>
$<TARGET_OBJECTS:ariadne-function>
$<TARGET_OBJECTS:ariadne-geometry>
$<TARGET_OBJECTS:ariadne-solvers>
$<TARGET_OBJECTS:ariadne-output>
$<TARGET_OBJECTS:ariadne-symbolic>
)
add_library(ariadne SHARED
$<TARGET_OBJECTS:ariadne-utility>
$<TARGET_OBJECTS:ariadne-numeric>
$<TARGET_OBJECTS:ariadne-algebra>
$<TARGET_OBJECTS:ariadne-function>
$<TARGET_OBJECTS:ariadne-geometry>
$<TARGET_OBJECTS:ariadne-solvers>
$<TARGET_OBJECTS:ariadne-output>
$<TARGET_OBJECTS:ariadne-symbolic>
$<TARGET_OBJECTS:ariadne-dynamics>
$<TARGET_OBJECTS:ariadne-hybrid>
)
target_link_libraries(ariadne dl)
target_link_libraries(ariadne-kernel dl)
target_link_libraries(ariadne-core dl)
target_link_libraries(ariadne ${GMP_LIBRARIES} ${MPFR_LIBRARIES})
target_link_libraries(ariadne-kernel ${GMP_LIBRARIES} ${MPFR_LIBRARIES})
target_link_libraries(ariadne-core ${GMP_LIBRARIES} ${MPFR_LIBRARIES})
if(COVERAGE)
target_link_libraries(ariadne coverage_config)
target_link_libraries(ariadne-kernel coverage_config)
target_link_libraries(ariadne-core coverage_config)
endif()
if(GMPXX_FOUND)
target_link_libraries(ariadne ${GMPXX_LIBRARIES})
target_link_libraries(ariadne-kernel ${GMP_LIBRARIES} ${MPFR_LIBRARIES})
target_link_libraries(ariadne-core ${GMP_LIBRARIES} ${MPFR_LIBRARIES})
endif()
if(CAIRO_FOUND)
target_link_libraries(ariadne ${CAIRO_LIBRARIES})
target_link_libraries(ariadne-kernel ${CAIRO_LIBRARIES})
endif()
# Ariadne gets linked to the Cuda code inside the "source/cuda" folder
if (CMAKE_CUDA_COMPILER)
target_link_libraries(ariadne ariadne-cuda)
target_link_libraries(ariadne-kernel ariadne-cuda)
target_link_libraries(ariadne-core ariadne-cuda)
endif()
install(TARGETS ariadne DESTINATION lib)
install(DIRECTORY source/ DESTINATION include/ariadne FILES_MATCHING PATTERN "*.hpp")