This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
181 lines (153 loc) · 6.07 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
# Copyright 2023 Klepsydra Technologies AG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Main header: Project name & Configuration
# ------------------------------------------------------------------------------------------------------
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
SET(PROJ_MAIN_NAME "benchmark")
PROJECT(${PROJ_MAIN_NAME})
# Set kpsr-core-benchmark version.
# ------------------------------------------------------------------------------------------------------
set(BENCHMARK_MAJOR_VERSION 1)
set(BENCHMARK_MINOR_VERSION 0)
set(BENCHMARK_PATCH_VERSION 0)
set(BENCHMARK_VERSION
${BENCHMARK_MAJOR_VERSION}.${BENCHMARK_MINOR_VERSION}.${BENCHMARK_PATCH_VERSION})
# Configuration types
# ------------------------------------------------------------------------------------------------------
SET(CMAKE_CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo" CACHE STRING "Configs" FORCE)
IF(DEFINED CMAKE_BUILD_TYPE AND CMAKE_VERSION VERSION_GREATER "2.8")
SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES})
ENDIF()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
enable_testing()
# Configure variables
# ------------------------------------------------------------------------------------------------------
# Paths
if(DEFINED KPSR_BUILD_PATH)
else()
SET(KPSR_BUILD_PATH ${CMAKE_SOURCE_DIR}/kpsr-build)
endif()
message(STATUS "kpsr-build path: " ${KPSR_BUILD_PATH})
IF(DEFINED THIRDPARTIES_PATH)
ELSE()
SET(THIRDPARTIES_PATH ${CMAKE_SOURCE_DIR}/thirdparties )
ENDIF()
message(STATUS "Thirdparties install path: " ${THIRDPARTIES_PATH})
SET(CMAKE_MODULE_PATH ${KPSR_BUILD_PATH}/cmake)
IF(DEFINED GBENCHMARK_PATH)
ELSE()
SET(GBENCHMARK_PATH ${CMAKE_SOURCE_DIR}/thirdparties/benchmark)
ENDIF()
message(STATUS "Google benchmark path: " ${GBENCHMARK_PATH})
IF(DEFINED GOOGLETEST_PATH)
ELSE()
SET(GOOGLETEST_PATH ${CMAKE_SOURCE_DIR}/thirdparties/googletest) #google test path var needed for benchmark.
ENDIF()
message(STATUS "Google test path: " ${GOOGLETEST_PATH})
IF(DEFINED SIMDJSON_PATH)
ELSE()
SET(SIMDJSON_PATH ${CMAKE_SOURCE_DIR}/thirdparties/simdjson)
ENDIF()
message(STATUS "SimdJSON path: " ${SIMDJSON_PATH})
IF(DEFINED cereal_DIR)
ELSE()
SET(cereal_DIR ${CMAKE_SOURCE_DIR}/thirdparties/cereal)
ENDIF()
message(STATUS "cereal_DIR path: " ${cereal_DIR})
IF(DEFINED PODS_PATH)
ELSE()
SET(PODS_PATH ${CMAKE_SOURCE_DIR}/thirdparties/pods)
ENDIF()
message(STATUS "pods path: " ${PODS_PATH})
IF(DEFINED YAS_PATH)
ELSE()
SET(YAS_PATH ${CMAKE_SOURCE_DIR}/thirdparties/yas)
ENDIF()
message(STATUS "yas path: " ${YAS_PATH})
IF(DEFINED JSON_FILE_PATH_AND_NAME)
ADD_DEFINITIONS(-DJSON_FILE_PATH_AND_NAME="\""${JSON_FILE_PATH_AND_NAME}"\"")
ELSE()
ADD_DEFINITIONS(-DJSON_FILE_PATH_AND_NAME="cereal_json_str.txt")
SET(JSON_FILE_PATH_AND_NAME cereal_json_str.txt)
ENDIF()
message(STATUS "JSON_FILE_PATH_AND_NAME: " ${JSON_FILE_PATH_AND_NAME})
IF(DEFINED BM_DENSE_RANGE_START)
ADD_DEFINITIONS(-DBM_DENSE_RANGE_START=${BM_DENSE_RANGE_START})
ELSE()
ADD_DEFINITIONS(-DBM_DENSE_RANGE_START=1024)
SET(BM_DENSE_RANGE_START 1024)
ENDIF()
message(STATUS "BM_DENSE_RANGE_START: " ${BM_DENSE_RANGE_START})
IF(DEFINED BM_DENSE_RANGE_END)
ADD_DEFINITIONS(-DBM_DENSE_RANGE_END=${BM_DENSE_RANGE_END})
ELSE()
ADD_DEFINITIONS(-DBM_DENSE_RANGE_END=102400)
SET(BM_DENSE_RANGE_END 102400)
ENDIF()
message(STATUS "BM_DENSE_RANGE_END: " ${BM_DENSE_RANGE_END})
IF(DEFINED BM_DENSE_RANGE_INCR)
ADD_DEFINITIONS(-DBM_DENSE_RANGE_INCR=${BM_DENSE_RANGE_INCR})
ELSE()
ADD_DEFINITIONS(-DBM_DENSE_RANGE_INCR=1024)
SET(BM_DENSE_RANGE_INCR 1024)
ENDIF()
message(STATUS "BM_DENSE_RANGE_INCR: " ${BM_DENSE_RANGE_INCR})
# Required packages.
# ------------------------------------------------------------------------------------------------------
find_package(Klepsydra REQUIRED)
# Ouput paths.
# ------------------------------------------------------------------------------------------------------
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "Library output" FORCE)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "Executable output" FORCE)
######################################################################################
# ADD SUB FOLDERS
######################################################################################
ADD_SUBDIRECTORY(benchmark)
ADD_SUBDIRECTORY(${GOOGLETEST_PATH})
ADD_SUBDIRECTORY(${GBENCHMARK_PATH})
#set_target_properties(cxx03_test PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
ADD_SUBDIRECTORY(${SIMDJSON_PATH})
ADD_SUBDIRECTORY(${PODS_PATH})
######################################################################################
# CODE STYLE
######################################################################################
if (KPSR_WITH_CODE_METRICS)
include(CodeCoverage)
set(CODE_COVERAGE_VERBOSE ON)
APPEND_COVERAGE_COMPILER_FLAGS()
# Code style check
include(CppcheckTargets)
include(Findcppcheck)
ENDIF()
# Code format check
include(CodeFormat)
# Code Coverage
if (KPSR_WITH_CODE_METRICS AND CMAKE_BUILD_TYPE MATCHES Debug AND CMAKE_COMPILER_IS_GNUCXX)
STRING(REPLACE ${CMAKE_SOURCE_DIR}/ "" THIRDPARTIES_PATH_COVERAGE ${THIRDPARTIES_PATH})
LIST(APPEND COVERAGE_EXCLUDES
${THIRDPARTIES_PATH_COVERAGE}
${CMAKE_PREFIX_PATH}
benchmark/benchmark_json/tests
)
setup_target_for_coverage_gcovr_xml(
NAME coverage
EXECUTABLE make test
)
ENDIF()
######################################################################################
# CCACHE SUPPORT
######################################################################################
include(FindCcache)