2022-06-04 11:16:05 +00:00
|
|
|
cmake_minimum_required(VERSION 3.12)
|
2021-08-22 10:20:59 +00:00
|
|
|
project(p2pool)
|
|
|
|
|
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)
|
2021-08-22 10:20:59 +00:00
|
|
|
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
|
|
|
|
2022-06-04 11:16:05 +00:00
|
|
|
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT p2pool)
|
2021-09-05 22:39:19 +00:00
|
|
|
|
2022-03-15 15:56:37 +00:00
|
|
|
if (WITH_RANDOMX)
|
|
|
|
add_definitions(-DWITH_RANDOMX)
|
|
|
|
add_subdirectory(external/src/RandomX)
|
|
|
|
set(LIBS randomx)
|
|
|
|
endif()
|
2021-08-22 10:20:59 +00:00
|
|
|
|
|
|
|
include(cmake/flags.cmake)
|
|
|
|
|
|
|
|
set(HEADERS
|
|
|
|
external/src/cryptonote/crypto-ops.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
|
|
|
|
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/tcp_server.inl
|
|
|
|
src/util.h
|
|
|
|
src/uv_util.h
|
|
|
|
src/wallet.h
|
|
|
|
src/zmq_reader.h
|
|
|
|
)
|
|
|
|
|
|
|
|
set(SOURCES
|
|
|
|
external/src/cryptonote/crypto-ops-data.c
|
|
|
|
external/src/cryptonote/crypto-ops.c
|
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
|
|
|
|
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
|
|
|
|
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()
|
|
|
|
|
2021-08-22 10:20:59 +00:00
|
|
|
include_directories(src)
|
|
|
|
include_directories(external/src)
|
|
|
|
include_directories(external/src/cryptonote)
|
2022-06-04 11:16:05 +00:00
|
|
|
include_directories(external/src/curl/include)
|
2021-08-22 10:20:59 +00:00
|
|
|
include_directories(external/src/libuv/include)
|
|
|
|
include_directories(external/src/cppzmq)
|
|
|
|
include_directories(external/src/libzmq/include)
|
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)
|
2021-08-22 10:20:59 +00:00
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
set(LIBS ${LIBS} ws2_32 iphlpapi userenv psapi)
|
2022-06-04 11:16:05 +00:00
|
|
|
add_definitions(-DCURL_STATICLIB)
|
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)
|
2022-05-02 19:24:51 +00:00
|
|
|
set(LIBS ${LIBS} pthread dl)
|
2021-08-22 10:20:59 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
|
|
|
find_library(ZMQ_LIBRARY_DEBUG NAMES libzmq-v142-mt-sgd-4_3_5 PATHS "external/lib/libzmq/Debug")
|
|
|
|
find_library(ZMQ_LIBRARY NAMES libzmq-v142-mt-s-4_3_5 PATHS "external/lib/libzmq/Release")
|
|
|
|
find_library(UV_LIBRARY_DEBUG NAMES uv_a PATHS "external/lib/libuv/Debug")
|
|
|
|
find_library(UV_LIBRARY NAMES uv_a PATHS "external/lib/libuv/Release")
|
2022-06-04 11:16:05 +00:00
|
|
|
find_library(CURL_LIBRARY_DEBUG NAMES libcurld PATHS "external/lib/libcurl/Debug")
|
|
|
|
find_library(CURL_LIBRARY NAMES libcurl PATHS "external/lib/libcurl/Release")
|
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)
|
|
|
|
find_library(CURL_LIBRARY_DEBUG NAMES libcurl.a PATHS "external/src/curl/lib/.libs" NO_DEFAULT_PATH)
|
|
|
|
find_library(CURL_LIBRARY NAMES libcurl.a PATHS "external/src/curl/lib/.libs" NO_DEFAULT_PATH)
|
|
|
|
else()
|
|
|
|
find_library(CURL_LIBRARY_DEBUG NAMES curl)
|
|
|
|
find_library(CURL_LIBRARY NAMES curl)
|
|
|
|
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-02 19:24:51 +00:00
|
|
|
include(CheckSymbolExists)
|
|
|
|
|
2022-05-03 18:52:24 +00:00
|
|
|
set(CMAKE_REQUIRED_FLAGS "${GENERAL_FLAGS}")
|
2022-05-02 19:24:51 +00:00
|
|
|
check_symbol_exists(pthread_cancel pthread.h HAVE_PTHREAD_CANCEL)
|
|
|
|
|
|
|
|
if (HAVE_PTHREAD_CANCEL)
|
|
|
|
add_definitions(/DHAVE_PTHREAD_CANCEL)
|
|
|
|
endif()
|
|
|
|
|
2022-05-09 09:25:52 +00:00
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
|
|
|
|
check_cxx_source_compiles("int main(){ return __builtin_clzll(1);}" HAVE_BUILTIN_CLZLL)
|
|
|
|
check_cxx_source_compiles("#include <intrin.h>\n#pragma intrinsic(_BitScanReverse64)\nint main(){unsigned long r;_BitScanReverse64(&r,1);return r;}" HAVE_BITSCANREVERSE64)
|
|
|
|
|
|
|
|
if (HAVE_BUILTIN_CLZLL)
|
|
|
|
add_definitions(/DHAVE_BUILTIN_CLZLL)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (HAVE_BITSCANREVERSE64)
|
|
|
|
add_definitions(/DHAVE_BITSCANREVERSE64)
|
|
|
|
endif()
|
|
|
|
|
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)
|
2022-06-04 11:16:05 +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()
|
2021-08-22 10:20:59 +00:00
|
|
|
|
2022-03-15 15:56:37 +00:00
|
|
|
if (WITH_RANDOMX)
|
|
|
|
set(STATIC_LIBS randomx)
|
|
|
|
endif()
|
|
|
|
|
2022-06-04 11:16:05 +00:00
|
|
|
if (WIN32)
|
|
|
|
set(STATIC_LIBS ${STATIC_LIBS} ws2_32 iphlpapi userenv psapi wldap32)
|
|
|
|
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()
|
2022-02-16 09:43:04 +00:00
|
|
|
set(STATIC_LIBS ${STATIC_LIBS} pthread dl)
|
|
|
|
endif()
|
|
|
|
|
2021-08-22 10:20:59 +00:00
|
|
|
target_link_libraries(${CMAKE_PROJECT_NAME}
|
|
|
|
"${CMAKE_SOURCE_DIR}/external/src/libzmq/build/lib/libzmq.a"
|
|
|
|
"${CMAKE_SOURCE_DIR}/external/src/libuv/build/libuv_a.a"
|
2022-06-04 11:16:05 +00:00
|
|
|
"${CMAKE_SOURCE_DIR}/external/src/curl/lib/.libs/libcurl.a"
|
2022-02-16 09:43:04 +00:00
|
|
|
${STATIC_LIBS}
|
2021-08-22 10:20:59 +00:00
|
|
|
)
|
|
|
|
else()
|
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()
|