From 599117abde895a67d677f496473bb19503d8a793 Mon Sep 17 00:00:00 2001 From: XMRig Date: Wed, 14 Jun 2017 19:13:02 +0300 Subject: [PATCH] Prepare for OS X. --- CMakeLists.txt | 24 ++++++++++++++++++++---- src/net/Network_mac.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 src/net/Network_mac.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d2fb52623..d846fd987 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,8 +85,21 @@ if (WIN32) ) set(EXTRA_LIBS ws2_32 psapi iphlpapi userenv) +elseif (APPLE) + set(SOURCES_OS + src/App_unix.cpp + src/Cpu_unix.cpp + src/Mem_unix.cpp + src/net/Network_mac.cpp + ) else() - set(SOURCES_OS src/Cpu_unix.cpp src/Mem_unix.cpp) + set(SOURCES_OS + src/App_unix.cpp + src/Cpu_unix.cpp + src/Mem_unix.cpp + src/net/Network_unix.cpp + ) + set(EXTRA_LIBS pthread) endif() @@ -105,17 +118,17 @@ endif() # https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html if (CMAKE_CXX_COMPILER_ID MATCHES GNU) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes -Wall -fno-exceptions") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes -Wall") 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") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes -Wall -fno-exceptions -fno-rtti") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes -Wall -std=c++14 -fno-exceptions -fno-rtti") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast -s -funroll-loops -fvariable-expansion-in-unroller -ftree-loop-if-convert-stores -fmerge-all-constants -fbranch-target-load-optimize2") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") add_definitions(/D_GNU_SOURCE) - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -gdwarf-2") + #set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -gdwarf-2") elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC) @@ -124,7 +137,10 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC) elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes -Wall") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Ofast -funroll-loops -fvariable-expansion-in-unroller -fmerge-all-constants") + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes -Wall -std=c++14 -fno-exceptions -fno-rtti") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast -funroll-loops -fvariable-expansion-in-unroller -fmerge-all-constants") endif() diff --git a/src/net/Network_mac.cpp b/src/net/Network_mac.cpp new file mode 100644 index 000000000..79b58c516 --- /dev/null +++ b/src/net/Network_mac.cpp @@ -0,0 +1,40 @@ +/* XMRig + * Copyright 2010 Jeff Garzik + * Copyright 2012-2014 pooler + * Copyright 2014 Lucas Jones + * Copyright 2014-2016 Wolf9466 + * Copyright 2016 Jay D Dee + * Copyright 2016-2017 XMRig + * + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +#include + + +#include "net/Network.h" +#include "version.h" + + +char *Network::userAgent() +{ + const size_t max = 128; + + char *buf = static_cast(malloc(max)); + snprintf(buf, max, "%s/%s", APP_NAME, APP_VERSION); + + return buf; +}