#1469 Fixed build with gcc 4.8.
This commit is contained in:
parent
d5605a29b4
commit
d64bbfa9c0
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user