2024-01-28 15:33:45 +00:00
|
|
|
cmake_minimum_required(VERSION 3.10)
|
2021-08-22 10:20:59 +00:00
|
|
|
project(p2pool)
|
|
|
|
|
2024-02-10 22:38:22 +00:00
|
|
|
include(cmake/standard.cmake)
|
|
|
|
|
2024-01-27 20:29:12 +00:00
|
|
|
message(STATUS "Build environment:
|
|
|
|
System processor: ${CMAKE_SYSTEM_PROCESSOR}
|
|
|
|
C compiler: ${CMAKE_C_COMPILER} (${CMAKE_C_COMPILER_ID})
|
|
|
|
CXX compiler: ${CMAKE_CXX_COMPILER} (${CMAKE_CXX_COMPILER_ID})
|
|
|
|
")
|
|
|
|
|
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
|
|
|
2022-02-16 09:43:04 +00:00
|
|
|
option(STATIC_BINARY "Build static binary" OFF)
|
2022-05-31 14:34:33 +00:00
|
|
|
option(STATIC_LIBS "Link libuv and libzmq statically" OFF)
|
2022-03-15 15:56:37 +00:00
|
|
|
option(WITH_RANDOMX "Include the RandomX library in the build. If this is turned off, p2pool will rely on monerod for verifying RandomX hashes" ON)
|
2023-02-07 09:04:37 +00:00
|
|
|
option(WITH_LTO "Use link-time compiler optimization (if linking fails for you, run cmake with -DWITH_LTO=OFF)" ON)
|
2023-03-19 18:13:29 +00:00
|
|
|
option(WITH_UPNP "Include UPnP support. If this is turned off, p2pool will not be able to configure port forwarding on UPnP-enabled routers." ON)
|
2024-02-15 16:43:15 +00:00
|
|
|
option(WITH_GRPC "Include gRPC support. If this is turned off, p2pool will not be able to merge mine with Tari." ON)
|
2021-08-22 10:20:59 +00:00
|
|
|
|
2022-08-23 12:13:09 +00:00
|
|
|
option(DEV_TEST_SYNC "[Developer only] Sync test, stop p2pool after sync is complete" OFF)
|
2023-05-17 21:06:54 +00:00
|
|
|
option(DEV_WITH_TSAN "[Developer only] Compile with thread sanitizer" OFF)
|
2023-05-24 12:16:07 +00:00
|
|
|
option(DEV_WITH_MSAN "[Developer only] Compile with memory sanitizer" OFF)
|
2023-05-25 06:56:10 +00:00
|
|
|
option(DEV_WITH_UBSAN "[Developer only] Compile with undefined behavior sanitizer" OFF)
|
2023-05-25 10:57:06 +00:00
|
|
|
option(DEV_WITH_ASAN "[Developer only] Compile with address sanitizer" OFF)
|
2023-06-15 08:32:05 +00:00
|
|
|
option(DEV_CLANG_TIDY "[Developer only] Compile for clang-tidy" OFF)
|
2023-07-19 11:13:00 +00:00
|
|
|
option(DEV_TRACK_MEMORY "[Developer only] Track memory allocations" OFF)
|
2022-08-23 12:13:09 +00:00
|
|
|
|
2024-01-28 15:33:45 +00:00
|
|
|
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT p2pool)
|
2021-09-05 22:39:19 +00:00
|
|
|
|
2024-02-11 09:52:50 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
|
|
|
set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION 10.0)
|
|
|
|
endif()
|
|
|
|
|
2024-02-15 16:43:15 +00:00
|
|
|
if (WITH_GRPC)
|
|
|
|
add_definitions(-DWITH_GRPC)
|
|
|
|
include(cmake/grpc.cmake)
|
2024-02-10 22:38:22 +00:00
|
|
|
|
2024-02-15 16:43:15 +00:00
|
|
|
add_subdirectory(external/src/Tari)
|
|
|
|
endif()
|
2024-01-27 20:29:12 +00:00
|
|
|
|
2022-03-15 15:56:37 +00:00
|
|
|
if (WITH_RANDOMX)
|
|
|
|
add_definitions(-DWITH_RANDOMX)
|
|
|
|
add_subdirectory(external/src/RandomX)
|
2023-03-19 18:13:29 +00:00
|
|
|
set(LIBS ${LIBS} randomx)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (WITH_UPNP)
|
|
|
|
add_definitions(-DWITH_UPNP)
|
|
|
|
add_subdirectory(external/src/miniupnp/miniupnpc)
|
|
|
|
set(LIBS ${LIBS} libminiupnpc-static)
|
2022-03-15 15:56:37 +00:00
|
|
|
endif()
|
2021-08-22 10:20:59 +00:00
|
|
|
|
2022-08-23 12:13:09 +00:00
|
|
|
if (DEV_TEST_SYNC)
|
|
|
|
add_definitions(-DDEV_TEST_SYNC)
|
|
|
|
endif()
|
|
|
|
|
2023-05-17 21:06:54 +00:00
|
|
|
if (DEV_WITH_TSAN)
|
|
|
|
add_definitions(-DDEV_WITH_TSAN)
|
|
|
|
endif()
|
|
|
|
|
2023-05-24 12:16:07 +00:00
|
|
|
if (DEV_WITH_MSAN)
|
|
|
|
add_definitions(-DDEV_WITH_MSAN)
|
|
|
|
endif()
|
|
|
|
|
2023-05-25 06:56:10 +00:00
|
|
|
if (DEV_WITH_UBSAN)
|
|
|
|
add_definitions(-DDEV_WITH_UBSAN)
|
|
|
|
endif()
|
|
|
|
|
2023-05-25 10:57:06 +00:00
|
|
|
if (DEV_WITH_ASAN)
|
|
|
|
add_definitions(-DDEV_WITH_ASAN)
|
|
|
|
endif()
|
|
|
|
|
2023-06-15 08:32:05 +00:00
|
|
|
if (DEV_CLANG_TIDY)
|
|
|
|
add_definitions(-DDEV_CLANG_TIDY)
|
|
|
|
endif()
|
|
|
|
|
2023-07-19 11:13:00 +00:00
|
|
|
if (DEV_TRACK_MEMORY)
|
|
|
|
add_definitions(-DDEV_TRACK_MEMORY)
|
|
|
|
endif()
|
|
|
|
|
2021-08-22 10:20:59 +00:00
|
|
|
include(cmake/flags.cmake)
|
|
|
|
|
|
|
|
set(HEADERS
|
2023-10-24 10:23:06 +00:00
|
|
|
external/src/crypto/sha256.h
|
2021-08-22 10:20:59 +00:00
|
|
|
external/src/cryptonote/crypto-ops.h
|
2022-12-19 08:58:43 +00:00
|
|
|
external/src/hardforks/hardforks.h
|
2021-08-24 09:42:41 +00:00
|
|
|
src/block_cache.h
|
2021-08-22 10:20:59 +00:00
|
|
|
src/block_template.h
|
|
|
|
src/common.h
|
|
|
|
src/console_commands.h
|
|
|
|
src/crypto.h
|
|
|
|
src/json_parsers.h
|
|
|
|
src/json_rpc_request.h
|
|
|
|
src/keccak.h
|
|
|
|
src/log.h
|
|
|
|
src/mempool.h
|
2023-11-01 18:49:44 +00:00
|
|
|
src/merge_mining_client.h
|
2024-02-05 19:22:15 +00:00
|
|
|
src/merge_mining_client_json_rpc.h
|
2023-10-21 17:00:30 +00:00
|
|
|
src/merkle.h
|
2021-08-22 10:20:59 +00:00
|
|
|
src/p2p_server.h
|
|
|
|
src/p2pool.h
|
2021-09-01 11:49:58 +00:00
|
|
|
src/p2pool_api.h
|
2021-08-22 10:20:59 +00:00
|
|
|
src/params.h
|
|
|
|
src/pool_block.h
|
|
|
|
src/pool_block_parser.inl
|
|
|
|
src/pow_hash.h
|
|
|
|
src/side_chain.h
|
|
|
|
src/stratum_server.h
|
|
|
|
src/tcp_server.h
|
|
|
|
src/util.h
|
|
|
|
src/uv_util.h
|
|
|
|
src/wallet.h
|
|
|
|
src/zmq_reader.h
|
|
|
|
)
|
|
|
|
|
|
|
|
set(SOURCES
|
2023-10-24 10:23:06 +00:00
|
|
|
external/src/crypto/sha256.c
|
2021-08-22 10:20:59 +00:00
|
|
|
external/src/cryptonote/crypto-ops-data.c
|
|
|
|
external/src/cryptonote/crypto-ops.c
|
2022-12-19 08:58:43 +00:00
|
|
|
external/src/hardforks/hardforks.cpp
|
2021-08-24 09:42:41 +00:00
|
|
|
src/block_cache.cpp
|
2021-08-22 10:20:59 +00:00
|
|
|
src/block_template.cpp
|
|
|
|
src/console_commands.cpp
|
|
|
|
src/crypto.cpp
|
|
|
|
src/json_rpc_request.cpp
|
|
|
|
src/keccak.cpp
|
|
|
|
src/log.cpp
|
|
|
|
src/main.cpp
|
2021-08-26 21:27:05 +00:00
|
|
|
src/memory_leak_debug.cpp
|
2021-08-22 10:20:59 +00:00
|
|
|
src/mempool.cpp
|
2023-11-01 18:49:44 +00:00
|
|
|
src/merge_mining_client.cpp
|
2024-02-05 19:22:15 +00:00
|
|
|
src/merge_mining_client_json_rpc.cpp
|
2023-10-21 17:00:30 +00:00
|
|
|
src/merkle.cpp
|
2021-08-22 10:20:59 +00:00
|
|
|
src/p2p_server.cpp
|
|
|
|
src/p2pool.cpp
|
2021-09-01 11:49:58 +00:00
|
|
|
src/p2pool_api.cpp
|
2021-08-22 10:20:59 +00:00
|
|
|
src/params.cpp
|
|
|
|
src/pool_block.cpp
|
|
|
|
src/pow_hash.cpp
|
|
|
|
src/side_chain.cpp
|
|
|
|
src/stratum_server.cpp
|
2023-04-19 09:36:12 +00:00
|
|
|
src/tcp_server.cpp
|
2021-08-22 10:20:59 +00:00
|
|
|
src/util.cpp
|
|
|
|
src/wallet.cpp
|
|
|
|
src/zmq_reader.cpp
|
|
|
|
)
|
|
|
|
|
2022-03-15 15:56:37 +00:00
|
|
|
if (WITH_RANDOMX)
|
|
|
|
set(HEADERS ${HEADERS} src/miner.h)
|
|
|
|
set(SOURCES ${SOURCES} src/miner.cpp)
|
|
|
|
endif()
|
|
|
|
|
2024-02-15 16:43:15 +00:00
|
|
|
if (WITH_GRPC)
|
|
|
|
set(HEADERS ${HEADERS} src/merge_mining_client_tari.h)
|
|
|
|
set(SOURCES ${SOURCES} src/merge_mining_client_tari.cpp)
|
|
|
|
endif()
|
|
|
|
|
2024-01-27 20:29:12 +00:00
|
|
|
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" PREFIX "Header Files" FILES ${HEADERS})
|
|
|
|
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" PREFIX "Source Files" FILES ${SOURCES})
|
|
|
|
|
2023-06-16 13:51:33 +00:00
|
|
|
if (NOT ((CMAKE_CXX_COMPILER_ID MATCHES MSVC) OR STATIC_BINARY OR STATIC_LIBS))
|
2022-08-23 12:13:09 +00:00
|
|
|
include(FindCURL)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (CURL_INCLUDE_DIRS)
|
2022-10-03 18:05:33 +00:00
|
|
|
include_directories(${CURL_INCLUDE_DIRS})
|
2022-08-23 12:13:09 +00:00
|
|
|
else()
|
|
|
|
include_directories(external/src/curl/include)
|
|
|
|
endif()
|
|
|
|
|
2022-11-14 19:59:11 +00:00
|
|
|
if ((CMAKE_CXX_COMPILER_ID MATCHES MSVC) OR STATIC_BINARY OR STATIC_LIBS)
|
|
|
|
set(UV_INCLUDE_DIR external/src/libuv/include)
|
|
|
|
set(ZMQ_INCLUDE_DIR external/src/libzmq/include)
|
|
|
|
else()
|
|
|
|
find_path(UV_INCLUDE_DIR NAMES uv.h PATH_SUFFIXES "include")
|
|
|
|
find_path(ZMQ_INCLUDE_DIR NAMES zmq.h PATH_SUFFIXES "include")
|
|
|
|
endif()
|
|
|
|
|
2021-08-22 10:20:59 +00:00
|
|
|
include_directories(src)
|
|
|
|
include_directories(external/src)
|
2023-10-24 12:13:36 +00:00
|
|
|
include_directories(external/src/crypto)
|
2021-08-22 10:20:59 +00:00
|
|
|
include_directories(external/src/cryptonote)
|
2022-11-14 19:59:11 +00:00
|
|
|
include_directories(${UV_INCLUDE_DIR})
|
2021-08-22 10:20:59 +00:00
|
|
|
include_directories(external/src/cppzmq)
|
2022-11-14 19:59:11 +00:00
|
|
|
include_directories(${ZMQ_INCLUDE_DIR})
|
2022-03-15 15:56:37 +00:00
|
|
|
if (WITH_RANDOMX)
|
|
|
|
include_directories(external/src/RandomX/src)
|
|
|
|
endif()
|
2021-09-05 15:30:21 +00:00
|
|
|
include_directories(external/src/rapidjson/include)
|
2021-10-22 16:18:38 +00:00
|
|
|
include_directories(external/src/robin-hood-hashing/src/include)
|
2023-03-19 18:13:29 +00:00
|
|
|
if (WITH_UPNP)
|
|
|
|
include_directories(external/src/miniupnp/miniupnpc/include)
|
|
|
|
endif()
|
2021-08-22 10:20:59 +00:00
|
|
|
|
|
|
|
if (WIN32)
|
2023-05-26 16:32:29 +00:00
|
|
|
set(LIBS ${LIBS} ws2_32 iphlpapi userenv psapi dnsapi dbghelp)
|
2022-09-25 18:41:10 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
|
|
|
set(LIBS ${LIBS} bcrypt)
|
|
|
|
endif()
|
2022-06-04 11:16:05 +00:00
|
|
|
add_definitions(-DCURL_STATICLIB)
|
2023-08-31 14:21:59 +00:00
|
|
|
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
|
|
|
add_definitions(-D_WIN32_WINNT=0x0600)
|
2022-04-05 17:05:15 +00:00
|
|
|
elseif (CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
|
|
|
|
set(LIBS ${LIBS} pthread)
|
2021-08-23 12:48:53 +00:00
|
|
|
elseif (NOT APPLE)
|
2023-01-26 14:45:41 +00:00
|
|
|
set(LIBS ${LIBS} pthread)
|
2021-08-22 10:20:59 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
2024-01-29 10:58:41 +00:00
|
|
|
find_library(ZMQ_LIBRARY_DEBUG NAMES libzmq-v142-mt-sgd-4_3_6 PATHS "external/lib/libzmq/Debug")
|
|
|
|
find_library(ZMQ_LIBRARY NAMES libzmq-v142-mt-s-4_3_6 PATHS "external/lib/libzmq/Release")
|
2023-05-26 16:32:29 +00:00
|
|
|
find_library(UV_LIBRARY_DEBUG NAMES libuv PATHS "external/lib/libuv/Debug")
|
|
|
|
find_library(UV_LIBRARY NAMES libuv PATHS "external/lib/libuv/Release")
|
2023-05-26 17:14:00 +00:00
|
|
|
find_library(CURL_LIBRARY_DEBUG NAMES libcurl-d PATHS "external/lib/libcurl/Debug")
|
2022-06-04 11:16:05 +00:00
|
|
|
find_library(CURL_LIBRARY NAMES libcurl PATHS "external/lib/libcurl/Release")
|
2022-09-14 16:05:28 +00:00
|
|
|
add_definitions(-D_DISABLE_VECTOR_ANNOTATION)
|
|
|
|
add_definitions(-D_DISABLE_STRING_ANNOTATION)
|
2021-08-23 09:21:11 +00:00
|
|
|
elseif (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
2021-08-31 21:17:45 +00:00
|
|
|
find_library(ZMQ_LIBRARY_DEBUG NAMES zmq libzmq.a)
|
|
|
|
find_library(ZMQ_LIBRARY NAMES zmq libzmq.a)
|
|
|
|
find_library(UV_LIBRARY_DEBUG NAMES uv libuv.a)
|
|
|
|
find_library(UV_LIBRARY NAMES uv libuv.a)
|
2022-06-04 11:16:05 +00:00
|
|
|
if (WIN32)
|
2024-02-02 14:26:20 +00:00
|
|
|
find_library(CURL_LIBRARY_DEBUG NAMES libcurl.a PATHS "external/src/curl/lib" NO_DEFAULT_PATH)
|
|
|
|
find_library(CURL_LIBRARY NAMES libcurl.a PATHS "external/src/curl/lib" NO_DEFAULT_PATH)
|
2022-06-04 11:16:05 +00:00
|
|
|
else()
|
2022-08-23 12:13:09 +00:00
|
|
|
if (CURL_LIBRARIES)
|
|
|
|
set(CURL_LIBRARY_DEBUG ${CURL_LIBRARIES})
|
|
|
|
set(CURL_LIBRARY ${CURL_LIBRARIES})
|
|
|
|
else()
|
|
|
|
find_library(CURL_LIBRARY_DEBUG NAMES curl)
|
|
|
|
find_library(CURL_LIBRARY NAMES curl)
|
|
|
|
endif()
|
2022-06-04 11:16:05 +00:00
|
|
|
endif()
|
2022-03-18 13:53:30 +00:00
|
|
|
find_library(SODIUM_LIBRARY sodium)
|
2021-08-22 10:20:59 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
find_library(PGM_LIBRARY pgm)
|
|
|
|
find_library(NORM_LIBRARY norm)
|
|
|
|
|
|
|
|
if (PGM_LIBRARY)
|
|
|
|
set(LIBS ${LIBS} ${PGM_LIBRARY})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NORM_LIBRARY)
|
|
|
|
set(LIBS ${LIBS} ${NORM_LIBRARY})
|
|
|
|
endif()
|
|
|
|
|
2022-03-18 13:53:30 +00:00
|
|
|
if (SODIUM_LIBRARY)
|
|
|
|
set(LIBS ${LIBS} ${SODIUM_LIBRARY})
|
|
|
|
endif()
|
|
|
|
|
2022-06-04 11:16:05 +00:00
|
|
|
if(APPLE)
|
|
|
|
find_library(FOUNDATION_LIB Foundation)
|
|
|
|
find_library(CORE_FOUNDATION_LIB CoreFoundation)
|
|
|
|
find_library(SYSTEM_CONFIGURATION_LIB SystemConfiguration)
|
|
|
|
set(LIBS ${LIBS} ${FOUNDATION_LIB} ${CORE_FOUNDATION_LIB} ${SYSTEM_CONFIGURATION_LIB})
|
|
|
|
endif()
|
|
|
|
|
2021-08-22 10:20:59 +00:00
|
|
|
add_definitions(/DZMQ_STATIC)
|
|
|
|
|
2022-05-09 09:25:52 +00:00
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
|
|
|
|
check_cxx_source_compiles("int main(){ return __builtin_clzll(1);}" HAVE_BUILTIN_CLZLL)
|
2024-01-27 20:29:12 +00:00
|
|
|
check_cxx_source_compiles("#include <intrin.h>\n#pragma intrinsic(_BitScanReverse64)\nint main(){unsigned long r;_BitScanReverse64(&r,1);return static_cast<int>(r);}" HAVE_BITSCANREVERSE64)
|
2022-12-17 11:52:08 +00:00
|
|
|
check_cxx_source_compiles("#include <sched.h>\nint main(){sched_param param;return sched_setscheduler(0, SCHED_IDLE, ¶m);}" HAVE_SCHED)
|
2022-05-09 09:25:52 +00:00
|
|
|
|
2023-05-10 19:22:51 +00:00
|
|
|
include(CheckCSourceCompiles)
|
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES "resolv")
|
|
|
|
|
2023-05-11 08:32:37 +00:00
|
|
|
check_c_source_compiles("int main() { return 0; }" HAVE_RESOLV_LIB)
|
|
|
|
|
|
|
|
if (NOT HAVE_RESOLV_LIB)
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
endif()
|
|
|
|
|
2023-05-10 19:22:51 +00:00
|
|
|
check_c_source_compiles("
|
2023-05-11 06:54:45 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <netinet/in.h>
|
2023-05-10 19:22:51 +00:00
|
|
|
#include <arpa/nameser.h>
|
|
|
|
#include <resolv.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <memory.h>
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
if (argc < 2) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
res_init();
|
|
|
|
|
|
|
|
uint8_t answer[4096];
|
|
|
|
const int anslen = res_query(argv[1], ns_c_in, ns_t_txt, answer, sizeof(answer));
|
|
|
|
|
|
|
|
if (anslen > (int) sizeof(answer)) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ns_msg handle;
|
|
|
|
ns_initparse(answer, anslen, &handle);
|
|
|
|
|
|
|
|
for (int rrnum = 0, n = ns_msg_count(handle, ns_s_an); rrnum < n; ++rrnum) {
|
|
|
|
ns_rr rr;
|
|
|
|
if ((ns_parserr(&handle, ns_s_an, rrnum, &rr) == 0) && (ns_rr_type(rr) == ns_t_txt)) {
|
2023-05-12 13:12:50 +00:00
|
|
|
for (const uint8_t* data = ns_rr_rdata(rr), *e = data + ns_rr_rdlen(rr); data < e;) {
|
|
|
|
const int k = *(data++);
|
|
|
|
if (k && (data + k <= e)) {
|
|
|
|
char buf[256];
|
|
|
|
memcpy(buf, data, k);
|
|
|
|
buf[k] = 0;
|
|
|
|
puts(buf);
|
|
|
|
}
|
|
|
|
data += k;
|
2023-05-11 06:54:45 +00:00
|
|
|
}
|
2023-05-10 19:22:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}" HAVE_RES_QUERY)
|
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
|
2022-05-09 09:25:52 +00:00
|
|
|
if (HAVE_BUILTIN_CLZLL)
|
|
|
|
add_definitions(/DHAVE_BUILTIN_CLZLL)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (HAVE_BITSCANREVERSE64)
|
|
|
|
add_definitions(/DHAVE_BITSCANREVERSE64)
|
|
|
|
endif()
|
|
|
|
|
2022-12-17 11:52:08 +00:00
|
|
|
if (HAVE_SCHED)
|
|
|
|
add_definitions(/DHAVE_SCHED)
|
|
|
|
endif()
|
|
|
|
|
2023-05-10 19:22:51 +00:00
|
|
|
if (HAVE_RES_QUERY)
|
|
|
|
add_definitions(/DHAVE_RES_QUERY)
|
2023-05-11 08:32:37 +00:00
|
|
|
if (HAVE_RESOLV_LIB)
|
|
|
|
set(LIBS ${LIBS} resolv)
|
|
|
|
endif()
|
2023-05-10 19:22:51 +00:00
|
|
|
endif()
|
|
|
|
|
2023-06-12 13:29:23 +00:00
|
|
|
add_definitions("-DRAPIDJSON_PARSE_DEFAULT_FLAGS=kParseTrailingCommasFlag")
|
|
|
|
|
2021-08-22 10:20:59 +00:00
|
|
|
add_executable(${CMAKE_PROJECT_NAME} ${HEADERS} ${SOURCES})
|
|
|
|
|
2022-05-31 14:34:33 +00:00
|
|
|
if (STATIC_BINARY OR STATIC_LIBS)
|
2023-05-25 10:57:06 +00:00
|
|
|
if (NOT (DEV_WITH_TSAN OR DEV_WITH_MSAN OR DEV_WITH_UBSAN OR DEV_WITH_ASAN))
|
2023-05-24 14:02:10 +00:00
|
|
|
if (WIN32)
|
|
|
|
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} "${CMAKE_PROJECT_NAME}.exe")
|
|
|
|
else()
|
|
|
|
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} ${CMAKE_PROJECT_NAME})
|
|
|
|
endif()
|
2022-06-04 11:16:05 +00:00
|
|
|
endif()
|
2021-08-22 10:20:59 +00:00
|
|
|
|
2023-08-15 11:31:28 +00:00
|
|
|
set(STATIC_LIBS "")
|
|
|
|
|
2022-03-15 15:56:37 +00:00
|
|
|
if (WITH_RANDOMX)
|
|
|
|
set(STATIC_LIBS randomx)
|
|
|
|
endif()
|
|
|
|
|
2023-03-19 22:55:22 +00:00
|
|
|
if (WITH_UPNP)
|
|
|
|
set(STATIC_LIBS ${STATIC_LIBS} libminiupnpc-static)
|
|
|
|
endif()
|
|
|
|
|
2022-06-04 11:16:05 +00:00
|
|
|
if (WIN32)
|
2023-05-26 17:14:00 +00:00
|
|
|
set(STATIC_LIBS ${STATIC_LIBS} ws2_32 iphlpapi userenv psapi dnsapi dbghelp)
|
2023-08-15 11:31:28 +00:00
|
|
|
if ((CMAKE_CXX_COMPILER_ID MATCHES GNU) OR (CMAKE_CXX_COMPILER_ID MATCHES Clang))
|
2022-09-25 18:41:10 +00:00
|
|
|
set(STATIC_LIBS ${STATIC_LIBS} bcrypt)
|
|
|
|
endif()
|
2022-06-04 11:16:05 +00:00
|
|
|
elseif (CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
|
2022-04-05 17:05:15 +00:00
|
|
|
set(STATIC_LIBS ${STATIC_LIBS} pthread)
|
2022-06-04 11:16:05 +00:00
|
|
|
elseif (APPLE)
|
|
|
|
find_library(FOUNDATION_LIB Foundation)
|
|
|
|
find_library(CORE_FOUNDATION_LIB CoreFoundation)
|
|
|
|
find_library(SYSTEM_CONFIGURATION_LIB SystemConfiguration)
|
|
|
|
set(STATIC_LIBS ${STATIC_LIBS} ${FOUNDATION_LIB} ${CORE_FOUNDATION_LIB} ${SYSTEM_CONFIGURATION_LIB})
|
|
|
|
else()
|
2023-01-26 14:45:41 +00:00
|
|
|
set(STATIC_LIBS ${STATIC_LIBS} pthread)
|
2022-02-16 09:43:04 +00:00
|
|
|
endif()
|
|
|
|
|
2023-05-11 08:32:37 +00:00
|
|
|
if (HAVE_RES_QUERY AND HAVE_RESOLV_LIB)
|
2023-05-10 19:22:51 +00:00
|
|
|
set(STATIC_LIBS ${STATIC_LIBS} resolv)
|
|
|
|
endif()
|
|
|
|
|
2024-02-15 16:43:15 +00:00
|
|
|
if (WITH_GRPC)
|
|
|
|
set(STATIC_LIBS ${STATIC_LIBS} Tari_gRPC grpc grpc++ libprotobuf)
|
|
|
|
endif()
|
2024-02-10 22:38:22 +00:00
|
|
|
|
2021-08-22 10:20:59 +00:00
|
|
|
target_link_libraries(${CMAKE_PROJECT_NAME}
|
|
|
|
"${CMAKE_SOURCE_DIR}/external/src/libzmq/build/lib/libzmq.a"
|
2023-05-26 16:32:29 +00:00
|
|
|
"${CMAKE_SOURCE_DIR}/external/src/libuv/build/libuv.a"
|
2024-02-02 14:26:20 +00:00
|
|
|
"${CMAKE_SOURCE_DIR}/external/src/curl/lib/libcurl.a"
|
2022-02-16 09:43:04 +00:00
|
|
|
${STATIC_LIBS}
|
2021-08-22 10:20:59 +00:00
|
|
|
)
|
|
|
|
else()
|
2024-02-15 18:25:31 +00:00
|
|
|
if (WITH_GRPC)
|
|
|
|
set(LIBS ${LIBS} Tari_gRPC grpc grpc++ libprotobuf)
|
|
|
|
endif()
|
|
|
|
|
2022-06-04 11:16:05 +00:00
|
|
|
target_link_libraries(${CMAKE_PROJECT_NAME} debug ${ZMQ_LIBRARY_DEBUG} debug ${UV_LIBRARY_DEBUG} debug ${CURL_LIBRARY_DEBUG} optimized ${ZMQ_LIBRARY} optimized ${UV_LIBRARY} optimized ${CURL_LIBRARY} ${LIBS})
|
2021-08-22 10:20:59 +00:00
|
|
|
endif()
|
2023-09-06 13:31:12 +00:00
|
|
|
|
|
|
|
message(STATUS "Summary of build options:
|
|
|
|
C compiler: ${CMAKE_C_COMPILER} (${CMAKE_C_COMPILER_ID})
|
|
|
|
CXX compiler: ${CMAKE_CXX_COMPILER} (${CMAKE_CXX_COMPILER_ID})
|
|
|
|
C_FLAGS: ${CMAKE_C_FLAGS}
|
|
|
|
CXX_FLAGS: ${CMAKE_CXX_FLAGS}
|
|
|
|
")
|