-
Notifications
You must be signed in to change notification settings - Fork 44
/
CMakeLists.txt
201 lines (164 loc) · 7.23 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
#
# Copyright 2015-2024 Real Logic Limited.
#
# 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
#
# https://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.
#
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
cmake_policy(VERSION 3.16)
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory)"
"and run CMake from there. You may need to remove CMakeCache.txt.")
endif ()
include(ExternalProject)
project("benchmarks")
# default build type is Release
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build" FORCE)
endif (NOT CMAKE_BUILD_TYPE)
set(AERON_THIRDPARTY_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/thirdparty")
##########################################################
# Google benchmark
ExternalProject_Add(
google_benchmark
URL ${CMAKE_CURRENT_SOURCE_DIR}/cppbuild/benchmark-1.8.2.zip
URL_MD5 dbdc6b760ea4aad9c1ace0de813701e2
CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER};-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER};
-DBENCHMARK_ENABLE_TESTING=OFF;-DBENCHMARK_ENABLE_GTEST_TESTS=OFF;-DBENCHMARK_ENABLE_ASSEMBLY_TESTS=OFF;
-DCMAKE_BUILD_TYPE=Release
PREFIX "${AERON_THIRDPARTY_BINARY_DIR}/google_benchmark"
BUILD_BYPRODUCTS "${AERON_THIRDPARTY_BINARY_DIR}/google_benchmark/src/google_benchmark-build/src/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX}"
INSTALL_COMMAND ""
)
ExternalProject_Get_Property(google_benchmark source_dir)
set(GOOGLE_BENCHMARK_SOURCE_DIR ${source_dir})
ExternalProject_Get_Property(google_benchmark binary_dir)
set(GOOGLE_BENCHMARK_BINARY_DIR ${binary_dir})
set(
GOOGLE_BENCHMARK_LIBS
${GOOGLE_BENCHMARK_BINARY_DIR}/src/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX}
)
##########################################################
# HDR Histogram
ExternalProject_Add(
hdr_histogram
URL ${CMAKE_CURRENT_SOURCE_DIR}/cppbuild/HdrHistogram_c-0.11.8.zip
URL_MD5 e993a4a08ad084ea0a895e7b2502de99
CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER};-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER};-DCMAKE_C_STANDARD=99;-DHDR_LOG_REQUIRED=OFF
PREFIX "${AERON_THIRDPARTY_BINARY_DIR}/hdr_histogram"
BUILD_BYPRODUCTS "${AERON_THIRDPARTY_BINARY_DIR}/hdr_histogram/src/hdr_histogram-build/src/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}hdr_histogram_static${CMAKE_STATIC_LIBRARY_SUFFIX}"
INSTALL_COMMAND ""
)
ExternalProject_Get_Property(hdr_histogram source_dir)
set(HDRHISTOGRAM_SOURCE_DIR ${source_dir})
ExternalProject_Get_Property(hdr_histogram binary_dir)
set(HDRHISTOGRAM_BINARY_DIR ${binary_dir})
set(
HDRHISTOGRAM_LIBS
${HDRHISTOGRAM_BINARY_DIR}/src/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}hdr_histogram_static${CMAKE_STATIC_LIBRARY_SUFFIX}
)
##########################################################
# Aeron from github or local git
if (NOT AERON_GIT_URL)
set(AERON_GIT_URL "https://github.com/real-logic/aeron.git" CACHE STRING "Location of the Aeron git repo" FORCE)
endif (NOT AERON_GIT_URL)
if (NOT AERON_GIT_SHA)
if (NOT AERON_GIT_TAG)
set(AERON_GIT_TAG "origin/HEAD" CACHE STRING "Tag in the Aeron git repo" FORCE)
endif (NOT AERON_GIT_TAG)
ExternalProject_Add(
aeron
GIT_REPOSITORY ${AERON_GIT_URL}
GIT_TAG ${AERON_GIT_TAG}
GIT_SHALLOW TRUE
CMAKE_ARGS "-DAERON_TESTS=OFF" "-DAERON_SYSTEM_TESTS=OFF" "-DAERON_SLOW_SYSTEM_TESTS=OFF" "-DCMAKE_BUILD_TYPE=Release"
INSTALL_COMMAND ""
)
else ()
ExternalProject_Add(
aeron
GIT_REPOSITORY ${AERON_GIT_URL}
GIT_TAG ${AERON_GIT_SHA}
CMAKE_ARGS "-DAERON_TESTS=OFF" "-DAERON_SYSTEM_TESTS=OFF" "-DAERON_SLOW_SYSTEM_TESTS=OFF" "-DCMAKE_BUILD_TYPE=Release"
INSTALL_COMMAND ""
)
endif ()
ExternalProject_Get_Property(aeron source_dir)
set(AERON_SOURCE_DIR ${source_dir})
ExternalProject_Get_Property(aeron binary_dir)
set(AERON_BINARY_DIR ${binary_dir})
set(
AERON_LIBS
${AERON_BINARY_DIR}/lib/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}aeron_client${CMAKE_STATIC_LIBRARY_SUFFIX}
${AERON_BINARY_DIR}/lib/${CMAKE_CFG_INTDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}aeron_driver${CMAKE_SHARED_LIBRARY_SUFFIX}
)
##########################################################
# Platform flags, etc.
find_package(Threads)
if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif ()
if (NOT DEFINED CMAKE_CXX_EXTENSIONS)
set(CMAKE_CXX_EXTENSIONS OFF)
endif ()
if (NOT DEFINED CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 11)
endif ()
if (NOT DEFINED CMAKE_C_EXTENSIONS)
set(CMAKE_C_EXTENSIONS OFF)
endif ()
# all UNIX-based platform compiler flags
if (UNIX)
add_compile_options(-Wall -Wpedantic -Wextra -Wno-unused-parameter)
# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast -DDISABLE_BOUNDS_CHECKS")
add_compile_options($<$<CONFIG:Release>:-Ofast>)
endif ()
# platform specific flags
if (APPLE)
add_compile_options(-Wsign-compare)
add_definitions(-DDarwin)
add_compile_options(-Wno-deprecated-register)
elseif (CYGWIN)
add_definitions(-DWIN32)
#add_definitions(-DGTEST_HAS_PTHREAD)
string(REPLACE "-std=c++11" "-std=gnu++11" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
elseif (MSVC)
add_definitions(-DWIN32)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)
add_definitions(-DNOMINMAX)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd /Od /Zi /MP /wd4251")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT /MP /wd4251")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
unset(CMAKE_C_STANDARD) # To avoid `/std:c11` in the compiler options
if (C_WARNINGS_AS_ERRORS)
add_compile_options($<$<COMPILE_LANGUAGE:C>:/WX>)
endif (C_WARNINGS_AS_ERRORS)
if (CXX_WARNINGS_AS_ERRORS)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/WX>)
endif (CXX_WARNINGS_AS_ERRORS)
endif ()
##########################################################
# Project variables, etc.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/binaries")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib")
# google benchmark
include_directories(${GOOGLE_BENCHMARK_SOURCE_DIR}/include)
# Hdr Histogram
include_directories(${HDRHISTOGRAM_SOURCE_DIR}/include/hdr)
include_directories(${AERON_SOURCE_DIR}/aeron-client/src/main/cpp)
include_directories(${AERON_SOURCE_DIR}/aeron-client/src/main/c)
include_directories(${AERON_SOURCE_DIR}/aeron-driver/src/main/c)
include_directories(${CMAKE_SOURCE_DIR}/benchmarks-aeron/src/main/cpp)
##########################################################
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/benchmarks-aeron/src/main/cpp")