-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
177 lines (147 loc) · 7.54 KB
/
CMakeLists.txt
File metadata and controls
177 lines (147 loc) · 7.54 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
# ==========================================================================
# Copyright (C) 2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
# ==========================================================================
# Intel® Query Processing Library (Intel® QPL)
# Build system
# If QPL is build with -DSANITIZE_THREADS=ON, use CMake v3.23 or higher
# Before v3.23 CMake will not add -pthread when pthread is found in libc,
# and this causes undefined reference errors when QPL is build with -DSANITIZE_THREADS=ON
if (UNIX AND "${SANITIZE_THREADS}" STREQUAL "ON")
cmake_minimum_required(VERSION 3.23 FATAL_ERROR)
else ()
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
endif ()
project(QPL VERSION 1.9.0 LANGUAGES C CXX
DESCRIPTION "A library to provide high-performance query processing operations on Intel CPUs."
)
# Set default build type to release
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
# This specify the build version
set(QPL_SHARED_LIB_VERSION ${PROJECT_VERSION})
# This is the indicator for the API and ABI compatibility.
set(QPL_SHARED_LIB_SOVERSION ${PROJECT_VERSION_MAJOR})
set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/overrides.cmake")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
set(CMAKE_EXPORT_PACKAGE_REGISTRY ON)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
message(STATUS "Intel QPL version: ${CMAKE_PROJECT_VERSION}")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
# Build Options
set(QPL_USE_CLANG_SANITIZER "" CACHE STRING
"Enables build with sanitizers. Supported values:
ADDRESS: Enables AddressSanitizer
LEAK: Enables LeakSanitizer
UNDEFINED: Enables UndefinedBehaviorSanitizer
THREAD: Enables ThreadSanitizer
ALL_COMPATIBLE: Enables most of the currently compatible checks (Note: this option is for convenience and may change).")
option(LOG_HW_INIT "Enables HW initialization log" OFF)
option(QPL_EXPERIMENTAL_LOG_IAA "Enables logging of execution information on the accelerator to the job structure" OFF)
option(EFFICIENT_WAIT "Enables usage of efficient wait instructions" OFF)
option(LIB_FUZZING_ENGINE "Enables fuzzy testing" OFF)
option(DYNAMIC_LOADING_LIBACCEL_CONFIG "Loads the accelerator configuration library (libaccel-config) dynamically with dlopen" ON)
set(QPL_LIBRARY_TYPE "STATIC" CACHE STRING "Specifies the resulting library type")
option(QPL_USE_CLANG_TIDY "Run clang-tidy" OFF)
# Deprecated Build Options handling
option(SANITIZE_MEMORY "Enables memory sanitizing, Deprecated, use QPL_USE_CLANG_SANITIZER=ADDRESS, LEAK or ALL_COMPATIBLE instead" OFF)
option(SANITIZE_THREADS "Enables threads sanitizing, Deprecated, use QPL_USE_CLANG_SANITIZER=THREAD instead" OFF)
if (SANITIZE_MEMORY)
message(DEPRECATION "SANITIZE_MEMORY is deprecated and will be removed in a future version. Use QPL_USE_CLANG_SANITIZER instead.")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=leak -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=leak -g")
endif ()
if (SANITIZE_THREADS)
message(DEPRECATION "SANITIZE_THREADS is deprecated and will be removed in a future version. Use QPL_USE_CLANG_SANITIZER instead.")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -g")
endif ()
# Print user's settings
message(STATUS "Sanitizer used for build and testing: ${QPL_USE_CLANG_SANITIZER}")
message(STATUS "Hardware initialization logging: ${LOG_HW_INIT}")
message(STATUS "IAA execution information logging to job structure: ${QPL_EXPERIMENTAL_LOG_IAA}")
message(STATUS "Efficient wait instructions: ${EFFICIENT_WAIT}")
message(STATUS "Fuzz testing build: ${LIB_FUZZING_ENGINE}")
message(STATUS "Load libaccel-config dynamically with dlopen: ${DYNAMIC_LOADING_LIBACCEL_CONFIG}")
message(STATUS "Run clang-tidy: ${QPL_USE_CLANG_TIDY}")
message(STATUS "Library build type: ${QPL_LIBRARY_TYPE}")
if (QPL_USE_CLANG_SANITIZER)
if (WIN32)
message(WARNING "Sanitizers are not supported on Windows")
elseif (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
message(WARNING "Sanitizers are only supported with Clang")
else ()
set(SANITIZER_FLAGS "")
if (QPL_USE_CLANG_SANITIZER STREQUAL "ADDRESS")
set(SANITIZER_FLAGS "-fsanitize=address")
elseif (QPL_USE_CLANG_SANITIZER STREQUAL "LEAK")
set(SANITIZER_FLAGS "-fsanitize=leak")
elseif (QPL_USE_CLANG_SANITIZER STREQUAL "UNDEFINED")
set(SANITIZER_FLAGS "-fsanitize=integer -fsanitize=null")
elseif (QPL_USE_CLANG_SANITIZER STREQUAL "THREAD")
set(SANITIZER_FLAGS "-fsanitize=thread")
elseif (QPL_USE_CLANG_SANITIZER STREQUAL "ALL_COMPATIBLE")
set(SANITIZER_FLAGS "-fsanitize=address -fsanitize=leak -fsanitize=integer -fsanitize=null")
endif ()
if (SANITIZER_FLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_FLAGS} -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_FLAGS} -g")
endif ()
endif ()
endif ()
if (WIN32 AND "${QPL_LIBRARY_TYPE}" STREQUAL "SHARED")
message(FATAL_ERROR "Building shared library is not supported in Windows")
endif ()
if (LIB_FUZZING_ENGINE)
option(QPL_BUILD_EXAMPLES "Builds examples" OFF)
option(QPL_BUILD_TESTS "Builds tests and benchmarks framework" OFF)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-instr-generate -fcoverage-mapping -fsanitize=address,fuzzer -g -O1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping -fsanitize=address,fuzzer -g -O1")
endif ()
if (QPL_USE_CLANG_TIDY)
find_program(DO_CLANG_TIDY NAMES clang-tidy)
set(CMAKE_CXX_CLANG_TIDY ${DO_CLANG_TIDY})
set(CMAKE_C_CLANG_TIDY ${DO_CLANG_TIDY})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
message(STATUS "Using clang-tidy to run checks")
endif ()
include(cmake/CompileOptions.cmake)
include(cmake/target_settings.cmake)
include(GenerateExportHeader)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
install(EXPORT ${PROJECT_NAME}Targets
NAMESPACE QPL::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
"include(\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}Targets.cmake)\n")
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
SET(QPL_PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
# Build library
add_subdirectory(sources)
# Build additional components
# Set of extra options that allows to build only library, or library
# and examples excluding tests, etc.
option(QPL_BUILD_EXAMPLES "Builds examples" ON)
option(QPL_BUILD_TESTS "Builds tests and benchmarks framework" ON)
if (QPL_BUILD_TESTS)
enable_testing()
endif ()
# Print user's settings
message(STATUS "Build with examples: ${QPL_BUILD_EXAMPLES}")
message(STATUS "Build with tests and benchmarks framework: ${QPL_BUILD_TESTS}")
if (QPL_BUILD_EXAMPLES)
add_subdirectory(examples)
endif ()
add_subdirectory(tools)