-
Notifications
You must be signed in to change notification settings - Fork 130
/
CMakeLists.txt
133 lines (111 loc) · 3.04 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
cmake_minimum_required(VERSION 3.2)
project(xdag)
# Use a different compiler
# http://www.cmake.org/Wiki/CMake_FAQ#How_do_I_use_a_different_compiler.3F
# it must be done before any language is set (before project|enable_language command)
# set(CMAKE_C_COMPILER "gcc-7")
# set(CMAKE_CXX_COMPILER "g++-7")
# usually avoid this by using environment variables:
# mkdir build-gcc && cd build-gcc && CC=gcc-7 CXX=g++-7 cmake ..
enable_language(C ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_FLAGS "-std=gnu11 -O3 -g -Wall -Wmissing-prototypes -Wno-unused-result")
#set(ENV{PKG_CONFIG_PATH} secp256k1)
if ( NOT DEFINED ENV{SECP256K1_ROOT_DIR})
find_package(PkgConfig)
pkg_search_module(SECP256K1 REQUIRED libsecp256k1)
endif()
MESSAGE(STATUS ${SECP256K1_INCLUDE_DIRS})
MESSAGE(STATUS ${SECP256K1_LIBRARIES})
MESSAGE(STATUS ${SECP256K1_LIBDIR})
if (APPLE AND NOT DEFINED ENV{OPENSSL_ROOT_DIR})
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl" "/usr/local/ssl/*" "/usr/local/Cellar/openssl/*")
set(OPENSSL_LIBRARIES "/usr/local/opt/openssl/lib" "/usr/local/ssl/*/lib" "/usr/local/Cellar/openssl/*/lib")
endif()
set(RANDOMX_LIBDIR "/usr/lib" "/usr/local/lib")
set(RANDOMX_LIBRARIES "randomx")
file(GLOB_RECURSE DAGGER_SOURCES
client/*.c
dfslib/*.c
dnet/*.c
ldus/*.c
)
# ignore sources that we do not intend to include
# when building the executable...
list(FILTER DAGGER_SOURCES EXCLUDE REGEX ".*cgi.c$")
list(FILTER DAGGER_SOURCES EXCLUDE REGEX ".*dvstime.c$")
list(FILTER DAGGER_SOURCES EXCLUDE REGEX ".*statsdaemon.c$")
file(GLOB_RECURSE DAGGER_HEADERS
client/*.h
dfslib/*.h
dnet/*.h
ldus/*.h
)
set(SHA256_LINUX_ASM_SOURCES
client/algorithms/sha256-mb-x86_64.s
client/x86_64cpuid.s
)
set(SHA256_MAC_ASM_SOURCES
client/algorithms/sha256-mb-x86_64-mac.s
client/x86_64cpuid-mac.s
)
OPTION(DEBUG "Build the project using debugging code" OFF)
if(DEBUG)
MESSAGE("Adding Debug flag...")
SET(CMAKE_BUILD_TYPE Debug)
MESSAGE("Build type is " ${CMAKE_BUILD_TYPE})
else()
add_definitions(-DNDEBUG)
endif(DEBUG)
add_definitions(-DDFSTOOLS)
add_definitions(-DSHA256_USE_OPENSSL_TXFM)
add_definitions(-DSHA256_OPENSSL_MBLOCK)
find_package(Threads QUIET)
if(NOT Threads_FOUND)
message(FATAL_ERROR "Failed to find pthreads dependency!")
endif()
find_package(OpenSSL QUIET)
if(NOT OpenSSL_FOUND)
message(FATAL_ERROR "Failed to find openssl dependency!")
endif()
include_directories(
${OPENSSL_INCLUDE_DIR}
${SECP256K1_INCLUDE_DIRS}
)
if(APPLE)
add_executable(
${PROJECT_NAME}
${DAGGER_HEADERS}
${DAGGER_SOURCES}
${SHA256_MAC_ASM_SOURCES}
)
else(UNIX)
add_executable(
${PROJECT_NAME}
${DAGGER_HEADERS}
${DAGGER_SOURCES}
${SHA256_LINUX_ASM_SOURCES}
)
endif()
target_link_libraries(
${PROJECT_NAME}
${CMAKE_THREAD_LIBS_INIT}
)
target_link_libraries(
${PROJECT_NAME}
OpenSSL::SSL
OpenSSL::Crypto
-L${SECP256K1_LIBDIR} ${SECP256K1_LIBRARIES}
-L${RANDOMX_LIBDIR} ${RANDOMX_LIBRARIES}
m
-lstdc++
)
add_executable(
cgi_stats
client/statsdaemon.c
)
add_executable(
cgi_block
client/block.cgi.c
)