-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathCMakeLists.txt
222 lines (184 loc) · 5.74 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
cmake_minimum_required(VERSION 3.26)
project(Sara LANGUAGES C CXX)
# We are post-2020 now: let's all look to the future please. Activate C++20
# globally
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Set the version major and minor manually.
set(DO_Sara_VERSION_MAJOR 1)
set(DO_Sara_VERSION_MINOR 11)
if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
endif()
# Check that vcpkg toolchain is specified when running CMake!
if(WIN32 AND NOT CMAKE_TOOLCHAIN_FILE)
message(FATAL_ERROR "[Sara] Could not find vpkg toolchain file: "
"please specify it to build Sara on Windows!")
endif()
# Set default build type to Release mode.
set(CMAKE_BUILD_TYPE
"Release"
CACHE STRING "Build type options are: Debug, Release")
# Set options.
option(SARA_USE_VLD "Enable Visual Leak Detector for unit tests" OFF)
option(SARA_USE_QT6 "Switch to Qt6" OFF)
option(SARA_USE_HALIDE "Enable Halide" OFF)
option(SARA_BUILD_VIDEOIO "Build Sara's Video I/O module" OFF)
option(SARA_BUILD_PYTHON_BINDINGS "Build Python bindings" OFF)
option(SARA_BUILD_TESTS "Build unit tests for DO-Sara libraries" OFF)
option(SARA_BUILD_SAMPLES "Build sample programs using DO-Sara libraries" OFF)
option(SARA_BUILD_SHARED_LIBS "Build shared libraries for DO-Sara libraries"
OFF)
option(SARA_BUILD_DRAFTS "Build draft code" OFF)
option(SARA_SELF_CONTAINED_INSTALLATION
"Install C++ and Python libraries in a single self contained directory"
OFF)
# Set the following internal switches to build Sara.
set(SARA_USE_FROM_SOURCE
TRUE
CACHE INTERNAL "Build Sara libraries")
set(BUILD_SHARED_LIBS ${SARA_BUILD_SHARED_LIBS})
# Add Sara to the CMake module path.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(sara_create_asan_build_type)
# Import macros and configure Sara library version.
include(sara_macros)
sara_dissect_version()
# Use CCache if available to speed up builds.
include(sara_use_ccache)
if(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
set(EIGEN3_INCLUDE_DIRECTORY "/usr/include/eigen3")
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
endif()
# Use CUDA if available.
if(NOT CMAKE_SYSTEM_NAME STREQUAL Emscripten)
include(CheckLanguage)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
enable_language(CUDA)
find_package(CUDAToolkit REQUIRED)
find_package(TensorRT)
find_package(OnnxRuntime)
else()
message(STATUS "No CUDA support!")
endif()
endif()
if(CMAKE_SYSTEM_NAME STREQUAL iOS)
# Find Boost package.
set(Boost_INCLUDE_DIR
/Users/david/GitHub/Apple-Boost-BuildScript/dist/boost.xcframework/Headers
)
set(Boost_LIBRARIES
/Users/david/GitHub/Apple-Boost-BuildScript/dist/boost.xcframework/ios-arm64/libboost.a
)
elseif(NOT CMAKE_SYSTEM_NAME STREQUAL Emscripten)
find_package(Eigen3 3.4 REQUIRED NO_MODULE)
find_package(TBB)
# set(Boost_DEBUG ON)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
find_package(
Boost
COMPONENTS filesystem log program_options serialization system
unit_test_framework
REQUIRED)
find_package(OpenMP)
find_package(
HDF5
COMPONENTS CXX
REQUIRED)
if(WIN32 AND SARA_USE_VLD)
find_package(VisualLeakDetector)
include_directories(${VLD_INCLUDE_DIR})
link_directories(${VLD_LINK_DIRECTORIES})
endif()
# Image I/O libraries.
find_package(JPEG REQUIRED)
find_package(PNG REQUIRED)
find_package(TIFF REQUIRED)
find_package(ZLIB REQUIRED)
find_package(HEIF REQUIRED)
if(WIN32)
find_package(WebP CONFIG REQUIRED)
else()
find_package(WebP REQUIRED)
endif()
# Qt 5 or 6.
if(SARA_USE_QT6)
set(QT_VERSION 6)
find_package(
Qt${QT_VERSION}
COMPONENTS Core Widgets OpenGL OpenGLWidgets
REQUIRED)
else(SARA_USE_QT6)
set(QT_VERSION 5)
find_package(
Qt${QT_VERSION}
COMPONENTS Core Widgets OpenGL OpenGLExtensions
REQUIRED)
endif()
# OpenGL/GLFW/ImGui
find_package(OpenGL REQUIRED)
if(NOT APPLE)
find_package(GLEW REQUIRED)
endif()
find_package(glfw3 REQUIRED)
find_package(Freetype)
# High-performance compute.
find_package(OpenCL)
find_package(Vulkan)
find_program(
GLSLC_EXECUTABLE
NAMES glslc
HINTS ENV VULKAN_SDK
PATH_SUFFIXES bin)
find_package(Ceres REQUIRED)
if(SARA_USE_HALIDE)
include(sara_use_halide)
endif()
endif()
# We are ready to build Sara.
find_package(DO_Sara REQUIRED)
# Group projects by category.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Set installation settings.
include(sara_installation_settings)
# Enable testing before building the library.
if(SARA_BUILD_TESTS)
include(sara_configure_code_coverage)
include(CTest)
enable_testing()
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
find_package(XCTest REQUIRED)
endif()
# Visual leak detector.
if(WIN32 AND SARA_USE_VLD)
find_package(VisualLeakDetector)
include_directories(${VLD_INCLUDE_DIR})
link_directories(${VLD_LINK_DIRECTORIES})
endif()
endif()
# Build the libraries.
add_subdirectory(cpp)
if(NOT CMAKE_SYSTEM_NAME STREQUAL Emscripten)
if(CMAKE_Swift_COMPILER)
add_subdirectory(swift)
endif()
if(SARA_BUILD_PYTHON_BINDINGS)
add_subdirectory(python)
endif()
# To create Windows installer and Linux packages.
include(CPack)
endif()
# Make documentation
add_subdirectory(doc)
# TODO: find out how to make this work.
# if(SARA_USE_HALIDE)
# set_property(TARGET acc_gen PROPERTY FOLDER "Libraries/Shakti/Halide")
# set_property(TARGET intrinsics_gen PROPERTY FOLDER "Libraries/Shakti/Halide")
# set_property(TARGET omp_gen PROPERTY FOLDER "Libraries/Shakti/Halide")
# set_property(TARGET RISCVTargetParserTableGen PROPERTY FOLDER "Libraries/Shakti/Halide")
# endif()