forked from thbaumbach/primecoin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
253 lines (220 loc) · 7.22 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0)
###
### FIND ADDITIONAL CMAKE MODULES
###
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
###
### PROJECT
###
PROJECT(xolominer)
###
### CONFIG
###
IF(NOT BITNESS) # Auto-select bitness based on platform
IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(BITNESS 64)
ELSE()
SET(BITNESS 32)
ENDIF()
ENDIF()
#select bitness for non-msvc platform. Can be specified as -DBITNESS=32/64 at command-line
IF(NOT MSVC)
SET(BITNESS ${BITNESS} CACHE STRING "Specify bitness, use -DBITNESS=32/64")
SET_PROPERTY(CACHE BITNESS PROPERTY STRINGS "64" "32")
endif()
#unset OPENCL_LIBRARIES, so that corresponding arch specific libs are found when bitness is changed
UNSET(OPENCL_LIBRARIES CACHE)
IF(BITNESS EQUAL 64)
SET(BITNESS_SUFFIX x86_64)
ELSEIF(BITNESS EQUAL 32)
SET(BITNESS_SUFFIX x86)
ELSE()
MESSAGE(FATAL_ERROR "Bitness specified is invalid")
ENDIF()
#set platform
IF(NOT UNIX)
SET(PLATFORM win)
ELSE()
SET(PLATFORM lnx)
ENDIF()
###
### OPENCL (new)
###
#find OpenCL include and libs
FIND_PATH(OPENCL_INCLUDE_DIRS
NAMES OpenCL/cl.h CL/cl.h
HINTS ../../../../include/ $ENV{AMDAPPSDKROOT}/include/
)
MARK_AS_ADVANCED(OPENCL_INCLUDE_DIRS)
FIND_LIBRARY(OPENCL_LIBRARIES
NAMES OpenCL
HINTS ../../../../lib/ $ENV{AMDAPPSDKROOT}/lib
PATH_SUFFIXES ${PLATFORM}${BITNESS} ${BITNESS_SUFFIX}
)
MARK_AS_ADVANCED(OPENCL_LIBRARIES)
IF(OPENCL_INCLUDE_DIRS STREQUAL "" OR OPENCL_LIBRARIES STREQUAL "")
MESSAGE(FATAL_ERROR "Could not locate OpenCL include & libs")
ELSE()
MESSAGE("OpenCL information: CPP bindings found")
MESSAGE(" OPENCL_INCLUDE_DIRS: ${OPENCL_INCLUDE_DIRS}")
MESSAGE(" OPENCL_LIBRARIES: ${OPENCL_LIBRARIES}")
ENDIF()
#tweaks for cygwin makefile to work with windows-style path
IF(CYGWIN)
SET(PATHS_TO_CONVERT
OPENCL_INCLUDE_DIRS
OPENCL_LIBRARIES
)
FOREACH(pathVar ${PATHS_TO_CONVERT})
#convert windows paths to cyg linux absolute path
EXECUTE_PROCESS(COMMAND cygpath -ua ${${pathVar}}
OUTPUT_VARIABLE ${pathVar}
OUTPUT_STRIP_TRAILING_WHITESPACE
)
ENDFOREACH(pathVar)
ENDIF()
INCLUDE_DIRECTORIES(${OPENCL_INCLUDE_DIRS})
#gcc/g++ specific compile options
SET(COMPILER_FLAGS " ")
SET(LINKER_FLAGS " ")
SET(ADDITIONAL_LIBRARIES "")
IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
SET( COMPILER_FLAGS "${COMPILER_FLAGS} -msse2 ")
# Note: "rt" is not present on mingw
IF(UNIX)
#if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# set( COMPILER_FLAGS " -g " )
#endif( )
SET(ADDITIONAL_LIBRARIES ${ADDITIONAL_LIBRARIES} "rt")
ENDIF()
IF(BITNESS EQUAL 32)
SET(COMPILER_FLAGS "${COMPILER_FLAGS} -m32 ")
SET(LINKER_FLAGS "${LINKER_FLAGS} -m32 ")
ELSE()
SET(COMPILER_FLAGS "${COMPILER_FLAGS} -m64 ")
SET(LINKER_FLAGS "${LINKER_FLAGS} -m64 ")
ENDIF()
SET(COMPILER_FLAGS "${COMPILER_FLAGS} ${EXTRA_COMPILER_FLAGS_GXX} ")
SET(LINKER_FLAGS "${LINKER_FLAGS} ${EXTRA_LINKER_FLAGS_GXX} ")
SET(ADDITIONAL_LIBRARIES ${ADDITIONAL_LIBRARIES} ${EXTRA_LIBRARIES_GXX})
ENDIF()
###
### OPENCL (old)
###
#FIND_PACKAGE(OpenCL REQUIRED)
#INCLUDE_DIRECTORIES(${OPENCL_INCLUDE_DIRS})
#if(OPENCL_HAS_CPP_BINDINGS)
# MESSAGE("OpenCL information: CPP bindings found")
# MESSAGE(" OPENCL_INCLUDE_DIRS: ${OPENCL_INCLUDE_DIRS}")
# MESSAGE(" OPENCL_LIBRARIES: ${OPENCL_LIBRARIES}")
#else(OPENCL_HAS_CPP_BINDINGS)
# MESSAGE("OpenCL information: CPP bindings -NOT- found")
#endif(OPENCL_HAS_CPP_BINDINGS)
###
### OPENSSL
###
FIND_PACKAGE(OpenSSL REQUIRED)
IF(OPENSSL_FOUND)
MESSAGE("OpenSSL information: found")
MESSAGE(" OpenSSL_INCLUDE_DIR: ${OpenSSL_INCLUDE_DIR}")
MESSAGE(" OpenSSL_LIBRARIES: ${OpenSSL_LIBRARIES}")
INCLUDE_DIRECTORIES(${OpenSSL_INCLUDE_DIR})
ELSE(OPENSSL_FOUND)
MESSAGE(FATAL_ERROR "OpenSSL -NOT- found" )
ENDIF(OPENSSL_FOUND)
###
### LIBGMP
###
FIND_PACKAGE(GMP REQUIRED)
IF(GMP_FOUND)
MESSAGE("libGMP information: found")
MESSAGE(" GMP_INCLUDE_DIR: ${GMP_INCLUDE_DIR}")
MESSAGE(" GMP(XX)_LIBRARIES: ${GMP_LIBRARIES} (${GMPXX_LIBRARIES})")
INCLUDE_DIRECTORIES(${GMP_INCLUDE_DIR})
ELSE()
MESSAGE(FATAL_ERROR "libGMP -NOT- found" )
ENDIF()
###
### BOOST
###
SET(Boost_USE_MULTITHREADED ON)
SET(Boost_USE_STATIC_LIBS ON)
#SET(Boost_COMPILER "-gcc43") #set this to the compiler suffix used by Boost if FindBoost has problems
#SET(Boost_ADDITIONAL_VERSIONS "0.99" "0.99.0" "1.78" "1.78.0") #for future boost releases
FIND_PACKAGE(Boost 1.43.0 COMPONENTS system thread timer chrono REQUIRED)
MESSAGE("Boost information: found ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
MESSAGE(" Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
MESSAGE(" Boost_LIBRARY_DIRS: ${Boost_LIBRARY_DIRS}")
MESSAGE(" Boost_LIBRARIES: ${Boost_LIBRARIES}")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
###
### YASM (not needed atm)
###
#IF(APPLE)
# set(CMAKE_ASM_FLAGS "-f macho64 --prefix=_") #TODO: 32 BIT?
#ELSE(UNIX)
# SET(CMAKE_ASM_FLAGS "-f elf64") #TODO: 32 BIT?
#ELSE()
# SET(CMAKE_ASM_FLAGS "-f win64") #TODO: 32 BIT?
#ENDIF()
#
#SET(CMAKE_ASM_COMPILER "yasm")
#ENABLE_LANGUAGE(ASM)
###
### GENERAL SOURCE STUFF
###
INCLUDE_DIRECTORIES("src")
SET(SRC_FILES
src/sha256.cpp
src/primes.cpp
src/prime.cpp
src/main_config.cpp
src/main_mining.cpp
src/main_poolminer.cpp
src/xpmclient.cpp
)
CONFIGURE_FILE(src/gpu/fermat.cl ${CMAKE_BINARY_DIR}/gpu/fermat.cl COPYONLY)
CONFIGURE_FILE(src/gpu/sha256.cl ${CMAKE_BINARY_DIR}/gpu/sha256.cl COPYONLY)
CONFIGURE_FILE(src/gpu/sieve.cl ${CMAKE_BINARY_DIR}/gpu/sieve.cl COPYONLY)
###
### EXECUTABLE
###
ADD_EXECUTABLE(xolominer
${SRC_FILES}
)
SET_TARGET_PROPERTIES(xolominer PROPERTIES
COMPILE_FLAGS ${COMPILER_FLAGS}
LINK_FLAGS ${LINKER_FLAGS}
)
###
### LIBRARIES
###
#TARGET_LINK_LIBRARIES(xolominer ${Boost_SYSTEM_LIBRARY})
#TARGET_LINK_LIBRARIES(xolominer ${Boost_THREAD_LIBRARY})
#TARGET_LINK_LIBRARIES(xolominer ${Boost_TIMER_LIBRARY})
#TARGET_LINK_LIBRARIES(xolominer ${Boost_CHRONO_LIBRARY})
TARGET_LINK_LIBRARIES(xolominer ${Boost_LIBRARIES})
TARGET_LINK_LIBRARIES(xolominer ${GMP_LIBRARIES})
TARGET_LINK_LIBRARIES(xolominer ${GMPXX_LIBRARIES})
TARGET_LINK_LIBRARIES(xolominer ${OpenSSL_LIBRARIES})
TARGET_LINK_LIBRARIES(xolominer ${OPENCL_LIBRARIES})
TARGET_LINK_LIBRARIES(xolominer ${ADDITIONAL_LIBRARIES})
TARGET_LINK_LIBRARIES(xolominer "pthread")
IF(WIN32) #<MINGW>
TARGET_LINK_LIBRARIES(xolominer "ws2_32")
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
SET(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++") #TODO: boost -> libwinpthread?
# TARGET_LINK_LIBRARIES(xolominer "mswsock") #needed? no.
# TARGET_LINK_LIBRARIES(xolominer "shlwapi") #needed? no.
# TARGET_LINK_LIBRARIES(xolominer "-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -Wl,--dynamicbase -Wl,--nxcompat -static") #needed? no.
ELSEIF(UNIX)
TARGET_LINK_LIBRARIES(xolominer "rt") # -NOT- APPLE !?!
ENDIF()
###
### COMMON FLAGS
###
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGLIBC_XX_DEBUG -Wall -ggdb -g3 -fno-rounding-math -msse -O0")
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") # DEBUG/RELEASE flags omitted atm (for simplification)
#SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
#SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DGLIBC_XX_DEBUG -Wall -ggdb -g3 -fno-rounding-math -msse -O0")