p2pool/tests/CMakeLists.txt

204 lines
7.5 KiB
Text
Raw Normal View History

cmake_minimum_required(VERSION 3.5)
2021-09-03 09:12:22 +00:00
project(p2pool_tests)
2024-02-10 22:38:22 +00:00
include(cmake/standard.cmake)
option(STATIC_LIBS "Use locally built libuv and libzmq static libs" OFF)
2024-02-12 13:48:45 +00:00
option(WITH_LTO "Use link-time compiler optimization (if linking fails for you, run cmake with -DWITH_LTO=OFF)" ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
2021-09-05 09:50:56 +00:00
2023-01-26 19:19:57 +00:00
if (${CMAKE_VERSION} VERSION_GREATER "3.5.2")
2021-09-05 22:39:19 +00:00
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT p2pool_tests)
endif()
2023-04-22 18:27:26 +00:00
set(BUILD_GMOCK OFF CACHE BOOL "Builds the googlemock subproject" FORCE)
set(INSTALL_GTEST OFF CACHE BOOL "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" FORCE)
2021-09-03 09:12:22 +00:00
add_subdirectory(googletest)
set(LIBS gtest)
2021-09-06 13:49:39 +00:00
add_subdirectory(../external/src/RandomX RandomX)
set(LIBS ${LIBS} randomx)
add_definitions(-DWITH_RANDOMX)
2021-09-06 13:49:39 +00:00
2023-01-07 23:34:38 +00:00
add_definitions(-DP2POOL_UNIT_TESTS)
add_definitions(-DP2POOL_SIDECHAIN_EXTRA_1=1)
2023-01-07 23:34:38 +00:00
include(cmake/flags.cmake)
2021-09-03 09:12:22 +00:00
set(HEADERS
)
set(SOURCES
2022-11-24 20:38:15 +00:00
src/block_template_tests.cpp
2021-09-04 20:32:39 +00:00
src/crypto_tests.cpp
2021-09-04 19:22:28 +00:00
src/difficulty_type_tests.cpp
src/hash_tests.cpp
2021-09-04 19:22:28 +00:00
src/keccak_tests.cpp
2023-10-21 17:00:30 +00:00
src/merkle_tests.cpp
2023-09-16 17:38:16 +00:00
src/log_tests.cpp
2021-09-04 19:22:28 +00:00
src/main.cpp
2021-09-06 13:49:39 +00:00
src/pool_block_tests.cpp
2023-10-24 10:23:06 +00:00
src/sha256_tests.cpp
2022-05-09 09:25:52 +00:00
src/util_tests.cpp
2021-09-03 22:05:37 +00:00
src/wallet_tests.cpp
2023-10-24 10:23:06 +00:00
../external/src/crypto/sha256.c
2021-09-03 22:05:37 +00:00
../external/src/cryptonote/crypto-ops-data.c
../external/src/cryptonote/crypto-ops.c
../external/src/hardforks/hardforks.cpp
2021-09-06 13:49:39 +00:00
../src/block_cache.cpp
../src/block_template.cpp
../src/console_commands.cpp
2021-09-03 22:05:37 +00:00
../src/crypto.cpp
2021-09-06 13:49:39 +00:00
../src/json_rpc_request.cpp
2021-09-03 22:05:37 +00:00
../src/keccak.cpp
2021-09-03 09:12:22 +00:00
../src/log.cpp
2021-10-22 16:18:38 +00:00
../src/memory_leak_debug.cpp
2021-09-06 13:49:39 +00:00
../src/mempool.cpp
../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
2022-01-22 22:09:29 +00:00
../src/miner.cpp
2021-09-06 13:49:39 +00:00
../src/p2p_server.cpp
../src/p2pool.cpp
../src/p2pool_api.cpp
../src/params.cpp
../src/pool_block.cpp
../src/pow_hash.cpp
../src/side_chain.cpp
../src/stratum_server.cpp
../src/tcp_server.cpp
2021-09-03 09:12:22 +00:00
../src/util.cpp
2021-09-03 22:05:37 +00:00
../src/wallet.cpp
2021-09-06 13:49:39 +00:00
../src/zmq_reader.cpp
2021-09-03 09:12:22 +00:00
)
2024-05-30 21:11:14 +00:00
if (AMD64)
set(SOURCES ${SOURCES} ../src/keccak_bmi.cpp)
if (CMAKE_C_COMPILER_ID MATCHES GNU OR CMAKE_C_COMPILER_ID MATCHES Clang)
set_source_files_properties(../src/keccak_bmi.cpp PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -mbmi")
endif()
endif()
2022-11-14 19:59:11 +00:00
if (NOT STATIC_BINARY AND NOT STATIC_LIBS)
include(FindCURL)
endif()
if (CURL_INCLUDE_DIRS)
include_directories(${CURL_INCLUDE_DIRS})
else()
include_directories(../external/src/curl/include)
endif()
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-09-03 09:12:22 +00:00
include_directories(../src)
include_directories(../external/src)
2023-10-24 10:23:06 +00:00
include_directories(../external/src/crypto)
2021-09-03 09:12:22 +00:00
include_directories(../external/src/cryptonote)
2022-11-14 19:59:11 +00:00
include_directories(${UV_INCLUDE_DIR})
2021-09-03 09:12:22 +00:00
include_directories(../external/src/cppzmq)
2022-11-14 19:59:11 +00:00
include_directories(${ZMQ_INCLUDE_DIR})
2024-02-06 16:20:58 +00:00
include_directories(../external/src/protobuf-c)
2021-09-06 13:49:39 +00:00
include_directories(../external/src/RandomX/src)
include_directories(../external/src/rapidjson/include)
2021-10-22 16:18:38 +00:00
include_directories(../external/src/robin-hood-hashing/src/include)
2021-09-03 09:12:22 +00:00
include_directories(src)
include_directories(googletest/googletest/include)
if (WIN32)
2023-05-26 16:32:29 +00:00
set(LIBS ${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(LIBS ${LIBS} bcrypt)
endif()
2022-06-04 11:16:05 +00:00
add_definitions(-DCURL_STATICLIB)
2021-09-03 09:12:22 +00:00
elseif (NOT APPLE)
2023-01-26 14:45:41 +00:00
set(LIBS ${LIBS} pthread)
2021-09-03 09:12:22 +00:00
endif()
if (STATIC_LIBS)
set(ZMQ_LIBRARY "${CMAKE_SOURCE_DIR}/../external/src/libzmq/build/lib/libzmq.a")
set(ZMQ_LIBRARY_DEBUG "${CMAKE_SOURCE_DIR}/../external/src/libzmq/build/lib/libzmq.a")
2023-05-26 16:32:29 +00:00
set(UV_LIBRARY_DEBUG "${CMAKE_SOURCE_DIR}/../external/src/libuv/build/libuv.a")
set(UV_LIBRARY "${CMAKE_SOURCE_DIR}/../external/src/libuv/build/libuv.a")
2022-06-04 11:16:05 +00:00
set(CURL_LIBRARY_DEBUG "${CMAKE_SOURCE_DIR}/../external/src/curl/lib/.libs/libcurl.a")
set(CURL_LIBRARY "${CMAKE_SOURCE_DIR}/../external/src/curl/lib/.libs/libcurl.a")
else()
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")
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)
elseif (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
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()
find_library(SODIUM_LIBRARY sodium)
endif()
if (SODIUM_LIBRARY)
set(LIBS ${LIBS} ${SODIUM_LIBRARY})
endif()
2021-09-03 09:12:22 +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-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-09-03 09:12:22 +00:00
add_definitions(/DZMQ_STATIC /DP2POOL_LOG_DISABLE)
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()
2023-06-12 13:29:23 +00:00
add_definitions("-DRAPIDJSON_PARSE_DEFAULT_FLAGS=kParseTrailingCommasFlag")
2021-09-03 09:12:22 +00:00
add_executable(${CMAKE_PROJECT_NAME} ${HEADERS} ${SOURCES})
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-09-04 20:32:39 +00:00
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/src/crypto_tests.txt" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
2023-03-19 10:38:43 +00:00
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/src/block.dat" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
2023-04-22 18:27:26 +00:00
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/src/sidechain_dump.dat.gz" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/src/sidechain_dump_mini.dat.gz" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)