This repository has been archived by the owner on Jan 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
CMakeLists.txt
94 lines (74 loc) · 3.32 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
#[[
Copyright 2020 The Silkrpc Authors
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.
]]
cmake_minimum_required(VERSION 3.16)
# Add support for MacOS architectures
set(CMAKE_OSX_ARCHITECTURES ${ARCHS_STANDARD} CACHE INTERNAL "" FORCE)
# Check that submodules initialization has been done
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/third-party/silkworm/.git)
message(FATAL_ERROR "Git submodules not initialized, execute:\n git submodule update --init --recursive")
endif()
# Use default toolchain file if not specified on the command line
if(NOT CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/third-party/silkworm/cmake/toolchain/cxx20.cmake CACHE FILEPATH "" FORCE)
endif()
# Enable language *before* indirectly including GNUInstallDirs (see CableBuildInfo)
enable_language(CXX)
include(third-party/silkworm/third_party/evmone/cmake/cable/bootstrap.cmake)
include(CableBuildInfo)
include(third-party/silkworm/third_party/evmone/cmake/cable/HunterGate.cmake)
HunterGate(
URL "https://github.com/cpp-pm/hunter/archive/v0.24.15.tar.gz"
SHA1 "8010d63d5ae611c564889d5fe12d3cb7a45703ac"
FILEPATH "${CMAKE_SOURCE_DIR}/third-party/silkworm/cmake/Hunter/config.cmake"
)
project(silkrpc)
set(PROJECT_VERSION 0.0.7)
string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" _ ${PROJECT_VERSION})
set(PROJECT_VERSION_MAJOR ${CMAKE_MATCH_1})
set(PROJECT_VERSION_MINOR ${CMAKE_MATCH_2})
set(PROJECT_VERSION_PATCH ${CMAKE_MATCH_3})
cable_add_buildinfo_library(PROJECT_NAME ${PROJECT_NAME})
# Enforce minimum compiler versions
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_C_COMPILER_VERSION VERSION_LESS 10.3.0)
message(FATAL_ERROR "required gcc version >= 10.3.0")
endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.3.0)
message(FATAL_ERROR "required g++ version >= 10.3.0")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
if(CMAKE_C_COMPILER_VERSION VERSION_LESS 10.0.0)
message(FATAL_ERROR "required clang version >= 10.0.0")
endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0.0)
message(FATAL_ERROR "required clang++ version >= 10.0.0")
endif()
endif()
include(cmake/Hunter/packages.cmake)
# Silence CMake policy warnings in submodules
set(CMAKE_POLICY_DEFAULT_CMP0048 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0063 NEW)
# Silkworm
find_package(ethash CONFIG REQUIRED)
find_package(intx CONFIG REQUIRED)
# Silkrpc itself
option(SILKRPC_CLANG_COVERAGE "Clang instrumentation for code coverage reports" OFF)
option(SILKRPC_USE_MIMALLOC "Enable using mimalloc for dynamic memory management" ON)
if(SILKRPC_CLANG_COVERAGE)
add_compile_options(-fprofile-instr-generate -fcoverage-mapping -DBUILD_COVERAGE)
add_link_options(-fprofile-instr-generate -fcoverage-mapping)
endif()
add_subdirectory(third-party)
add_subdirectory(silkworm)
add_subdirectory(cmd)
add_subdirectory(examples)