-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
147 lines (110 loc) · 4.57 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
# Copyright (c) 2016-2024 Knuth Project developers.
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
cmake_minimum_required(VERSION 3.20)
project(node-exe VERSION 0 LANGUAGES CXX C)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(WITH_MEMPOOL "Mempool enabled." OFF)
option(DB_READONLY_MODE "Readonly DB mode enabled." OFF)
option(USE_LIBMDBX "Uses libmdbx DB library." OFF)
option(STATISTICS "Collect statistics." OFF)
option(GLOBAL_BUILD "" OFF)
if (WITH_MEMPOOL)
message(STATUS "Knuth: Mempool enabled")
add_definitions(-DKTH_WITH_MEMPOOL)
endif()
if (DB_READONLY_MODE)
message(STATUS "Knuth: Readonly DB mode enabled")
add_definitions(-DKTH_DB_READONLY)
endif()
if (USE_LIBMDBX)
add_definitions(-DKTH_USE_LIBMDBX)
endif()
if (STATISTICS)
add_definitions(-DKTH_STATISTICS_ENABLED)
endif()
set(LOG_LIBRARY "boost" CACHE STRING "Setting for the logging library (boost|spdlog|binlog).")
if (${LOG_LIBRARY} STREQUAL "boost")
add_definitions(-DKTH_LOG_LIBRARY_BOOST)
elseif (${LOG_LIBRARY} STREQUAL "spdlog")
add_definitions(-DKTH_LOG_LIBRARY_SPDLOG)
elseif (${LOG_LIBRARY} STREQUAL "binlog")
add_definitions(-DKTH_LOG_LIBRARY_BINLOG)
else()
message(FATAL_ERROR "Invalid Logging Library: ${LOG_LIBRARY}")
endif()
message(STATUS "Knuth: Logging Library: ${LOG_LIBRARY}")
set(MARCH_ID "" CACHE STRING "Specify the Microarchitecture ID (x86_64|...).")
message( STATUS "Knuth: Compiling for Microarchitecture ID ${MARCH_ID}")
message( STATUS "Knuth: CONAN_CXX_FLAGS ${CONAN_CXX_FLAGS}")
message( STATUS "Knuth: CONAN_C_FLAGS ${CONAN_C_FLAGS}")
set(CURRENCY "BCH" CACHE STRING "Specify the Cryptocurrency (BCH|BTC|LTC).")
if (${CURRENCY} STREQUAL "BCH")
add_definitions(-DKTH_CURRENCY_BCH)
elseif (${CURRENCY} STREQUAL "BTC")
add_definitions(-DKTH_CURRENCY_BTC)
elseif (${CURRENCY} STREQUAL "LTC")
add_definitions(-DKTH_CURRENCY_LTC)
else()
message(FATAL_ERROR "Invalid Cryptocurrency: ${CURRENCY}")
endif()
message(STATUS "Knuth: Cryptocurrency: ${CURRENCY}")
if (NOT GLOBAL_BUILD)
find_package(node REQUIRED)
endif()
include(CheckCXXCompilerFlag)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/ci_utils/cmake)
include(KnuthTools)
if (NOT MSVC)
_add_c_compile_flag(-Wall _has_all_warning_flag)
else()
_add_c_compile_flag(-W4 _has_all_warning_flag)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
if (NOT MSVC)
_add_c_compile_flag(-Wextra _has_extra_warning_flag)
endif()
_add_c_compile_flag(-Wpedantic _has_pedantic_warning_flag)
if (_has_pedantic_warning_flag)
_add_c_compile_flag(-pedantic _has_pedantic_flag)
endif()
_add_cxx_compile_flag(-Wno-missing-braces _has_no_missing_braces_warning_flag)
_add_cxx_compile_flag(-Wno-mismatched-tags _has_no_mismatched_tags_warning_flag)
_add_c_compile_flag(-Wno-deprecated-declarations _has_no_deprecated_declarations_warning_flag)
_add_link_flag(-fstack-protector _has_stack_protector_flag)
_add_link_flag(-fstack-protector-all _has_stack_protector_all_flag)
_add_cxx_compile_flag(-fvisibility-hidden _has_visibility_hidden_flag)
_add_cxx_compile_flag(-fvisibility-inlines-hidden _has_visibility_inlines_hidden_flag)
if (MSVC)
add_definitions(-D_WIN32_WINNT=0x0600)
endif()
# Build
# ------------------------------------------------------------------------------
add_executable(${PROJECT_NAME} src/main.cpp)
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX CXX_STANDARD 23 CXX_STANDARD_REQUIRED TRUE)
target_compile_definitions(${PROJECT_NAME} PUBLIC -DBCN_STATIC -DBCB_STATIC -DBCD_STATIC -DBCT_STATIC -DBC_STATIC)
target_link_libraries(${PROJECT_NAME} PUBLIC node::node)
if (MINGW)
target_link_libraries(${PROJECT_NAME} PUBLIC ws2_32 wsock32)
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "node" OUTPUT_NAME kth)
# Install
# ------------------------------------------------------------------------------
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Generate and install a CMake package configuration file
install(EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}-config.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)