2017-04-15 06:02:08 +00:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
|
|
|
project(xmrig C)
|
|
|
|
|
2017-05-03 07:53:51 +00:00
|
|
|
option(WITH_LIBCPUID "Use Libcpuid library" ON)
|
|
|
|
|
2017-04-15 06:02:08 +00:00
|
|
|
set(HEADERS
|
|
|
|
compat.h
|
|
|
|
algo/cryptonight/cryptonight.h
|
2017-05-01 00:49:05 +00:00
|
|
|
algo/cryptonight/cryptonight_aesni.h
|
|
|
|
algo/cryptonight/cryptonight_softaes.h
|
2017-04-15 06:02:08 +00:00
|
|
|
elist.h
|
|
|
|
xmrig.h
|
|
|
|
version.h
|
|
|
|
options.h
|
|
|
|
cpu.h
|
|
|
|
persistent_memory.h
|
|
|
|
stratum.h
|
|
|
|
stats.h
|
|
|
|
util.h
|
|
|
|
donate.h
|
|
|
|
)
|
|
|
|
|
|
|
|
set(HEADERS_CRYPTO
|
|
|
|
crypto/c_groestl.h
|
|
|
|
crypto/c_blake256.h
|
|
|
|
crypto/c_jh.h
|
|
|
|
crypto/c_skein.h
|
|
|
|
)
|
|
|
|
|
|
|
|
set(HEADERS_COMPAT
|
|
|
|
compat/winansi.h
|
|
|
|
)
|
|
|
|
|
|
|
|
set(HEADERS_UTILS
|
|
|
|
utils/applog.h
|
|
|
|
utils/threads.h
|
|
|
|
utils/summary.h
|
|
|
|
)
|
|
|
|
|
|
|
|
set(SOURCES
|
|
|
|
xmrig.c
|
2017-04-24 10:23:49 +00:00
|
|
|
algo/cryptonight/cryptonight.c
|
2017-05-01 00:49:05 +00:00
|
|
|
algo/cryptonight/cryptonight_av1_aesni.c
|
|
|
|
algo/cryptonight/cryptonight_av2_aesni_double.c
|
|
|
|
algo/cryptonight/cryptonight_av4_softaes.c
|
|
|
|
algo/cryptonight/cryptonight_av5_softaes_double.c
|
2017-04-15 06:02:08 +00:00
|
|
|
util.c
|
|
|
|
options.c
|
|
|
|
stratum.c
|
|
|
|
stats.c
|
|
|
|
memory.c
|
|
|
|
)
|
|
|
|
|
|
|
|
set(SOURCES_CRYPTO
|
|
|
|
crypto/c_keccak.c
|
|
|
|
crypto/c_groestl.c
|
|
|
|
crypto/c_blake256.c
|
|
|
|
crypto/c_jh.c
|
|
|
|
crypto/c_skein.c
|
2017-04-19 07:03:40 +00:00
|
|
|
crypto/soft_aes.c
|
2017-04-15 06:02:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
set(SOURCES_UTILS
|
|
|
|
utils/applog.c
|
|
|
|
utils/summary.c
|
|
|
|
)
|
|
|
|
|
|
|
|
if (WIN32)
|
2017-04-19 17:52:00 +00:00
|
|
|
set(SOURCES_OS win/cpu_win.c win/memory_win.c win/xmrig_win.c win/app.rc compat/winansi.c)
|
2017-04-15 06:02:08 +00:00
|
|
|
set(EXTRA_LIBS ws2_32)
|
|
|
|
add_definitions(/D_WIN32_WINNT=0x600)
|
|
|
|
else()
|
|
|
|
set(SOURCES_OS unix/cpu_unix.c unix/memory_unix.c unix/xmrig_unix.c)
|
|
|
|
set(EXTRA_LIBS pthread)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include_directories(.)
|
|
|
|
add_definitions(/DUSE_NATIVE_THREADS)
|
|
|
|
add_definitions(/D_GNU_SOURCE)
|
|
|
|
|
|
|
|
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
|
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes -Wno-pointer-to-int-cast")
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Ofast -funroll-loops -fvariable-expansion-in-unroller -ftree-loop-if-convert-stores -fmerge-all-constants -fbranch-target-load-optimize2")
|
2017-04-21 06:20:19 +00:00
|
|
|
#set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -gdwarf-2")
|
2017-04-15 06:02:08 +00:00
|
|
|
#set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fprofile-generate")
|
|
|
|
#set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fprofile-use -fprofile-correction")
|
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include_directories(compat/jansson)
|
|
|
|
add_subdirectory(compat/jansson)
|
|
|
|
|
2017-05-03 07:53:51 +00:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
|
|
|
|
|
2017-04-15 06:02:08 +00:00
|
|
|
find_package(CURL REQUIRED)
|
2017-05-03 07:53:51 +00:00
|
|
|
include_directories(${CURL_INCLUDE_DIRS})
|
|
|
|
add_definitions(/DCURL_STATICLIB)
|
|
|
|
link_directories(${CURL_LIBRARIES})
|
2017-04-15 06:02:08 +00:00
|
|
|
|
2017-05-03 07:53:51 +00:00
|
|
|
if (WITH_LIBCPUID)
|
|
|
|
find_package(CPUID REQUIRED)
|
|
|
|
include_directories(${CPUID_INCLUDE_DIRS})
|
|
|
|
link_directories(${CPUID_LIBRARIES})
|
|
|
|
|
|
|
|
set(CPUID_LIB cpuid)
|
2017-05-03 10:48:08 +00:00
|
|
|
set(SOURCES_CPUID cpu.c)
|
2017-05-03 07:53:51 +00:00
|
|
|
else()
|
|
|
|
add_definitions(/DXMRIG_NO_LIBCPUID)
|
2017-05-03 10:48:08 +00:00
|
|
|
set(SOURCES_CPUID cpu_stub.c)
|
2017-04-15 06:02:08 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
|
|
add_subdirectory(algo/cryptonight/bmi2)
|
2017-05-03 10:48:08 +00:00
|
|
|
add_executable(xmrig ${HEADERS} ${HEADERS_CRYPTO} ${SOURCES} ${SOURCES_CRYPTO} ${HEADERS_UTILS} ${SOURCES_UTILS} ${HEADERS_COMPAT} ${SOURCES_COMPAT} ${SOURCES_OS} ${SOURCES_CPUID})
|
2017-05-03 07:53:51 +00:00
|
|
|
target_link_libraries(xmrig jansson curl cryptonight_av3_aesni_bmi2 ${CPUID_LIB} ${EXTRA_LIBS})
|
2017-04-15 06:02:08 +00:00
|
|
|
else()
|
|
|
|
set(CRYPTONIGHT32
|
2017-04-21 12:20:08 +00:00
|
|
|
algo/cryptonight/i686/cryptonight_av1_aesni.c
|
2017-04-21 12:47:11 +00:00
|
|
|
algo/cryptonight/i686/cryptonight_av4_softaes.c
|
2017-04-15 06:02:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
add_executable(xmrig32 ${HEADERS} ${HEADERS_CRYPTO} ${SOURCES} ${SOURCES_CRYPTO} ${HEADERS_UTILS} ${SOURCES_UTILS} ${HEADERS_COMPAT} ${SOURCES_COMPAT} ${SOURCES_OS} ${CRYPTONIGHT32})
|
2017-04-21 12:20:08 +00:00
|
|
|
target_link_libraries(xmrig32 jansson curl ${EXTRA_LIBS})
|
2017-04-15 06:02:08 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
source_group("HEADERS" FILES ${HEADERS})
|