diff --git a/CMakeLists.txt b/CMakeLists.txt index 849c1257..e507a03c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") include (CheckIncludeFile) include (cmake/cpu.cmake) +include (cmake/os.cmake) include (src/base/base.cmake) include (src/backend/backend.cmake) @@ -131,40 +132,31 @@ if (WITH_HWLOC) ) endif() -if (WIN32) - set(SOURCES_OS - "${SOURCES_OS}" +if (XMRIG_OS_WIN) + list(APPEND SOURCES_OS res/app.rc src/App_win.cpp src/crypto/common/VirtualMemory_win.cpp ) - add_definitions(/DWIN32) set(EXTRA_LIBS ws2_32 psapi iphlpapi userenv) -elseif (APPLE) - set(SOURCES_OS - "${SOURCES_OS}" +elseif (XMRIG_OS_APPLE) + list(APPEND SOURCES_OS src/App_unix.cpp src/crypto/common/VirtualMemory_unix.cpp ) else() - set(SOURCES_OS - "${SOURCES_OS}" + list(APPEND SOURCES_OS src/App_unix.cpp src/crypto/common/VirtualMemory_unix.cpp ) - if (CMAKE_SYSTEM_NAME STREQUAL FreeBSD) - set(EXTRA_LIBS kvm pthread) - else() + if (XMRIG_OS_ANDROID) + set(EXTRA_LIBS pthread rt dl log) + elseif (XMRIG_OS_LINUX) set(EXTRA_LIBS pthread rt dl) - endif() -endif() - -if (CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Android") - EXECUTE_PROCESS(COMMAND uname -o COMMAND tr -d '\n' OUTPUT_VARIABLE OPERATING_SYSTEM) - if (OPERATING_SYSTEM MATCHES "Android") - set(EXTRA_LIBS ${EXTRA_LIBS} log) + elseif (XMRIG_OS_FREEBSD) + set(EXTRA_LIBS kvm pthread) endif() endif() diff --git a/cmake/os.cmake b/cmake/os.cmake new file mode 100644 index 00000000..0270cc93 --- /dev/null +++ b/cmake/os.cmake @@ -0,0 +1,45 @@ +if (WIN32) + set(XMRIG_OS_WIN ON) +elseif (APPLE) + set(XMRIG_OS_APPLE ON) + + if (IOS OR CMAKE_SYSTEM_NAME STREQUAL iOS) + set(XMRIG_OS_IOS ON) + else() + set(XMRIG_OS_MACOS ON) + endif() +else() + set(XMRIG_OS_UNIX ON) + + if (ANDROID OR CMAKE_SYSTEM_NAME MATCHES "Android") + set(XMRIG_OS_ANDROID ON) + elseif(CMAKE_SYSTEM_NAME MATCHES "Linux") + set(XMRIG_OS_LINUX ON) + elseif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) + set(XMRIG_OS_FREEBSD ON) + endif() +endif() + + +if (XMRIG_OS_WIN) + add_definitions(/DWIN32) + add_definitions(/DXMRIG_OS_WIN) +elseif(XMRIG_OS_APPLE) + add_definitions(/DXMRIG_OS_APPLE) + + if (XMRIG_OS_IOS) + add_definitions(/DXMRIG_OS_IOS) + else() + add_definitions(/DXMRIG_OS_MACOS) + endif() +elseif(XMRIG_OS_UNIX) + add_definitions(/DXMRIG_OS_UNIX) + + if (XMRIG_OS_ANDROID) + add_definitions(/DXMRIG_OS_ANDROID) + elseif (XMRIG_OS_LINUX) + add_definitions(/DXMRIG_OS_LINUX) + elseif (XMRIG_OS_FREEBSD) + add_definitions(/DXMRIG_OS_FREEBSD) + endif() +endif()