2017-01-21 12:46:45 +01:00
|
|
|
project(xmr-stak-amd)
|
|
|
|
|
2017-04-07 11:23:06 +02:00
|
|
|
cmake_minimum_required(VERSION 3.1.3)
|
2017-01-21 12:46:45 +01:00
|
|
|
|
2017-04-07 11:23:06 +02:00
|
|
|
# enforce C++11
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
|
|
|
|
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
|
|
|
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "install prefix" FORCE)
|
|
|
|
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
|
|
|
|
|
|
|
# help to find AMD app SDK on systems with a software module system
|
|
|
|
list(APPEND CMAKE_PREFIX_PATH "$ENV{AMDAPPSDKROOT}")
|
|
|
|
# allow user to extent CMAKE_PREFIX_PATH via environment variable
|
|
|
|
list(APPEND CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# CMake user options
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# gcc 5.1 is the first GNU version without CoW strings
|
|
|
|
# https://github.com/fireice-uk/xmr-stak-nvidia/pull/10#issuecomment-290821792
|
|
|
|
# If you remove this guard to compile with older gcc versions the miner will produce
|
|
|
|
# a high rate of wrong shares.
|
2017-01-21 12:46:45 +01:00
|
|
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
2017-04-07 11:23:06 +02:00
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
|
2017-01-21 12:46:45 +01:00
|
|
|
message(FATAL_ERROR "GCC version must be at least 5.1!")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2017-04-07 11:23:06 +02:00
|
|
|
set(BUILD_TYPE "Release;Debug")
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build" FORCE)
|
|
|
|
endif()
|
|
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${BUILD_TYPE}")
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Find OpenCL
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
find_package(OpenCL REQUIRED)
|
|
|
|
include_directories(SYSTEM ${OpenCL_INCLUDE_DIRS})
|
|
|
|
set(LIBS ${LIBS} ${OpenCL_LIBRARY})
|
|
|
|
link_directories(${OpenCL_LIBRARY})
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Find PThreads
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Find microhttpd
|
|
|
|
################################################################################
|
|
|
|
|
2017-01-21 12:46:45 +01:00
|
|
|
find_library(MHTD NAMES microhttpd)
|
|
|
|
if("${MHTD}" STREQUAL "MHTD-NOTFOUND")
|
2017-04-07 11:23:06 +02:00
|
|
|
message(STATUS "microhttpd NOT found: disable http server")
|
|
|
|
add_definitions("-DCONF_NO_HTTPD")
|
|
|
|
else()
|
|
|
|
set(LIBS ${LIBS} ${MHTD})
|
2017-01-21 12:46:45 +01:00
|
|
|
endif()
|
|
|
|
|
2017-04-07 11:23:06 +02:00
|
|
|
###############################################################################
|
|
|
|
# Find OpenSSL
|
|
|
|
###############################################################################
|
2017-02-22 23:49:55 +01:00
|
|
|
|
2017-04-07 11:23:06 +02:00
|
|
|
find_package(OpenSSL)
|
|
|
|
include_directories(${OPENSSL_INCLUDE_DIR})
|
|
|
|
set(LIBS ${LIBS} ${OPENSSL_LIBRARIES})
|
|
|
|
if(NOT OPENSSL_FOUND)
|
|
|
|
add_definitions("-DCONF_NO_TLS")
|
2017-01-21 12:46:45 +01:00
|
|
|
endif()
|
|
|
|
|
2017-04-07 11:23:06 +02:00
|
|
|
################################################################################
|
|
|
|
# Compile & Link
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
include_directories(.)
|
|
|
|
|
|
|
|
# activate sse2 and aes-ni
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2 -maes")
|
2017-01-21 12:46:45 +01:00
|
|
|
|
2017-04-07 11:23:06 +02:00
|
|
|
file(GLOB SRCFILES_CPP "*.cpp" "crypto/*.cpp")
|
|
|
|
file(GLOB SRCFILES_C "crypto/*.c" "amd_gpu/*.c")
|
|
|
|
|
|
|
|
add_library(xmr-stak-c
|
|
|
|
STATIC
|
|
|
|
${SRCFILES_C}
|
|
|
|
)
|
|
|
|
set_property(TARGET xmr-stak-c PROPERTY C_STANDARD 99)
|
|
|
|
|
|
|
|
add_executable(xmr-stak-amd
|
|
|
|
${SRCFILES_CPP}
|
|
|
|
)
|
2017-01-21 12:46:45 +01:00
|
|
|
|
|
|
|
set(EXECUTABLE_OUTPUT_PATH "bin")
|
2017-04-07 11:23:06 +02:00
|
|
|
target_link_libraries(xmr-stak-amd xmr-stak-c ${LIBS})
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Install
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# do not install the binary if the project and install are equal
|
|
|
|
if( NOT "${CMAKE_INSTALL_PREFIX}" STREQUAL "${PROJECT_BINARY_DIR}" )
|
|
|
|
install(TARGETS xmr-stak-amd
|
|
|
|
RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
|
|
|
|
endif()
|
2017-01-21 12:46:45 +01:00
|
|
|
|
2017-04-07 11:23:06 +02:00
|
|
|
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/opencl"
|
|
|
|
DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
|
2017-01-21 12:46:45 +01:00
|
|
|
|
2017-04-07 11:23:06 +02:00
|
|
|
# avoid overwrite of user defined settings
|
|
|
|
# install `config.txt`if file not exists in `${CMAKE_INSTALL_PREFIX}/bin`
|
|
|
|
install(CODE " \
|
|
|
|
if(NOT EXISTS ${CMAKE_INSTALL_PREFIX}/bin/config.txt)\n \
|
|
|
|
file(INSTALL ${CMAKE_CURRENT_SOURCE_DIR}/config.txt \
|
|
|
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)\n \
|
|
|
|
endif()"
|
|
|
|
)
|
2017-01-21 12:46:45 +01:00
|
|
|
|