-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
114 lines (85 loc) · 2.44 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
cmake_minimum_required(VERSION 2.8)
project(reaper)
## Version ##
set(REAPER_VERSION "v12")
## Options ##
option(CPU_MINING_ONLY "Do not compile the GPU mining part" OFF)
## Global config ##
configure_file(
"${PROJECT_SOURCE_DIR}/CMakeConf.h.in"
"${PROJECT_BINARY_DIR}/CMakeConf.h"
)
## Source files ##
set(SOURCES
App.cpp
AppOpenCL.cpp
Blake512.cpp
CPUMiner.cpp
Config.cpp
Curl.cpp
json_reader.cpp
json_value.cpp
json_writer.cpp
main.cpp
RSHash.cpp
ServerSettings.cpp
SHA256.cpp
Util.cpp
)
set(HEADERS
App.h
AppOpenCL.h
Blake512.h
CPUMiner.h
Config.h
Curl.h
Global.h
RSHash.h
ServerSettings.h
SHA256.h
Util.h
)
## Targets ##
add_executable(reaper ${SOURCES} ${HEADERS})
include_directories(${PROJECT_BINARY_DIR})
set_target_properties(reaper PROPERTIES COMPILE_FLAGS -O2)
## OpenCL detection ##
if(NOT CPU_MINING_ONLY)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
find_library(OPENCL_LIBRARY OpenCL PATHS "$ENV{AMDAPPSDKROOT}/lib/x86_64")
else(CMAKE_SIZEOF_VOID_P EQUAL 8)
find_library(OPENCL_LIBRARY OpenCL PATHS "$ENV{AMDAPPSDKROOT}/lib/x86")
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
if(APPLE)
find_path(OPENCL_INCLUDE_DIR OpenCL/cl.h)
else(APPLE)
find_path(OPENCL_INCLUDE_DIR CL/cl.h PATHS "$ENV{AMDAPPSDKROOT}/include")
endif(APPLE)
mark_as_advanced(OPENCL_INCLUDE_DIR OPENCL_LIBRARY)
include_directories(${OPENCL_INCLUDE_DIR})
endif(NOT CPU_MINING_ONLY)
## Detection of the rest of the libs ##
find_library(PTHREAD_LIBRARY pthread)
find_path(PTHREAD_INCLUDE_DIR NAMES pthread.h)
mark_as_advanced(PTHREAD_LIBRARY PTHREAD_INCLUDE_DIR)
find_library(CURL_LIBRARY curl)
find_path(CURL_INCLUDE_DIR NAMES curl.h PATH_SUFFIXES curl)
mark_as_advanced(CURL_LIBRARY CURL_INCLUDE_DIR)
include_directories(${PTHREAD_INCLUDE_DIR} ${CURL_INCLUDE_DIR})
link_directories(${PTHREAD_LIBRARY} ${CURL_LIBRARY})
## Library configuration ##
if(CPU_MINING_ONLY)
target_link_libraries(reaper ${PTHREAD_LIBRARY} ${CURL_LIBRARY})
else(CPU_MINING_ONLY)
target_link_libraries(reaper ${PTHREAD_LIBRARY} ${CURL_LIBRARY} ${OPENCL_LIBRARY})
endif(CPU_MINING_ONLY)
## Make MSVC use Runtime Library: "Multithreaded" instead of "Multithreaded DLL"
if(MSVC)
foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/MD")
endforeach(flag_var)
endif(MSVC)