-
Notifications
You must be signed in to change notification settings - Fork 58
/
CMakeLists.txt
110 lines (92 loc) · 3.58 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
cmake_minimum_required(VERSION 3.10)
project(gdk VERSION 0.73.3 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(cmake/includes/helpers.cmake)
include(cmake/includes/greengdk.cmake)
cmake_policy(SET CMP0074 NEW)
### project options
option(ENABLE_TESTS "enable building tests" FALSE)
option(BUILD_SHARED_LIBS "build gdk as shared library" FALSE)
option(DEV_MODE "dev mode enables a faster developing-testing loop when working with the python-wheel" FALSE)
option(ENABLE_SWIFT "enable build of swift bindings" FALSE)
OPTION(ENABLE_BCUR "enable support QR code encoding/decoding" TRUE)
set(PYTHON_REQUIRED_VERSION 3 CACHE STRING "required python version")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
### avoiding in-build compilation, your local gdk folder would turn into a real mess
### WARNING. please refine this once cmake_path becomes available
if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not allowed")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
###### searching for dependencies
#### projects with cmake-provided FindXXX module
# boost
set(Boost_USE_STATIC_LIBS ON)
if (CMAKE_BUILD_TYPE STREQUAL Debug)
set(Boost_USE_DEBUG_LIBS ON)
else()
set(Boost_USE_DEBUG_LIBS OFF)
endif()
set(Boost_NO_SYSTEM_PATHS ON)
find_package(Boost 1.84.0 EXACT REQUIRED COMPONENTS date_time thread log chrono system)
# zlib
set(ZLIB_ROOT ${CMAKE_PREFIX_PATH})
find_package(ZLIB 1.3 EXACT REQUIRED)
# openSSL
set(OPENSSL_USE_STATIC_LIBS ON)
find_package(OpenSSL 1.1.1 EXACT REQUIRED)
#### cmake-based projects with xxx-config.cmake file
find_package(nlohmann_json REQUIRED CONFIG)
find_package(Microsoft.GSL REQUIRED CONFIG)
find_package(websocketpp REQUIRED CONFIG)
find_package(msgpack REQUIRED CONFIG)
find_package(Libevent REQUIRED CONFIG COMPONENTS core extra OPTIONAL_COMPONENTS pthreads)
# ur-c
set(URC_INCLUDE_DIRS "")
set(URC_LINK_LIBRARIES "")
if (ENABLE_BCUR)
find_package(bcur REQUIRED MODULE)
find_package(urc REQUIRED)
get_target_property(URC_INCLUDE_DIRS urc::urc INTERFACE_INCLUDE_DIRECTORIES)
string(TOUPPER ${CMAKE_BUILD_TYPE} _upcase_build_type)
get_target_property(URC_LINK_LIBRARIES urc::urc IMPORTED_LOCATION_${_upcase_build_type})
set_target_properties(urc::urc PROPERTIES INTERFACE_LINK_LIBRARIES "PkgConfig::TinyCBOR")
add_compile_definitions(USE_REAL_BCUR)
endif()
#### dependencies relying on pkg-config
find_package(PkgConfig REQUIRED)
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
# wallycore
pkg_check_modules(wallycore REQUIRED IMPORTED_TARGET wallycore)
pkg_check_modules(libsecp256k1 REQUIRED IMPORTED_TARGET libsecp256k1)
set(TINYCBOR_INCLUDE_DIRS "")
if (ENABLE_BCUR)
pkg_check_modules(TinyCBOR REQUIRED IMPORTED_TARGET tinycbor)
get_target_property(TINYCBOR_INCLUDE_DIRS PkgConfig::TinyCBOR INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "TINYCBOR_INCLUDE_DIRS: ${TINYCBOR_INCLUDE_DIRS}")
endif()
#### custom packages
find_package(tor REQUIRED MODULE)
find_package(sqlite3 REQUIRED MODULE)
find_package(autobahn REQUIRED MODULE)
####################################################################
create_gdkrust_target()
add_subdirectory(src)
if (NOT BUILD_SHARED_LIBS)
create_greengdkfull_target()
endif()
## bindings
find_package(SWIG)
add_subdirectory(src/swig_java)
find_package(Python ${PYTHON_REQUIRED_VERSION} EXACT COMPONENTS Interpreter)
add_subdirectory(src/swig_python)
add_subdirectory(src/swift)
### installation directives
install_cmake_config()
#### test testing tests
if(NOT ENABLE_TESTS)
return()
endif()
enable_testing()
add_subdirectory(tests)