Skip to content

Commit 5fd63fa

Browse files
committed
build: CMake: Support bundled Boost
This starts a series of commits introducing Hunter Package Manager support. The end goal is to make building with CMake on Windows possible.
1 parent 3aa1aa8 commit 5fd63fa

File tree

4 files changed

+589
-11
lines changed

4 files changed

+589
-11
lines changed

CMakeLists.txt

+45-10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,25 @@
77
# CMake support is experimental. Use with caution and report any bugs.
88

99
cmake_minimum_required(VERSION 3.18)
10+
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/build-aux/cmake")
11+
12+
13+
# Hunter Package Manager
14+
# ======================
15+
16+
# Windows doesn't yet have a package manager that can be used for managing
17+
# dependencies, so we use Hunter on it.
18+
option(HUNTER_ENABLED "Enable Hunter package manager" OFF)
19+
include(HunterGate)
20+
HunterGate(
21+
URL "https://github.com/cpp-pm/hunter/archive/refs/tags/v0.25.3.tar.gz"
22+
SHA1 "0dfbc2cb5c4cf7e83533733bdfd2125ff96680cb"
23+
FILEPATH "${CMAKE_CURRENT_SOURCE_DIR}/build-aux/cmake/Hunter/config.cmake"
24+
)
25+
26+
27+
# Project configuration
28+
# =====================
1029

1130
project("Gridcoin"
1231
VERSION 5.4.5.4
@@ -37,20 +56,21 @@ string(REPLACE "NDEBUG" "_NDEBUG" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_REL
3756
string(REPLACE "NDEBUG" "_NDEBUG" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
3857

3958

40-
# Load modules from the source tree
41-
# =================================
42-
43-
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/build-aux/cmake")
59+
# Load CMake modules
60+
# ==================
4461

4562
include(CheckCXXSymbolExists)
4663
include(CheckFunctionExists)
4764
include(CheckIncludeFile)
4865
include(CheckPIESupported)
66+
include(CheckSymbolExists)
67+
4968
include(CheckSSE)
5069
include(CheckStrerrorR)
51-
include(CheckSymbolExists)
70+
include(HunterGate)
5271
include(VersionFromGit)
5372

73+
5474
# Define options
5575
# ==============
5676

@@ -74,21 +94,32 @@ option(ENABLE_QRENCODE "Enable generation of QR Codes for receiving payments" O
7494
option(ENABLE_UPNP "Enable UPnP port mapping support" OFF)
7595
option(DEFAULT_UPNP "Turn UPnP on startup" OFF)
7696
option(USE_DBUS "Enable DBus support" OFF)
97+
98+
# Bundled packages
7799
option(SYSTEM_BDB "Find system installation of Berkeley DB CXX 5.3" OFF)
78100
option(SYSTEM_LEVELDB "Find system installation of leveldb" OFF)
79101
option(SYSTEM_SECP256K1 "Find system installation of libsecp256k1 with pkg-config" OFF)
80102
option(SYSTEM_UNIVALUE "Find system installation of Univalue with pkg-config" OFF)
81103
option(SYSTEM_XXD "Find system xxd binary" OFF)
82104

105+
# Hunter packages
106+
option(BUNDLED_BOOST "Use the bundled version of Boost" ${HUNTER_ENABLED})
83107

84-
# Find dependencies
85-
# =================
86108

87-
set(BOOST_MINIMUM_VERSION 1.63.0)
109+
# Handle dependencies
110+
# ===================
111+
88112
set(QT5_MINIMUM_VERSION 5.15.0)
89113

114+
set(BOOST_MINIMUM_VERSION 1.63.0)
115+
set(BOOST_COMPONENTS filesystem iostreams thread)
116+
set(BOOST_HUNTER_COMPONENTS ${BOOST_COMPONENTS})
117+
if(ENABLE_TESTS)
118+
list(APPEND BOOST_COMPONENTS unit_test_framework)
119+
list(APPEND BOOST_HUNTER_COMPONENTS test)
120+
endif()
121+
90122
find_package(Atomics REQUIRED)
91-
find_package(Boost ${BOOST_MINIMUM_VERSION} COMPONENTS filesystem iostreams thread REQUIRED)
92123
find_package(CURL COMPONENTS HTTP HTTPS SSL REQUIRED)
93124
find_package(OpenSSL REQUIRED)
94125
find_package(Threads REQUIRED)
@@ -114,6 +145,11 @@ if(SYSTEM_UNIVALUE)
114145
pkg_check_modules(UNIVALUE REQUIRED IMPORTED_TARGET libunivalue)
115146
endif()
116147

148+
if(BUNDLED_BOOST)
149+
hunter_add_package(Boost COMPONENTS ${BOOST_HUNTER_COMPONENTS})
150+
endif()
151+
find_package(Boost ${BOOST_MINIMUM_VERSION} COMPONENTS ${BOOST_COMPONENTS} CONFIG REQUIRED)
152+
117153
if(USE_ASM)
118154
enable_language(ASM)
119155
endif()
@@ -146,7 +182,6 @@ if(ENABLE_UPNP)
146182
endif()
147183

148184
if(ENABLE_TESTS)
149-
find_package(Boost ${BOOST_MINIMUM_VERSION} COMPONENTS unit_test_framework REQUIRED)
150185
enable_testing()
151186

152187
if(SYSTEM_XXD)

build-aux/cmake/Hunter/config.cmake

Whitespace-only changes.

0 commit comments

Comments
 (0)