2021-09-03 09:12:22 +00:00
|
|
|
cmake_minimum_required(VERSION 2.8.12)
|
|
|
|
project(p2pool_tests)
|
|
|
|
|
2021-09-05 09:50:56 +00:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
set(CMAKE_CXX_STANDARD 14)
|
|
|
|
|
|
|
|
set(CMAKE_C_STANDARD 99)
|
|
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
|
2021-09-05 22:39:19 +00:00
|
|
|
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.6.0")
|
|
|
|
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT p2pool_tests)
|
|
|
|
endif()
|
|
|
|
|
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)
|
|
|
|
|
2021-09-03 09:12:22 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
|
|
|
set(WARNING_FLAGS "")
|
|
|
|
set(OPTIMIZATION_FLAGS "-Ofast -s")
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}")
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${WARNING_FLAGS} ${OPTIMIZATION_FLAGS}")
|
|
|
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS}")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${WARNING_FLAGS} ${OPTIMIZATION_FLAGS}")
|
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
|
|
|
else()
|
|
|
|
if (STATIC_LINUX_BINARY)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
|
|
|
else()
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
|
|
|
set(WARNING_FLAGS "")
|
|
|
|
set(SECURITY_FLAGS "/GS /guard:cf")
|
|
|
|
set(OPTIMIZATION_FLAGS "/O2 /Oi /Ob2 /Ot /DNDEBUG /GL")
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_DEBUG "${WARNING_FLAGS} ${SECURITY_FLAGS} /Od /Ob0 /Zi /MTd /fsanitize=address")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${WARNING_FLAGS} ${SECURITY_FLAGS} /Od /Ob0 /Zi /MTd /fsanitize=address")
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${WARNING_FLAGS} ${SECURITY_FLAGS} ${OPTIMIZATION_FLAGS} /MT")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${WARNING_FLAGS} ${SECURITY_FLAGS} ${OPTIMIZATION_FLAGS} /MT")
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${WARNING_FLAGS} ${SECURITY_FLAGS} /Ob1 /Ot /Zi /MT")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${WARNING_FLAGS} ${SECURITY_FLAGS} /Ob1 /Ot /Zi /MT")
|
|
|
|
elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
|
|
|
set(WARNING_FLAGS "")
|
|
|
|
set(OPTIMIZATION_FLAGS "-Ofast -funroll-loops -fmerge-all-constants")
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}")
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${WARNING_FLAGS} ${OPTIMIZATION_FLAGS}")
|
|
|
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS}")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${WARNING_FLAGS} ${OPTIMIZATION_FLAGS}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(HEADERS
|
|
|
|
)
|
|
|
|
|
|
|
|
set(SOURCES
|
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
|
2021-09-05 20:28:57 +00:00
|
|
|
src/hash_tests.cpp
|
2021-09-04 19:22:28 +00:00
|
|
|
src/keccak_tests.cpp
|
|
|
|
src/main.cpp
|
2021-09-06 13:49:39 +00:00
|
|
|
src/pool_block_tests.cpp
|
2021-09-03 22:05:37 +00:00
|
|
|
src/wallet_tests.cpp
|
|
|
|
../external/src/cryptonote/crypto-ops-data.c
|
|
|
|
../external/src/cryptonote/crypto-ops.c
|
2021-09-06 13:49:39 +00:00
|
|
|
../external/src/llhttp/api.c
|
|
|
|
../external/src/llhttp/http.c
|
|
|
|
../external/src/llhttp/llhttp.c
|
|
|
|
../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/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
|
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
|
|
|
)
|
|
|
|
|
|
|
|
include_directories(../src)
|
|
|
|
include_directories(../external/src)
|
|
|
|
include_directories(../external/src/cryptonote)
|
|
|
|
include_directories(../external/src/libuv/include)
|
|
|
|
include_directories(../external/src/cppzmq)
|
|
|
|
include_directories(../external/src/libzmq/include)
|
|
|
|
include_directories(../external/src/llhttp)
|
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)
|
|
|
|
set(LIBS ${LIBS} ws2_32 iphlpapi userenv psapi)
|
|
|
|
elseif (NOT APPLE)
|
|
|
|
set(LIBS ${LIBS} pthread gss dl)
|
|
|
|
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")
|
|
|
|
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)
|
|
|
|
find_library(SODIUM_LIBRARY sodium)
|
|
|
|
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()
|
|
|
|
|
|
|
|
if (SODIUM_LIBRARY)
|
|
|
|
set(LIBS ${LIBS} ${SODIUM_LIBRARY})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_definitions(/DZMQ_STATIC /DP2POOL_LOG_DISABLE)
|
|
|
|
|
|
|
|
add_executable(${CMAKE_PROJECT_NAME} ${HEADERS} ${SOURCES})
|
|
|
|
target_link_libraries(${CMAKE_PROJECT_NAME} debug ${ZMQ_LIBRARY_DEBUG} debug ${UV_LIBRARY_DEBUG} optimized ${ZMQ_LIBRARY} optimized ${UV_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}>)
|
2021-09-06 13:49:39 +00:00
|
|
|
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/src/mainnet_test2_block.dat" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
|
2021-11-01 17:53:34 +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" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
|