-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
208 lines (170 loc) · 8.82 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.22)
project(FastLanes)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
# Requirements : -------------------------------------------------------------------------------------------------------
if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
message(FATAL_ERROR "Only Clang is supported!")
endif ()
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13)
message(FATAL_ERROR "Only Clang >= 13 is supported!")
endif ()
# FLAGS : --------------------------------------------------------------------------------------------------------------
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Winconsistent-missing-override -Wshadow -Wconversion -Wnon-virtual-dtor -Wunused -Wpedantic -Woverloaded-virtual -Wshorten-64-to-32")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wshadow -Wconversion")
#-----------------------------------------------------------------------------------------------------------------------
include(FetchContent)
include(CheckCXXCompilerFlag)
include(CMakePrintHelpers)
# https://stackoverflow.com/questions/56089330/cmake-creates-lots-of-targets-i-didnt-specify
set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1)
include(CTest)
# Options : ------------------------------------------------------------------------------------------------------------
option(FLS_BUILD_FLS "Build FLS" ON)
option(FLS_BUILD_ALP "Build ALP" ON)
option(FLS_BUILD_TESTING "Build Test" OFF)
option(FLS_BUILD_BENCHMARKING "Enable Benchmark Build" OFF)
option(FLS_BUILD_EXAMPLE "Build Example" OFF)
option(FLS_BUILD_GPU "Build GPU" OFF)
option(FLS_BUILD_GTEST "Build GTEST" OFF)
option(FLS_ENABLE_CLANG_TIDY "Enable clang_tidy on all targets" ON)
option(FLS_ENABLE_IWYU "Enable include-what-you-use tool" OFF)
option(FLS_ENABLE_DOC "Enable Doc build" OFF)
option(FLS_ENABLE_TABLE_LOG "Enable Table Log" OFF)
# ALP: ---------------------------------------------------------------------------------------------------------------
if (FLS_BUILD_ALP)
message("---------------------------------------------------------------------------------------------------------")
message("-- FLS: Build ALP.")
FetchContent_Declare(
alp_repo
GIT_REPOSITORY https://github.com/cwida/ALP.git
GIT_TAG main #
)
FetchContent_MakeAvailable(alp_repo)
include_directories(${alp_repo_SOURCE_DIR}/include)
endif ()
# GTEST : ------------------------------------------------------------------------------------------------------------
if (FLS_BUILD_TESTING OR FLS_BUILD_GPU)
message("---------------------------------------------------------------------------------------------------------")
message("-- FLS: Building GTEST:")
include(GoogleTest)
# Gtest: -----------------------------------------------------------------------------------------------------------
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG e2239ee6043f73722e7aa812a459f54a28552929 # release-1.11.0
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
enable_testing()
# Silence clang-tidy warnings from googletest
set_target_properties(gtest PROPERTIES CXX_CLANG_TIDY "")
set_target_properties(gtest_main PROPERTIES CXX_CLANG_TIDY "")
set_target_properties(gmock PROPERTIES CXX_CLANG_TIDY "")
set_target_properties(gmock_main PROPERTIES CXX_CLANG_TIDY "")
endif ()
# DATA : ---------------------------------------------------------------------------------------------------------------
if (FLS_BUILD_TESTING OR FLS_BUILD_BENCHMARKING OR FLS_BUILD_EXAMPLE)
message("---------------------------------------------------------------------------------------------------------")
message("-- FLS: Enabling Data.")
include_directories(${CMAKE_SOURCE_DIR}/data/include)
FetchContent_Declare(
data
GIT_REPOSITORY https://github.com/cwida/FastLanes_Data.git
GIT_TAG 2_no_git_moudles # main
)
FetchContent_MakeAvailable(data)
add_compile_definitions(FASTLANES_DATA_DIR="${data_SOURCE_DIR}")
cmake_print_variables(data_SOURCE_DIR)
endif ()
# Definitions: ---------------------------------------------------------------------------------------------------------
add_compile_definitions(CMAKE_SOURCE_DIR="${CMAKE_SOURCE_DIR}")
if (FLS_ENABLE_CLANG_TIDY)
message("---------------------------------------------------------------------------------------------------------")
message("-- FLS: Enabling CLANG-TIDY.")
find_program(CLANG_TIDY_EXE NAMES clang-tidy)
if (NOT CLANG_TIDY_EXE)
message(FATAL_ERROR "-- FLS: clang-tidy not found.")
else ()
set(CMAKE_CXX_CLANG_TIDY
${CLANG_TIDY_EXE};
-header-filter=include;
-warnings-as-errors=*;)
endif ()
endif ()
if (FLS_ENABLE_IWYU)
message("---------------------------------------------------------------------------------------------------------")
message("-- FLS: Enabling IWYU")
find_program(iwyu_path NAMES include-what-you-use iwyu REQUIRED)
if (NOT iwyu_path)
message(WARNING "-- FLS_ERROR: Could not find the program include-what-you-use")
endif ()
endif ()
if (FLS_ENABLE_DOC)
find_package(Doxygen OPTIONAL_COMPONENTS dot)
if (DOXYGEN_FOUND)
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md")
doxygen_add_docs(doc
${CMAKE_SOURCE_DIR}
)
endif (DOXYGEN_FOUND)
endif ()
if (FLS_ENABLE_TABLE_LOG)
endif ()
if (FLS_BUILD_FLS)
# FLGs: ------------------------------------------------------------------------------------------------------------
message("---------------------------------------------------------------------------------------------------------")
message("- FFF:")
cmake_print_variables(CMAKE_OSX_ARCHITECTURES)
cmake_print_variables(CMAKE_HOST_SYSTEM_PROCESSOR)
cmake_print_variables(CMAKE_SYSTEM_PROCESSOR)
cmake_print_variables(CMAKE_HOST_SYSTEM_NAME)
cmake_print_variables(CMAKE_SYSTEM_NAME)
cmake_print_variables(CMAKE_C_COMPILER)
cmake_print_variables(CMAKE_CXX_COMPILER)
cmake_print_variables(CMAKE_CXX_COMPILER_ID)
cmake_print_variables(CMAKE_CXX_COMPILER_VERSION)
cmake_print_variables(CMAKE_LINKER)
cmake_print_variables(CMAKE_CROSSCOMPILING)
cmake_print_variables(CMAKE_CXX_FLAGS)
cmake_print_variables(CMAKE_CXX_FLAGS_DEBUG)
cmake_print_variables(CMAKE_CXX_FLAGS_RELEASE)
cmake_print_variables(CMAKE_BUILD_TYPE)
cmake_print_variables(CMAKE_CXX_STANDARD)
# Include : --------------------------------------------------------------------------------------------------------
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/third_party)
# Primitives: ------------------------------------------------------------------------------------------------------
add_subdirectory(${CMAKE_SOURCE_DIR}/primitives)
# Source: ----------------------------------------------------------------------------------------------------------
add_subdirectory(${CMAKE_SOURCE_DIR}/src)
# Third_party: -----------------------------------------------------------------------------------------------------
add_subdirectory(${CMAKE_SOURCE_DIR}/third_party)
endif ()
# Benchmark : ----------------------------------------------------------------------------------------------------------
if (FLS_BUILD_BENCHMARKING)
message("---------------------------------------------------------------------------------------------------------")
message("- Benchmark:")
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/benchmark/include)
add_subdirectory(${CMAKE_SOURCE_DIR}/benchmark)
endif ()
# Test: ----------------------------------------------------------------------------------------------------------------
if (FLS_BUILD_TESTING)
include_directories(${CMAKE_SOURCE_DIR}/test/include)
add_subdirectory(${CMAKE_SOURCE_DIR}/test)
endif ()
# Example : ------------------------------------------------------------------------------------------------------------
if (FLS_BUILD_EXAMPLE)
message("---------------------------------------------------------------------------------------------------------")
message("- Examples:")
add_subdirectory(${CMAKE_SOURCE_DIR}/example)
endif ()
# GPU : ----------------------------------------------------------------------------------------------------------------
if (FLS_BUILD_GPU)
message("---------------------------------------------------------------------------------------------------------")
message("- GPU:")
add_subdirectory(${CMAKE_SOURCE_DIR}/gpu)
endif ()