#1469 Fixed build with gcc 4.8.

This commit is contained in:
XMRig 2019-12-30 16:04:07 +07:00
parent d5605a29b4
commit d64bbfa9c0
No known key found for this signature in database
GPG Key ID: 446A53638BE94409
3 changed files with 21 additions and 0 deletions

View File

@ -14,6 +14,7 @@ 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(WITH_MSR "Enable MSR mod & 1st-gen Ryzen fix" ON)
option(WITH_ENV_VARS "Enable environment variables support in config file" ON)
option(WITH_EMBEDDED_CONFIG "Enable internal embedded JSON config" OFF)
option(WITH_OPENCL "Enable OpenCL backend" ON)
option(WITH_CUDA "Enable CUDA backend" ON)

View File

@ -169,3 +169,15 @@ else()
remove_definitions(/DXMRIG_FEATURE_HTTP)
remove_definitions(/DXMRIG_FEATURE_API)
endif()
if (WITH_ENV_VARS AND CMAKE_CXX_COMPILER_ID MATCHES GNU AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
set(WITH_ENV_VARS OFF)
endif()
if (WITH_ENV_VARS)
add_definitions(/DXMRIG_FEATURE_ENV)
else()
remove_definitions(/DXMRIG_FEATURE_ENV)
endif()

View File

@ -50,6 +50,7 @@
namespace xmrig {
#ifdef XMRIG_FEATURE_ENV
static std::map<String, String> variables;
@ -59,6 +60,7 @@ static void createVariables()
variables.insert({ "XMRIG_EXE_DIR", Process::location(Process::ExeLocation, "") });
variables.insert({ "XMRIG_CWD", Process::location(Process::CwdLocation, "") });
}
#endif
} // namespace xmrig
@ -66,6 +68,7 @@ static void createVariables()
xmrig::String xmrig::Env::expand(const char *in)
{
# ifdef XMRIG_FEATURE_ENV
if (in == nullptr) {
return {};
}
@ -103,11 +106,15 @@ xmrig::String xmrig::Env::expand(const char *in)
}
return text.c_str();
# else
return in;
# endif
}
xmrig::String xmrig::Env::get(const String &name)
{
# ifdef XMRIG_FEATURE_ENV
if (variables.empty()) {
createVariables();
}
@ -115,6 +122,7 @@ xmrig::String xmrig::Env::get(const String &name)
if (variables.count(name)) {
return variables.at(name);
}
# endif
return static_cast<const char *>(getenv(name));
}