This repository has been archived by the owner on Jan 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 583
/
CMakeLists.txt
198 lines (175 loc) · 5.91 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
project(nheqminer)
cmake_minimum_required(VERSION 3.5)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # -Wall
## Enable solvers here
#### older slower
option(USE_CPU_TROMP "USE CPU_TROMP" OFF)
option(USE_CUDA_TROMP "USE CUDA_TROMP" OFF)
#### faster
option(USE_CPU_XENONCAT "USE CPU_XENONCAT" ON)
option(USE_CUDA_DJEZO "USE CUDA_DJEZO" ON)
## Add solvers here
if (USE_CPU_TROMP)
add_definitions(-DUSE_CPU_TROMP)
message("-- USE_CPU_TROMP DEFINED")
endif()
if (USE_CPU_XENONCAT)
add_definitions(-DUSE_CPU_XENONCAT)
message("-- USE_CPU_XENONCAT DEFINED")
endif()
if (USE_CUDA_TROMP)
add_definitions(-DUSE_CUDA_TROMP)
message("-- USE_CUDA_TROMP DEFINED")
endif()
if (USE_CUDA_DJEZO)
add_definitions(-DUSE_CUDA_DJEZO)
message("-- USE_CUDA_DJEZO DEFINED")
endif()
########
# LINUX
if(CMAKE_COMPILER_IS_GNUCXX)
# # use native cpu features
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -fPIC")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -fPIC")
# # optimizations
# add_definitions(-O3)
# use
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64 -msse2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -msse2")
# optimizations
add_definitions(-O2)
endif()
# Common
include_directories(${nheqminer_SOURCE_DIR}/nheqminer)
# BOOST
#find_package(Threads REQUIRED COMPONENTS)
# compile boost staticaly
set(Boost_USE_STATIC_LIBS ON)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
#set(BUILD_SHARED_LIBRARIES OFF)
#set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
find_package(Boost REQUIRED COMPONENTS system log_setup log date_time filesystem thread)
if (Boost_FOUND)
# From the offical documentation:
# Add include directories to the build. [...] If the SYSTEM option is given,
# the compiler will be told the directories are meant as system include
# directories on some platforms (signalling this setting might achieve effects
# such as the compiler skipping warnings [...])."
include_directories (SYSTEM ${Boost_INCLUDE_DIR})
# From the offical documentation:
# "Specify directories in which the linker will look for libraries. [...] Note
# that this command is rarely necessary. Library locations returned by
# find_package() and find_library() are absolute paths. Pass these absolute
# library file paths directly to the target_link_libraries() command. CMake
# will ensure the linker finds them."
link_directories (${Boost_LIBRARY_DIRS})
else()
message("Boost_FOUND NOT FOUND")
endif ()
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../)
set(SOURCE_FILES
# sources
nheqminer/amount.cpp
nheqminer/api.cpp
nheqminer/arith_uint256.cpp
nheqminer/crypto/sha256.cpp
nheqminer/json/json_spirit_reader.cpp
nheqminer/json/json_spirit_value.cpp
nheqminer/json/json_spirit_writer.cpp
nheqminer/libstratum/ZcashStratum.cpp
nheqminer/main.cpp
nheqminer/primitives/block.cpp
nheqminer/speed.cpp
nheqminer/uint256.cpp
nheqminer/utilstrencodings.cpp
# headers
nheqminer/amount.h
nheqminer/api.hpp
nheqminer/arith_uint256.h
nheqminer/crypto/sha256.h
nheqminer/hash.h
nheqminer/json/json_spirit.h
nheqminer/json/json_spirit_error_position.h
nheqminer/json/json_spirit_reader.h
nheqminer/json/json_spirit_reader_template.h
nheqminer/json/json_spirit_stream_reader.h
nheqminer/json/json_spirit_utils.h
nheqminer/json/json_spirit_value.h
nheqminer/json/json_spirit_writer.h
nheqminer/json/json_spirit_writer_template.h
nheqminer/libstratum/StratumClient.cpp
nheqminer/libstratum/StratumClient.h
nheqminer/libstratum/ZcashStratum.cpp
nheqminer/libstratum/ZcashStratum.h
nheqminer/primitives/block.h
nheqminer/primitives/transaction.h
nheqminer/script/script.h
nheqminer/serialize.h
nheqminer/speed.hpp
nheqminer/streams.h
nheqminer/support/allocators/zeroafterfree.h
nheqminer/tinyformat.h
nheqminer/uint252.h
nheqminer/uint256.h
nheqminer/utilstrencodings.h
nheqminer/version.h
nheqminer/zcash/JoinSplit.hpp
nheqminer/zcash/NoteEncryption.hpp
nheqminer/zcash/Proof.hpp
nheqminer/zcash/Zcash.h
nheqminer/SolverStub.h # just a stub
nheqminer/AvailableSolvers.h
nheqminer/ISolver.h
nheqminer/Solver.h
nheqminer/MinerFactory.h
nheqminer/MinerFactory.cpp
# make same path on windows
#blake shared
# src
blake2/blake2bx.cpp
# headers
blake2/blake2.h
blake2/blake2b-load-sse2.h
blake2/blake2b-load-sse41.h
blake2/blake2b-round.h
blake2/blake2-config.h
blake2/blake2-impl.h
blake2/blake2-round.h
)
#set(LIBS ${LIBS} ${Threads_LIBRARIES} ${Boost_LIBRARIES})
set(LIBS ${LIBS} ${Boost_LIBRARIES})
message("-- CXXFLAGS: ${CMAKE_CXX_FLAGS}")
message("-- LIBS: ${LIBS}")
if (USE_CPU_TROMP)
add_subdirectory(cpu_tromp)
endif()
if (USE_CPU_XENONCAT)
add_subdirectory(cpu_xenoncat)
endif()
if (USE_CUDA_TROMP)
add_subdirectory(cuda_tromp)
endif()
if (USE_CUDA_DJEZO)
add_subdirectory(cuda_djezo)
endif()
#add_subdirectory(cpu_xenoncat)
ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCE_FILES})
#target_link_libraries(${PROJECT_NAME} ${LIBS} ${CUDA_LIBRARIES} )
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT} ${LIBS} )
# link libs
if (USE_CPU_TROMP)
target_link_libraries(${PROJECT_NAME} cpu_tromp)
endif()
if (USE_CPU_XENONCAT)
add_library ( xenoncat_avx1 SHARED IMPORTED GLOBAL )
set_target_properties ( xenoncat_avx1 PROPERTIES IMPORTED_LOCATION "../nheqminer/cpu_xenoncat/asm_linux/equihash_avx1.o" )
add_library ( xenoncat_avx2 SHARED IMPORTED GLOBAL )
set_target_properties ( xenoncat_avx2 PROPERTIES IMPORTED_LOCATION "../nheqminer/cpu_xenoncat/asm_linux/equihash_avx2.o" )
target_link_libraries(${PROJECT_NAME} cpu_xenoncat xenoncat_avx1 xenoncat_avx2)
endif()
if (USE_CUDA_TROMP)
target_link_libraries(${PROJECT_NAME} cuda_tromp)
endif()
if (USE_CUDA_DJEZO)
target_link_libraries(${PROJECT_NAME} cuda_djezo)
endif()