-
Notifications
You must be signed in to change notification settings - Fork 83
/
CMakeLists.txt
82 lines (66 loc) · 3.47 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
cmake_minimum_required(VERSION 3.15)
project(ledger-core)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
option(TARGET_JNI "Indicates wheter or not the toolchain must build for JNI or not" OFF)
option(BUILD_TESTS "Indicates wheter or not the toolchain must build the test or not" ON)
option(TESTS_UPDATE_HTTP_CACHE "Update HTTP cache for tests" OFF)
option(TESTS_USE_EXTERNAL_WEB_SERVICES "Use external web-services instead of cached HTTP responses" OFF)
option(NIX_BUILD "Indicates whether this build is using nix dependencies." OFF)
option(SYS_LIBUV "Indicates whether this build is using system libuv." OFF)
option(SYS_SECP256K1 "Indicates whether this build is using system libsecp256k1." OFF)
option(SYS_OPENSSL "Indicates whether this build is using system openssl." OFF)
if(NIX_BUILD)
set(SYS_LIBUV ON CACHE BOOL "Building with Nix implies using system UV" FORCE)
set(SYS_SECP256K1 ON CACHE BOOL "Building with Nix implies using system secp256k1" FORCE)
set(SYS_OPENSSL ON CACHE BOOL "Building with Nix implies using system openssl" FORCE)
endif()
# Update Cmake Module Path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-modules")
include(UseBackportedModules)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-scripts")
# General internal functions
function (unsetListOfVarsStartingWith _prefix)
get_cmake_property(_vars VARIABLES)
string (REGEX MATCHALL "(^|;)${_prefix}[A-Za-z0-9_]*" _matchedVars "${_vars}")
FOREACH(var ${_matchedVars})
unset (${var} CACHE)
ENDFOREACH()
endfunction()
# Include cmake scripts
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CCache.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/Coverage.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/Cotire.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-scripts/c++-standards.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-scripts/tools.cmake")
cxx_17()
clang_tidy("-checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus*,cppcoreguidelines-*,modernize-*") # add cmake conf option CLANG_TIDY=ON to activate
include_what_you_use() # add cmake conf option IWYU=ON to activate
# The project version number.
set(VERSION_MAJOR 4 CACHE STRING "Project major version number.")
set(VERSION_MINOR 7 CACHE STRING "Project minor version number.")
set(VERSION_PATCH 6 CACHE STRING "Project patch version number.")
mark_as_advanced(VERSION_MAJOR VERSION_MINOR VERSION_PATCH)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY build)
list(APPEND INCLUDE_DIRECTORIES core/test/include/)
# Setup BOOST
set(BOOST_INCLUDEDIR "${CMAKE_CURRENT_SOURCE_DIR}/core/lib/boost/")
set(CMAKE_MACOSX_RPATH 1)
add_definitions("-DSQLITE_HAS_CODEC")
# To add SSL support
if (SSL_SUPPORT)
add_definitions("-DSSL_SUPPORT")
endif()
string(FIND "${CMAKE_OSX_SYSROOT}" "iphone" IS_IOS)
if(IS_IOS GREATER_EQUAL 0 OR TARGET_JNI OR ANDROID)
set(BUILD_TESTING OFF CACHE BOOL "iOS build fail otherwise" FORCE)
set(BUILD_TESTS OFF CACHE BOOL "Cannot run tests for these options" FORCE)
endif()
enable_testing()
add_subdirectory(doc)
add_subdirectory(core)
# Fix LLC-186: Add this flag to avoid crash for 10.10.x version
# https://stackoverflow.com/questions/41865537/how-does-apples-codesign-utility-decide-which-sha-algorithms-to-sign-a-shared
# Notes:
# > This is a "blind" fix, no available 10.10.x macOS machine,
# > Issue is specific to 10.10.x, 10.9.5 and > 10.10.x are fine
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X version to target for deployment: 10.9" FORCE)