2017-12-16 19:27:11 +07:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
2017-06-04 20:52:21 +03:00
|
|
|
project(xmrig)
|
2017-05-03 10:53:51 +03:00
|
|
|
|
2019-03-02 13:12:38 +07:00
|
|
|
option(WITH_LIBCPUID "Use Libcpuid" ON)
|
2019-07-23 01:18:55 +07:00
|
|
|
option(WITH_HWLOC "Use hwloc" OFF)
|
2019-06-09 15:29:26 +07:00
|
|
|
option(WITH_CN_LITE "CryptoNight-Lite support" ON)
|
|
|
|
option(WITH_CN_HEAVY "CryptoNight-Heavy support" ON)
|
2019-03-02 13:12:38 +07:00
|
|
|
option(WITH_CN_PICO "CryptoNight-Pico support" ON)
|
|
|
|
option(WITH_CN_GPU "CryptoNight-GPU support" ON)
|
2019-06-18 06:11:53 +07:00
|
|
|
option(WITH_RANDOMX "RandomX support" ON)
|
2019-04-09 02:27:19 +07:00
|
|
|
option(WITH_HTTP "HTTP protocol support (client/server)" ON)
|
2019-03-02 13:12:38 +07:00
|
|
|
option(WITH_DEBUG_LOG "Enable debug log output" OFF)
|
|
|
|
option(WITH_TLS "Enable OpenSSL support" ON)
|
|
|
|
option(WITH_ASM "Enable ASM PoW implementations" ON)
|
|
|
|
option(BUILD_STATIC "Build static binary" OFF)
|
|
|
|
option(ARM_TARGET "Force use specific ARM target 8 or 7" 0)
|
|
|
|
option(WITH_EMBEDDED_CONFIG "Enable internal embedded JSON config" OFF)
|
2017-06-25 02:04:59 +03:00
|
|
|
|
|
|
|
include (CheckIncludeFile)
|
2017-11-06 03:11:35 +03:00
|
|
|
include (cmake/cpu.cmake)
|
2019-03-16 02:07:26 +07:00
|
|
|
include (src/base/base.cmake)
|
2019-07-02 22:56:28 +07:00
|
|
|
include (src/backend/backend.cmake)
|
2017-06-25 02:04:59 +03:00
|
|
|
|
|
|
|
|
2017-04-15 09:02:08 +03:00
|
|
|
set(HEADERS
|
2019-03-16 02:07:26 +07:00
|
|
|
"${HEADERS_BASE}"
|
2019-03-29 02:31:56 +07:00
|
|
|
"${HEADERS_BASE_HTTP}"
|
2019-07-02 22:56:28 +07:00
|
|
|
"${HEADERS_BACKEND}"
|
2019-03-30 03:10:27 +07:00
|
|
|
src/api/interfaces/IApiListener.h
|
2017-06-04 20:52:21 +03:00
|
|
|
src/App.h
|
2019-04-05 22:14:01 +07:00
|
|
|
src/core/config/Config_default.h
|
|
|
|
src/core/config/Config_platform.h
|
2019-04-06 18:32:24 +07:00
|
|
|
src/core/config/Config.h
|
|
|
|
src/core/config/ConfigTransform.h
|
2019-03-30 21:27:54 +07:00
|
|
|
src/core/config/usage.h
|
2018-03-27 14:01:38 +07:00
|
|
|
src/core/Controller.h
|
2019-07-16 22:10:50 +07:00
|
|
|
src/core/Miner.h
|
2019-07-06 15:22:19 +07:00
|
|
|
src/net/interfaces/IJobResultListener.h
|
2017-06-11 10:58:46 +03:00
|
|
|
src/net/JobResult.h
|
2019-07-06 15:22:19 +07:00
|
|
|
src/net/JobResults.h
|
2017-06-04 20:52:21 +03:00
|
|
|
src/net/Network.h
|
2019-03-30 03:10:27 +07:00
|
|
|
src/net/NetworkState.h
|
2017-06-28 06:17:02 +03:00
|
|
|
src/net/strategies/DonateStrategy.h
|
2017-06-08 01:16:45 +03:00
|
|
|
src/Summary.h
|
2017-06-12 16:19:07 +03:00
|
|
|
src/version.h
|
2017-04-15 09:02:08 +03:00
|
|
|
)
|
|
|
|
|
2017-06-08 04:20:10 +03:00
|
|
|
set(HEADERS_CRYPTO
|
2019-06-04 19:20:33 +07:00
|
|
|
src/crypto/cn/asm/CryptonightR_template.h
|
|
|
|
src/crypto/cn/c_blake256.h
|
|
|
|
src/crypto/cn/c_groestl.h
|
|
|
|
src/crypto/cn/c_jh.h
|
|
|
|
src/crypto/cn/c_skein.h
|
2019-06-13 22:08:52 +07:00
|
|
|
src/crypto/cn/CnAlgo.h
|
2019-07-17 04:33:11 +07:00
|
|
|
src/crypto/cn/CnCtx.h
|
2019-06-13 22:08:52 +07:00
|
|
|
src/crypto/cn/CnHash.h
|
2019-06-04 19:20:33 +07:00
|
|
|
src/crypto/cn/CryptoNight_monero.h
|
|
|
|
src/crypto/cn/CryptoNight_test.h
|
|
|
|
src/crypto/cn/CryptoNight.h
|
|
|
|
src/crypto/cn/groestl_tables.h
|
|
|
|
src/crypto/cn/hash.h
|
|
|
|
src/crypto/cn/skein_port.h
|
|
|
|
src/crypto/cn/soft_aes.h
|
2019-06-09 16:46:44 +07:00
|
|
|
src/crypto/common/Algorithm.h
|
2019-06-17 04:06:38 +07:00
|
|
|
src/crypto/common/keccak.h
|
2019-07-11 16:15:51 +07:00
|
|
|
src/crypto/common/Nonce.h
|
2019-06-02 20:57:49 +07:00
|
|
|
src/crypto/common/portable/mm_malloc.h
|
|
|
|
src/crypto/common/VirtualMemory.h
|
2017-06-08 04:20:10 +03:00
|
|
|
)
|
|
|
|
|
2017-11-26 22:23:23 +03:00
|
|
|
if (XMRIG_ARM)
|
2019-06-04 19:20:33 +07:00
|
|
|
set(HEADERS_CRYPTO "${HEADERS_CRYPTO}" src/crypto/cn/CryptoNight_arm.h)
|
2017-11-06 03:11:35 +03:00
|
|
|
else()
|
2019-06-04 19:20:33 +07:00
|
|
|
set(HEADERS_CRYPTO "${HEADERS_CRYPTO}" src/crypto/cn/CryptoNight_x86.h)
|
2017-11-06 03:11:35 +03:00
|
|
|
endif()
|
|
|
|
|
2017-04-15 09:02:08 +03:00
|
|
|
set(SOURCES
|
2019-03-16 02:07:26 +07:00
|
|
|
"${SOURCES_BASE}"
|
2019-03-29 02:31:56 +07:00
|
|
|
"${SOURCES_BASE_HTTP}"
|
2019-07-02 22:56:28 +07:00
|
|
|
"${SOURCES_BACKEND}"
|
2017-06-04 20:52:21 +03:00
|
|
|
src/App.cpp
|
2019-03-30 21:27:54 +07:00
|
|
|
src/core/config/Config.cpp
|
2019-04-05 22:14:01 +07:00
|
|
|
src/core/config/ConfigTransform.cpp
|
2018-03-27 14:01:38 +07:00
|
|
|
src/core/Controller.cpp
|
2019-07-16 22:10:50 +07:00
|
|
|
src/core/Miner.cpp
|
2019-07-06 15:22:19 +07:00
|
|
|
src/net/JobResults.cpp
|
2017-06-04 20:52:21 +03:00
|
|
|
src/net/Network.cpp
|
2019-03-30 03:10:27 +07:00
|
|
|
src/net/NetworkState.cpp
|
2017-06-28 06:17:02 +03:00
|
|
|
src/net/strategies/DonateStrategy.cpp
|
2017-06-08 01:16:45 +03:00
|
|
|
src/Summary.cpp
|
2017-06-04 20:52:21 +03:00
|
|
|
src/xmrig.cpp
|
2017-04-15 09:02:08 +03:00
|
|
|
)
|
|
|
|
|
2017-06-08 04:20:10 +03:00
|
|
|
set(SOURCES_CRYPTO
|
2019-06-04 19:20:33 +07:00
|
|
|
src/crypto/cn/c_blake256.c
|
2019-06-13 22:08:52 +07:00
|
|
|
src/crypto/cn/c_groestl.c
|
2019-06-04 19:20:33 +07:00
|
|
|
src/crypto/cn/c_jh.c
|
|
|
|
src/crypto/cn/c_skein.c
|
2019-07-17 04:33:11 +07:00
|
|
|
src/crypto/cn/CnCtx.cpp
|
2019-06-13 22:08:52 +07:00
|
|
|
src/crypto/cn/CnHash.cpp
|
2019-06-09 16:46:44 +07:00
|
|
|
src/crypto/common/Algorithm.cpp
|
2019-06-17 04:06:38 +07:00
|
|
|
src/crypto/common/keccak.cpp
|
2019-07-11 16:15:51 +07:00
|
|
|
src/crypto/common/Nonce.cpp
|
2017-06-08 04:20:10 +03:00
|
|
|
)
|
|
|
|
|
2017-04-15 09:02:08 +03:00
|
|
|
if (WIN32)
|
2017-06-04 20:52:21 +03:00
|
|
|
set(SOURCES_OS
|
2019-03-16 02:07:26 +07:00
|
|
|
"${SOURCES_OS}"
|
2017-06-04 20:52:21 +03:00
|
|
|
res/app.rc
|
2017-06-13 13:20:15 +03:00
|
|
|
src/App_win.cpp
|
2019-06-02 19:43:56 +07:00
|
|
|
src/crypto/common/VirtualMemory_win.cpp
|
2017-06-04 20:52:21 +03:00
|
|
|
)
|
|
|
|
|
2017-06-14 21:33:20 +03:00
|
|
|
add_definitions(/DWIN32)
|
2017-06-04 20:52:21 +03:00
|
|
|
set(EXTRA_LIBS ws2_32 psapi iphlpapi userenv)
|
2017-06-14 19:13:02 +03:00
|
|
|
elseif (APPLE)
|
|
|
|
set(SOURCES_OS
|
2019-03-16 02:07:26 +07:00
|
|
|
"${SOURCES_OS}"
|
2017-06-14 19:13:02 +03:00
|
|
|
src/App_unix.cpp
|
2019-06-02 19:43:56 +07:00
|
|
|
src/crypto/common/VirtualMemory_unix.cpp
|
2017-06-14 19:13:02 +03:00
|
|
|
)
|
2017-04-15 09:02:08 +03:00
|
|
|
else()
|
2017-06-14 19:13:02 +03:00
|
|
|
set(SOURCES_OS
|
2019-03-16 02:07:26 +07:00
|
|
|
"${SOURCES_OS}"
|
2017-06-14 19:13:02 +03:00
|
|
|
src/App_unix.cpp
|
2019-06-02 19:43:56 +07:00
|
|
|
src/crypto/common/VirtualMemory_unix.cpp
|
2017-06-14 19:13:02 +03:00
|
|
|
)
|
|
|
|
|
2018-10-24 09:55:40 +07:00
|
|
|
if (CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
|
2019-01-16 10:55:45 +01:00
|
|
|
set(EXTRA_LIBS kvm pthread)
|
2018-10-24 09:55:40 +07:00
|
|
|
else()
|
|
|
|
set(EXTRA_LIBS pthread rt dl)
|
|
|
|
endif()
|
2017-10-20 19:54:18 +03:00
|
|
|
endif()
|
|
|
|
|
2017-11-24 00:23:04 +03:00
|
|
|
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
EXECUTE_PROCESS(COMMAND uname -o COMMAND tr -d '\n' OUTPUT_VARIABLE OPERATING_SYSTEM)
|
|
|
|
if (OPERATING_SYSTEM MATCHES "Android")
|
|
|
|
set(EXTRA_LIBS ${EXTRA_LIBS} log)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2017-08-29 23:41:57 +03:00
|
|
|
add_definitions(/D__STDC_FORMAT_MACROS)
|
2017-05-05 15:49:38 +03:00
|
|
|
add_definitions(/DUNICODE)
|
2017-04-15 09:02:08 +03:00
|
|
|
|
2017-06-04 20:52:21 +03:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
2017-04-15 09:02:08 +03:00
|
|
|
|
2017-06-04 20:52:21 +03:00
|
|
|
find_package(UV REQUIRED)
|
2017-05-27 10:34:42 +03:00
|
|
|
|
2019-07-23 01:18:55 +07:00
|
|
|
if (WITH_HWLOC)
|
|
|
|
find_package(HWLOC REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2019-06-18 06:11:53 +07:00
|
|
|
if (WITH_RANDOMX)
|
2019-07-01 20:11:51 +02:00
|
|
|
include_directories(src/crypto/randomx)
|
2019-06-18 06:11:53 +07:00
|
|
|
add_definitions(/DXMRIG_ALGO_RANDOMX)
|
2019-07-01 20:11:51 +02:00
|
|
|
set(SOURCES_CRYPTO
|
|
|
|
"${SOURCES_CRYPTO}"
|
|
|
|
src/crypto/randomx/aes_hash.cpp
|
|
|
|
src/crypto/randomx/allocator.cpp
|
|
|
|
src/crypto/randomx/argon2_core.c
|
2019-07-10 01:53:05 +07:00
|
|
|
src/crypto/randomx/argon2_ref.c
|
2019-07-01 20:11:51 +02:00
|
|
|
src/crypto/randomx/blake2_generator.cpp
|
2019-07-10 01:53:05 +07:00
|
|
|
src/crypto/randomx/blake2/blake2b.c
|
|
|
|
src/crypto/randomx/bytecode_machine.cpp
|
|
|
|
src/crypto/randomx/dataset.cpp
|
2019-07-01 20:11:51 +02:00
|
|
|
src/crypto/randomx/instructions_portable.cpp
|
2019-07-10 01:53:05 +07:00
|
|
|
src/crypto/randomx/randomx.cpp
|
2019-07-01 20:11:51 +02:00
|
|
|
src/crypto/randomx/reciprocal.c
|
2019-07-10 01:53:05 +07:00
|
|
|
src/crypto/randomx/soft_aes.cpp
|
|
|
|
src/crypto/randomx/superscalar.cpp
|
2019-07-01 20:11:51 +02:00
|
|
|
src/crypto/randomx/virtual_machine.cpp
|
2019-07-10 01:53:05 +07:00
|
|
|
src/crypto/randomx/virtual_memory.cpp
|
2019-07-01 20:11:51 +02:00
|
|
|
src/crypto/randomx/vm_compiled_light.cpp
|
2019-07-10 01:53:05 +07:00
|
|
|
src/crypto/randomx/vm_compiled.cpp
|
|
|
|
src/crypto/randomx/vm_interpreted_light.cpp
|
|
|
|
src/crypto/randomx/vm_interpreted.cpp
|
|
|
|
src/crypto/rx/Rx.cpp
|
|
|
|
src/crypto/rx/Rx.h
|
|
|
|
src/crypto/rx/RxAlgo.cpp
|
|
|
|
src/crypto/rx/RxAlgo.h
|
|
|
|
src/crypto/rx/RxCache.cpp
|
|
|
|
src/crypto/rx/RxCache.h
|
|
|
|
src/crypto/rx/RxDataset.cpp
|
|
|
|
src/crypto/rx/RxDataset.h
|
2019-07-10 10:14:33 +07:00
|
|
|
src/crypto/rx/RxVm.cpp
|
|
|
|
src/crypto/rx/RxVm.h
|
2019-07-01 20:11:51 +02:00
|
|
|
)
|
2019-07-01 20:48:51 +02:00
|
|
|
if (NOT ARCH_ID)
|
|
|
|
set(ARCH_ID ${CMAKE_HOST_SYSTEM_PROCESSOR})
|
|
|
|
endif()
|
2019-07-01 20:11:51 +02:00
|
|
|
if (CMAKE_C_COMPILER_ID MATCHES MSVC)
|
|
|
|
enable_language(ASM_MASM)
|
|
|
|
list(APPEND SOURCES_CRYPTO
|
|
|
|
src/crypto/randomx/jit_compiler_x86_static.asm
|
|
|
|
src/crypto/randomx/jit_compiler_x86.cpp
|
|
|
|
)
|
2019-07-02 22:57:08 +07:00
|
|
|
elseif (NOT XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
2019-07-01 20:11:51 +02:00
|
|
|
list(APPEND SOURCES_CRYPTO
|
|
|
|
src/crypto/randomx/jit_compiler_x86_static.S
|
|
|
|
src/crypto/randomx/jit_compiler_x86.cpp
|
|
|
|
)
|
|
|
|
# cheat because cmake and ccache hate each other
|
|
|
|
set_property(SOURCE src/crypto/randomx/jit_compiler_x86_static.S PROPERTY LANGUAGE C)
|
|
|
|
endif()
|
2019-06-18 06:11:53 +07:00
|
|
|
else()
|
|
|
|
remove_definitions(/DXMRIG_ALGO_RANDOMX)
|
|
|
|
endif()
|
2017-05-27 10:34:42 +03:00
|
|
|
|
2017-11-06 03:11:35 +03:00
|
|
|
include(cmake/flags.cmake)
|
2017-04-15 09:02:08 +03:00
|
|
|
|
2018-09-16 03:06:54 +03:00
|
|
|
include(cmake/OpenSSL.cmake)
|
2018-09-23 20:16:33 +03:00
|
|
|
include(cmake/asm.cmake)
|
2019-02-03 14:44:23 +07:00
|
|
|
include(cmake/cn-gpu.cmake)
|
2018-09-16 03:06:54 +03:00
|
|
|
|
2019-06-09 15:29:26 +07:00
|
|
|
if (WITH_CN_LITE)
|
|
|
|
add_definitions(/DXMRIG_ALGO_CN_LITE)
|
2017-09-02 19:04:40 +03:00
|
|
|
endif()
|
|
|
|
|
2019-06-09 15:29:26 +07:00
|
|
|
if (WITH_CN_HEAVY)
|
|
|
|
add_definitions(/DXMRIG_ALGO_CN_HEAVY)
|
2018-04-03 02:55:28 +07:00
|
|
|
endif()
|
|
|
|
|
2019-06-09 15:29:26 +07:00
|
|
|
if (WITH_CN_PICO)
|
|
|
|
add_definitions(/DXMRIG_ALGO_CN_PICO)
|
2019-01-20 19:52:44 +07:00
|
|
|
endif()
|
|
|
|
|
2019-03-02 13:12:38 +07:00
|
|
|
if (WITH_EMBEDDED_CONFIG)
|
|
|
|
add_definitions(/DXMRIG_FEATURE_EMBEDDED_CONFIG)
|
|
|
|
endif()
|
|
|
|
|
2019-04-09 02:27:19 +07:00
|
|
|
if (WITH_HTTP)
|
|
|
|
set(HTTP_SOURCES
|
2019-03-31 01:31:40 +07:00
|
|
|
src/api/Api.cpp
|
2019-03-30 00:16:01 +07:00
|
|
|
src/api/Api.h
|
2019-03-31 01:31:40 +07:00
|
|
|
src/api/Httpd.cpp
|
|
|
|
src/api/Httpd.h
|
2019-03-30 02:26:30 +07:00
|
|
|
src/api/interfaces/IApiRequest.h
|
|
|
|
src/api/requests/ApiRequest.cpp
|
2019-03-31 01:31:40 +07:00
|
|
|
src/api/requests/ApiRequest.h
|
2019-03-30 02:26:30 +07:00
|
|
|
src/api/requests/HttpApiRequest.cpp
|
2019-03-31 01:31:40 +07:00
|
|
|
src/api/requests/HttpApiRequest.h
|
2019-03-29 12:33:11 +07:00
|
|
|
)
|
2017-08-31 02:28:33 +03:00
|
|
|
else()
|
2019-04-09 02:27:19 +07:00
|
|
|
set(HTTP_SOURCES "")
|
2017-08-31 02:28:33 +03:00
|
|
|
endif()
|
|
|
|
|
2017-06-04 20:52:21 +03:00
|
|
|
include_directories(src)
|
|
|
|
include_directories(src/3rdparty)
|
|
|
|
include_directories(${UV_INCLUDE_DIR})
|
2017-05-10 12:58:52 +03:00
|
|
|
|
2018-03-12 21:03:04 +01:00
|
|
|
if (BUILD_STATIC)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS " -static")
|
|
|
|
endif()
|
|
|
|
|
2018-09-03 01:26:19 +03:00
|
|
|
if (WITH_DEBUG_LOG)
|
|
|
|
add_definitions(/DAPP_DEBUG)
|
|
|
|
endif()
|
|
|
|
|
2019-04-09 02:27:19 +07:00
|
|
|
add_executable(${CMAKE_PROJECT_NAME} ${HEADERS} ${SOURCES} ${SOURCES_OS} ${SOURCES_CPUID} ${HEADERS_CRYPTO} ${SOURCES_CRYPTO} ${SOURCES_SYSLOG} ${HTTP_SOURCES} ${TLS_SOURCES} ${XMRIG_ASM_SOURCES} ${CN_GPU_SOURCES})
|
2019-07-24 06:11:54 +07:00
|
|
|
target_link_libraries(${CMAKE_PROJECT_NAME} ${XMRIG_ASM_LIBRARY} ${OPENSSL_LIBRARIES} ${UV_LIBRARIES} ${EXTRA_LIBS} ${CPUID_LIB} ${HWLOC_LIBRARY})
|