blob: ca4d39d84c0f4537fa01715268d93ee06d4c5b04 (
plain) (
blame)
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
|
cmake_minimum_required(VERSION 3.9)
project(hotstuff)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/salticidae/cmake/Modules/")
add_subdirectory(salticidae)
include_directories(salticidae/include)
find_package(OpenSSL REQUIRED)
include(ExternalProject)
include_directories(secp256k1/include)
ExternalProject_Add(libsecp256k1
SOURCE_DIR secp256k1
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/secp256k1/autogen.sh
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/secp256k1/configure --disable-shared --with-pic --with-bignum=no --enable-module-recovery
BUILD_COMMAND make
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1)
add_library(secp256k1 STATIC IMPORTED)
set_target_properties(
secp256k1
PROPERTIES IMPORTED_LOCATION
${CMAKE_CURRENT_SOURCE_DIR}/secp256k1/.libs/libsecp256k1.a)
add_dependencies(secp256k1 libsecp256k1)
# add libraries
include_directories(include)
add_library(hotstuff
OBJECT
src/util.cpp
src/client.cpp
src/crypto.cpp
src/entity.cpp
src/consensus.cpp
src/hotstuff.cpp
)
option(BUILD_SHARED "build shared library." OFF)
if(BUILD_SHARED)
set_property(TARGET hotstuff PROPERTY POSITION_INDEPENDENT_CODE 1)
add_library(hotstuff_shared SHARED $<TARGET_OBJECTS:hotstuff>)
set_target_properties(hotstuff_shared PROPERTIES OUTPUT_NAME "hotstuff")
target_link_libraries(hotstuff_shared salticidae_static secp256k1 crypto)
endif()
add_library(hotstuff_static STATIC $<TARGET_OBJECTS:hotstuff>)
set_target_properties(hotstuff_static PROPERTIES OUTPUT_NAME "hotstuff")
target_link_libraries(hotstuff_static salticidae_static secp256k1 crypto)
add_subdirectory(test)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Release")
endif()
option(HOTSTUFF_ENABLE_DEBUG_LOG "enable debug log" OFF)
option(HOTSTUFF_ENABLE_NORMAL_LOG "enable normal log" ON)
if(HOTSTUFF_ENABLE_DEBUG_LOG)
add_definitions(-DHOTSTUFF_DEBUG_LOG)
elseif(HOTSTUFF_ENABLE_NORMAL_LOG)
add_definitions(-DHOTSTUFF_NORMAL_LOG)
endif()
# add executables
add_executable(hotstuff-app
src/hotstuff_app.cpp)
target_link_libraries(hotstuff-app hotstuff_static)
add_executable(hotstuff-client
src/hotstuff_client.cpp)
target_link_libraries(hotstuff-client hotstuff_static)
add_executable(hotstuff-keygen
src/hotstuff_keygen.cpp)
target_link_libraries(hotstuff-keygen hotstuff_static)
find_package(Doxygen)
if (DOXYGEN_FOUND)
add_custom_target(doc
${DOXYGEN_EXECUTABLE} doc/doxygen.conf WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif(DOXYGEN_FOUND)
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -no-pie -pg")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -W -Wall -Wextra -pedantic -Wsuggest-override")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -W -Wall -Wextra -pedantic -Wsuggest-override")
macro(remove_cxx_flag flag)
string(REPLACE "${flag}" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
endmacro()
remove_cxx_flag("-DNDEBUG")
|