-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
208 lines (146 loc) · 5.6 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
cmake_minimum_required(VERSION 3.11)
# Configure C++
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release")
set(COPYRIGHT_YEAR_START 2022)
list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Checks
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Common
${CMAKE_CURRENT_SOURCE_DIR}/cmake/External
${CMAKE_CURRENT_SOURCE_DIR}/cmake/.NetSupport
)
# Force all libraries to be build dynamic if ON, also they are set to STATIC
# If we set this flag to on and use gtest with FectContent we have to
# implement the main function for our unit tests by ourself
option(BUILD_SHARED_LIBS "Build project libraries as shared libraries" OFF)
option(BUILD_TESTING "Build with tests" OFF)
option(BUILD_PYTHON_BINDINGS "Build bindings for python" OFF)
option(BUILD_DOC "Build documentation" OFF)
option(BUILD_WITH_EIGEN "Build some libraries with eigen support" OFF)
option(BUILD_WITH_BOOST "Build some libraries with boost support" OFF)
option(BUILD_WITH_OPENCV "Build some libraries with OpenCV support" OFF)
option(BUILD_WITH_ZIP "Build some libraries with Zip support" OFF)
option(DEBUG_POSTFIX "Set to ON to force _d postfix for the lib names." OFF)
option(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" ON)
# 3rd party dependencies needs to be build first
option (USE_SUPERBUILD "Whether or not a superbuild should be invoked" ON)
if (USE_SUPERBUILD)
#project (SUPERBUILD NONE)
# execute the superbuild (this script will be invoked again without the
# USE_SUPERBUILD option this time)
include(SuperBuild)
return() # stop processing this file further
else(USE_SUPERBUILD)
project(CMakePlayground VERSION 1.0.0)
endif(USE_SUPERBUILD)
if(ENABLE_SOLUTION_FOLDERS)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
endif()
# Standard CMake modules
include(FindPackageHandleStandardArgs)
include(GenerateExportHeader)
# Modules
include(Common)
include(CompilerFlags)
if(DEBUG_POSTFIX)
# For debug libs and exes, add "-d" postfix
set(CMAKE_DEBUG_POSTFIX "-d" CACHE STRING "Set debug library postfix")
endif(DEBUG_POSTFIX)
if(BUILD_TESTING)
# Activate test support
# Enable integration with CTest
# The shared libs option needs to be turne off to be alble to use gtest main function
# instead of writing every time our own. Maybe for all test executables a own fucntion is required
include(CTest)
enable_testing()
include(GoogleTest)
endif(BUILD_TESTING)
if(BUILD_DOC)
#include(DoxygenSupport)
#add_subdirectory(doc)
endif(BUILD_DOC)
# Add clang-format for all C++ projects
# and editorconfig for all .NET projects
add_custom_target(ALL
SOURCES
.clang-format
.editorconfig
)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory" FORCE)
message(STATUS "")
message(STATUS " Install to: " "${CMAKE_INSTALL_PREFIX}")
message(STATUS "-----------------------------------------------------------------")
message(STATUS "")
# Let CMake load the CMakeLists.txt in the subdirectory to load the
# sub-projects. Prefer lower-case names.
add_subdirectory(libraries)
add_subdirectory(applications)
#find_program ( CLANG_TIDY_EXE NAMES clang-tidy clang-tidy.exe
# PATHS "$ENV{ProgramFiles}/Microsoft Visual Studio/2022/Professional/VC/Tools/Llvm/bin"
# DOC "Path to clang-tidy executable"
#)
#find_program (
# CLANG_TIDY_EXE
# NAMES
# clang-tidy clang-tidy.exe
# DOC
# "Path to clang-tidy executable"
# PATHS
# ".../Llvm/bin"
#)
#message(STATUS "$ENV{ProgramFiles}/Microsoft Visual Studio/2022/Professional/VC/Tools/Llvm/bin")
#message(STATUS "MSVC_VERSION: ${MSVC_VERSION}")
#message(STATUS "MSVC_TOOLSET_VERSION: ${MSVC_TOOLSET_VERSION}")
#if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# message(STATUS "Install to default")
#else(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# message(STATUS "Install to custom")
#endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# TODO: Test on clean project. The defalult install dir will be
# c:/Program Files/${PROJECT_NAME}
#if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# set(CMAKE_INSTALL_PREFIX "/my/default" CACHE PATH "..." FORCE)
#endif()
# include(FetchContent)
# message("Configure Eigen: ")
# FetchContent_Declare(
# eigen
# GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
# GIT_TAG 3.4
# GIT_SHALLOW TRUE
# GIT_PROGRESS TRUE
# )
# option(EIGEN_BUILD_DOC OFF)
# option(BUILD_TESTING OFF)
# option(EIGEN_LEAVE_TEST_IN_ALL_TARGET OFF)
# option(EIGEN_BUILD_PKGCONFIG OFF)
# FetchContent_MakeAvailable(eigen)
# message("====================================")
# message("Configure spdlog: ")
# FetchContent_Declare(
# spdlog
# GIT_REPOSITORY https://github.com/gabime/spdlog.git
# GIT_TAG v1.8.5
# GIT_SHALLOW TRUE
# GIT_PROGRESS TRUE
# )
# option(SPDLOG_BUILD_SHARED OFF)
# option(SPDLOG_BUILD_ALL OFF)
# FetchContent_MakeAvailable(spdlog)
# include(FetchContent)
# message("Configure Eigen: ")
# FetchContent_Declare(
# eigen
# GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
# GIT_TAG 3.4
# GIT_SHALLOW TRUE
# GIT_PROGRESS TRUE
# )
# option(EIGEN_BUILD_DOC OFF)
# option(BUILD_TESTING OFF)
# option(EIGEN_LEAVE_TEST_IN_ALL_TARGET OFF)
# option(EIGEN_BUILD_PKGCONFIG OFF)
# FetchContent_MakeAvailable(eigen)
# set_target_properties(eigen PROPERTIES EXCLUDE_FROM_ALL TRUE)