-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
143 lines (121 loc) · 4.95 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
cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0048 NEW)
set(VERSION "0.1")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cryptonote/cmake")
# parse project version from cryptonote/src/version.h.in
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/cryptonote/src/version.h.in" VERSION_FILE)
string(REGEX REPLACE ".*APP_VER_MAJOR ([0-9]+).*" "" DUMMY ${VERSION_FILE})
set(VER_MAJOR ${CMAKE_MATCH_1})
string(REGEX REPLACE "APP_VER_MINOR ([0-9]+)" "" DUMMY ${VERSION_FILE})
set(VER_MINOR ${CMAKE_MATCH_1})
string(REGEX REPLACE "APP_VER_REV ([0-9]+)" "" DUMMY ${VERSION_FILE})
set(VER_PATCH ${CMAKE_MATCH_1})
string(REGEX REPLACE "APP_VER_BUILD ([0-9]+)" "" DUMMY ${VERSION_FILE})
set(VER_TWEAK ${CMAKE_MATCH_1})
unset(DUMMY)
message("Version: ${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}.${VER_TWEAK}")
project(TalleoWrapper VERSION ${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}.${VER_TWEAK} LANGUAGES C CXX)
if(CMAKE_TOOLCHAIN_FILE)
message("Toolchain: ${CMAKE_TOOLCHAIN_FILE}")
endif()
message("System: ${CMAKE_SYSTEM_NAME}")
message("Processor: ${CMAKE_SYSTEM_PROCESSOR}")
if(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*|FreeBSD")
set(FREEBSD TRUE)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*")
set(DRAGONFLY TRUE)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
set(OPENBSD TRUE)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
set(NETBSD TRUE)
endif()
if(MSVC)
add_definitions("-EHsc" "-DWIN32" "-DBUILD_DLL")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions("-MTd")
else()
add_definitions("-MT")
endif()
include_directories(${CMAKE_SOURCE_DIR}/cryptonote/src/Platform/Windows)
elseif(APPLE)
add_definitions("-DOSX" "-DPOSIX" "-DBUILD_DLL")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -fvisibility=hidden")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fvisibility=hidden")
include_directories(${CMAKE_SOURCE_DIR}/cryptonote/src/Platform/OSX)
include_directories(${CMAKE_SOURCE_DIR}/cryptonote/src/Platform/Posix)
elseif(FREEBSD OR NETBSD OR OPENBSD)
add_definitions("-DBSD" "-DPOSIX" "-DBUILD_DLL")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -fvisibility=hidden")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fvisibility=hidden")
include_directories(${CMAKE_SOURCE_DIR}/cryptonote/src/Platform/FreeBSD)
include_directories(${CMAKE_SOURCE_DIR}/cryptonote/src/Platform/Posix)
elseif(ANDROID)
add_definitions("-DANDROID" "-DPOSIX" "-DBUILD_DLL")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -fvisibility=hidden")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fvisibility=hidden")
include_directories(${CMAKE_SOURCE_DIR}/cryptonote/src/Platform/Android)
include_directories(${CMAKE_SOURCE_DIR}/cryptonote/src/Platform/Posix)
else()
add_definitions("-DLINUX" "-DPOSIX" "-DBUILD_DLL")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -fvisibility=hidden")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fvisibility=hidden")
include_directories(${CMAKE_SOURCE_DIR}/cryptonote/src/Platform/Linux)
include_directories(${CMAKE_SOURCE_DIR}/cryptonote/src/Platform/Posix)
endif()
find_package(RocksDB)
if(ROCKSDB_FOUND)
include_directories(SYSTEM ${ROCKSDB_INCLUDE_DIRS})
else()
include_directories(${CMAKE_SOURCE_DIR}/cryptonote/external/rocksdb/include)
endif()
# Force find_package(OpenSSL) to search the static library
if(STATIC)
set(OPENSSL_USE_STATIC_LIBS ON)
endif()
if(MSVC)
set(OPENSSL_MSVC_STATIC_RT ON)
endif()
# We have to look for Homebrew OpenSSL a bit differently
# Borrowed from https://github.com/tarantool/tarantool/commit/6eab201af1843f53a833c8928dc58fceffa08147
if(APPLE)
find_program(HOMEBREW_EXECUTABLE brew)
execute_process(COMMAND ${HOMEBREW_EXECUTABLE} --prefix openssl
OUTPUT_VARIABLE HOMEBREW_OPENSSL
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(DEFINED HOMEBREW_OPENSSL)
if(NOT DEFINED OPENSSL_ROOT_DIR)
message(STATUS "Setting OpenSSL root to ${HOMEBREW_OPENSSL}")
set(OPENSSL_ROOT_DIR "${HOMEBREW_OPENSSL}")
endif()
endif()
endif()
find_package(OpenSSL)
if(NOT OPENSSL_FOUND)
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_search_module(OPENSSL openssl)
endif()
endif()
add_subdirectory(cryptonote EXCLUDE_FROM_ALL)
include_directories(include cryptonote cryptonote/include cryptonote/src ${Boost_INCLUDE_DIR})
file(GLOB_RECURSE Wrapper src/*)
add_library(TalleoWrapper SHARED ${Wrapper})
if(ANDROID)
target_link_libraries(TalleoWrapper Common CryptoNoteCore Http Logging Mnemonics NodeRpcProxy Rpc System Wallet Transfers AndroidCompat)
else()
target_link_libraries(TalleoWrapper Common CryptoNoteCore Http Logging Mnemonics NodeRpcProxy Rpc System Wallet Transfers)
endif()
target_link_libraries(TalleoWrapper ${OPENSSL_LIBRARIES})
if(OPENSSL_FOUND)
if(NOT MSVC AND NOT NETBSD)
set(OPENSSL_LIBRARIES "${OPENSSL_LIBRARIES};dl")
endif()
target_link_libraries(TalleoWrapper ${OPENSSL_LIBRARIES})
# prevent error LNK2019: unresolved external symbol _vsnprintf
if(MSVC AND NOT (MSVC_VERSION LESS 1900))
target_link_libraries(TalleoWrapper "legacy_stdio_definitions.lib")
endif()
endif()