-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
160 lines (137 loc) · 3.37 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
cmake_minimum_required(VERSION 3.13...3.29)
message(STATUS "CMake version ${CMAKE_VERSION}")
# version number here is embedded in compiled executable
project(
SpatialModelEditor
VERSION 1.6.0
DESCRIPTION "Spatial Model Editor"
LANGUAGES C CXX)
# workaround for mingw gcc-14 c++20 issue:
# https://gitlab.kitware.com/cmake/cmake/-/issues/25974
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
# workaround for CGAL using deprecated exec_program
if(POLICY CMP0153)
cmake_policy(
SET
CMP0153
OLD)
endif()
list(
APPEND
CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/cmake")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true)
# "make test" excludes gui tests & uses all cores
include(ProcessorCount)
ProcessorCount(NPROC)
set(CMAKE_CTEST_ARGUMENTS "-j${NPROC};--progress;--output-on-failure;-E;gui")
# find required Qt modules
find_package(
Qt6
CONFIG
REQUIRED
COMPONENTS Core
Gui
Widgets
OpenGLWidgets
OpenGL)
get_target_property(
QtCore_location
Qt6::Core
LOCATION)
message(STATUS "Found QtCore: ${QtCore_location}")
# enable Qt utils: moc, uic, rcc
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
option(
SME_USE_STATIC_LIBS
"Use static versions of dependencies"
ON)
if(SME_USE_STATIC_LIBS)
set(CGAL_Boost_USE_STATIC_LIBS ON)
set(OpenCV_STATIC ON)
endif()
set(SME_LOG_LEVEL
"INFO"
CACHE STRING
"Logging level: OFF, CRITICAL, ERROR, WARN, INFO, DEBUG, TRACE")
set(SME_EXTRA_EXE_LIBS
""
CACHE STRING "Optional additional exe libs")
set(SME_EXTRA_GUI_LIBS
""
CACHE STRING "Optional additional gui libs")
set(SME_EXTRA_CORE_DEFS
""
CACHE STRING "Optional additional defines for core")
option(
SME_BUILD_CORE
"Build core sme library"
ON)
option(
SME_BUILD_BENCHMARKS
"Build benchmarks"
ON)
option(
SME_BUILD_GUI
"Build GUI version"
ON)
option(
SME_BUILD_CLI
"Build command-line version"
ON)
option(
SME_BUILD_PYTHON_LIBRARY
"Build python library"
ON)
if(NOT SME_BUILD_CORE)
find_package(
sme
REQUIRED
CONFIG)
get_target_property(
SME_CORE_LOCATION
sme::core
IMPORTED_LOCATION_RELEASE)
message(STATUS "Found sme::core: ${SME_CORE_LOCATION}")
endif()
if(SME_BUILD_BENCHMARKS)
add_subdirectory(benchmark)
endif()
include(CTest)
if(BUILD_TESTING)
find_package(Catch2 REQUIRED)
include(Catch)
add_subdirectory(test)
endif()
if(SME_BUILD_CORE)
add_subdirectory(core)
endif()
if(SME_BUILD_GUI)
add_subdirectory(gui)
add_subdirectory(app)
endif()
if(SME_BUILD_CLI)
add_subdirectory(ext/CLI11)
add_subdirectory(cli)
endif()
# compile python library
if(SME_BUILD_PYTHON_LIBRARY)
add_subdirectory(ext/nanobind)
add_subdirectory(sme)
endif()
# display sme configuration options
message(STATUS "SME_BUILD_CORE: ${SME_BUILD_CORE}")
message(STATUS "SME_BUILD_GUI: ${SME_BUILD_GUI}")
message(STATUS "SME_BUILD_CLI: ${SME_BUILD_CLI}")
message(STATUS "SME_BUILD_PYTHON_LIBRARY: ${SME_BUILD_PYTHON_LIBRARY}")
message(STATUS "SME_BUILD_BENCHMARKS: ${SME_BUILD_BENCHMARKS}")
message(STATUS "SME_LOG_LEVEL: ${SME_LOG_LEVEL}")
message(STATUS "SME_EXTRA_CORE_DEFS: ${SME_EXTRA_CORE_DEFS}")
message(STATUS "SME_EXTRA_GUI_LIBS: ${SME_EXTRA_GUI_LIBS}")
message(STATUS "SME_EXTRA_EXE_LIBS: ${SME_EXTRA_EXE_LIBS}")
message(STATUS "SME_USE_STATIC_LIBS: ${SME_USE_STATIC_LIBS}")