-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
189 lines (147 loc) · 6.28 KB
/
Copy pathCMakeLists.txt
File metadata and controls
189 lines (147 loc) · 6.28 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
cmake_minimum_required(VERSION 3.22)
# -----------------------------------------------------------------------------
# Optional: force clang Usage: cmake -B build -DCMAKE_C_COMPILER=clang
# -DCMAKE_CXX_COMPILER=clang++
# -----------------------------------------------------------------------------
project(highmap-root LANGUAGES C CXX)
# -----------------------------------------------------------------------------
# Options
# -----------------------------------------------------------------------------
option(HIGHMAP_ENABLE_OPENCL "" ON)
option(HIGHMAP_ENABLE_LOGS "Enable logging" ON)
option(HIGHMAP_ENABLE_EXAMPLES "" ON)
option(HIGHMAP_ENABLE_TESTS "" ON)
option(HIGHMAP_ENABLE_BENCHMARKS "" ON)
option(HIGHMAP_ENABLE_PROFILE_BUILD
"Enable build time profiling (-ftime-trace)" OFF)
option(HIGHMAP_ENABLE_PCH "Enable Precompiled Headers (PCH)" OFF)
# -----------------------------------------------------------------------------
# C++
# -----------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# -----------------------------------------------------------------------------
# Compiler flags
# -----------------------------------------------------------------------------
add_definitions(-D_USE_MATH_DEFINES)
if(MSVC)
message(STATUS "Compiler: MSVC")
add_definitions(-DHMAP_MSVC)
# do NOT pass /Od here: add_compile_options lands after the per-config flags
# on the MSVC command line, where it overrides Release's /O2 (last flag wins),
# silently disabling optimization in every Release build
add_compile_options(/W4 "$<$<NOT:$<CONFIG:Debug>>:/fp:fast>")
add_compile_definitions(M_PI=3.14159265358979323846)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
message(STATUS "Compiler: Clang")
add_compile_options(
-Wall
-Wextra
-Wpedantic
$<$<CONFIG:Debug>:-Og>
$<$<NOT:$<CONFIG:Debug>>:-Ofast>
$<$<NOT:$<CONFIG:Debug>>:-ffast-math>
-pthread
-fPIC
-Wno-deprecated-enum-enum-conversion
-Wno-header-guard
-Wno-gnu-zero-variadic-macro-arguments)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
message(STATUS "Compiler: GCC")
add_compile_options(
-Wall
-Wextra
$<$<CONFIG:Debug>:-Og>
$<$<NOT:$<CONFIG:Debug>>:-Ofast>
$<$<NOT:$<CONFIG:Debug>>:-ffast-math>
-pthread
-fPIC
-Wno-free-nonheap-object
-Wno-deprecated-enum-enum-conversion)
endif()
# -----------------------------------------------------------------------------
# Profiling
# -----------------------------------------------------------------------------
if(HIGHMAP_ENABLE_PROFILE_BUILD)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-ftime-trace" HIGHMAP_HAS_FTIME_TRACE)
if(HIGHMAP_HAS_FTIME_TRACE)
message(STATUS "HIGHMAP_ENABLE_PROFILE_BUILD: -ftime-trace enabled")
add_compile_options(-ftime-trace)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
message(STATUS "HIGHMAP_ENABLE_PROFILE_BUILD: -ftime-report enabled")
add_compile_options(-ftime-report)
endif()
endif()
# -----------------------------------------------------------------------------
# Output
# -----------------------------------------------------------------------------
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
# -----------------------------------------------------------------------------
# Dependencies
# -----------------------------------------------------------------------------
find_package(GSL REQUIRED COMPONENTS gsl gslcblas)
find_package(assimp REQUIRED)
find_package(glm REQUIRED)
find_package(OpenMP REQUIRED)
find_package(OpenCV REQUIRED)
find_package(OpenCL REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
# OpenMP
add_compile_options(${OpenMP_CXX_FLAGS})
# OpenCL
add_compile_definitions(CL_HPP_MINIMUM_OPENCL_VERSION=120
CL_HPP_TARGET_OPENCL_VERSION=120)
# Logging
if(HIGHMAP_ENABLE_LOGS)
add_compile_definitions(HIGHMAP_ENABLE_LOGS=1)
else()
add_compile_definitions(HIGHMAP_ENABLE_LOGS=0)
endif()
# -----------------------------------------------------------------------------
# Status output
# -----------------------------------------------------------------------------
message(STATUS "┌─ HighMap configuration ─────────────")
message(STATUS "│ HIGHMAP_ENABLE_OPENCL: ${HIGHMAP_ENABLE_OPENCL}")
message(STATUS "│ HIGHMAP_ENABLE_LOGS: ${HIGHMAP_ENABLE_LOGS}")
message(
STATUS "│ HIGHMAP_ENABLE_EXAMPLES: ${HIGHMAP_ENABLE_EXAMPLES}")
message(STATUS "│ HIGHMAP_ENABLE_TESTS: ${HIGHMAP_ENABLE_TESTS}")
message(
STATUS "│ HIGHMAP_ENABLE_BENCHMARKS: ${HIGHMAP_ENABLE_BENCHMARKS}")
message(
STATUS "│ HIGHMAP_ENABLE_PROFILE_BUILD: ${HIGHMAP_ENABLE_PROFILE_BUILD}"
)
message(STATUS "│ CMAKE_CXX_STANDARD: ${CMAKE_CXX_STANDARD}")
message(STATUS "│ CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "│ CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "└─────────────────────────────────────")
# -----------------------------------------------------------------------------
# External libs
# -----------------------------------------------------------------------------
add_subdirectory(external)
# -----------------------------------------------------------------------------
# Library
# -----------------------------------------------------------------------------
add_subdirectory(HighMap)
# -----------------------------------------------------------------------------
# Examples
# -----------------------------------------------------------------------------
if(HIGHMAP_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()
# -----------------------------------------------------------------------------
# Tests
# -----------------------------------------------------------------------------
if(HIGHMAP_ENABLE_TESTS)
message(STATUS "HighMap tests enabled")
add_subdirectory(tests)
endif()
# -----------------------------------------------------------------------------
# Benchmarks
# -----------------------------------------------------------------------------
if(HIGHMAP_ENABLE_BENCHMARKS)
message(STATUS "HighMap benchmarks enabled")
add_subdirectory(benchmarks)
endif()