mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-13 09:58:29 -05:00
KWSys 2020-03-04 (6af2e592)
Code extracted from:
https://gitlab.kitware.com/utils/kwsys.git
at commit 6af2e59217a7e10ed507da564a1445b60ac2a095 (master).
Upstream Shortlog
-----------------
Hans Johnson (17):
81d1e737 STYLE: Use modern path naming
28b8e6c2 STYLE: Convert CMake-language commands to lower case
6ce3d69a DOC: Update documentation for modern add_subdirectory.
8a7fe7ac STYLE: Remove redundant void argument lists
1c3e193d COMP: Use nullptr instead of 0 or NULL
2a4c1252 STYLE: Replace integer literals which are cast to bool.
0fe7214d STYLE: Make prototype match definition names
3b30d0ff STYLE: Make prototype match definition names
691d5612 PERF: readability container size empty
7be4043f STYLE: Prefer c++11 'using' to 'typedef'
acc916ed COMP: Prefer const pointer when value does not change
4c7f64eb COMP: Prefer const member functions
d07092a0 STYLE: Use default member initialization
6d20e7c9 STYLE: Prefer = default to explicitly trivial implementations
91429382 PERF: emplace_back method results in potentially more efficient code
cc8fc323 STYLE: Use auto for variable type matches the type of the initializer
6621b069 STYLE: Use range-based loops from C++11
Julien Schueller (1):
a1a261ac CMake: Fix psapi lib name on case-sensitive fs
This commit is contained in:
committed by
Brad King
parent
4e8c4c7ebe
commit
ec33e3600c
+661
-661
File diff suppressed because it is too large
Load Diff
+15
-23
@@ -66,26 +66,21 @@ class CommandLineArgumentsMapOfStrucs
|
|||||||
class CommandLineArgumentsInternal
|
class CommandLineArgumentsInternal
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CommandLineArgumentsInternal()
|
CommandLineArgumentsInternal() = default;
|
||||||
: UnknownArgumentCallback{ nullptr }
|
|
||||||
, ClientData{ nullptr }
|
|
||||||
, LastArgument{ 0 }
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef CommandLineArgumentsVectorOfStrings VectorOfStrings;
|
using VectorOfStrings = CommandLineArgumentsVectorOfStrings;
|
||||||
typedef CommandLineArgumentsMapOfStrucs CallbacksMap;
|
using CallbacksMap = CommandLineArgumentsMapOfStrucs;
|
||||||
typedef kwsys::String String;
|
using String = kwsys::String;
|
||||||
typedef CommandLineArgumentsSetOfStrings SetOfStrings;
|
using SetOfStrings = CommandLineArgumentsSetOfStrings;
|
||||||
|
|
||||||
VectorOfStrings Argv;
|
VectorOfStrings Argv;
|
||||||
String Argv0;
|
String Argv0;
|
||||||
CallbacksMap Callbacks;
|
CallbacksMap Callbacks;
|
||||||
|
|
||||||
CommandLineArguments::ErrorCallbackType UnknownArgumentCallback;
|
CommandLineArguments::ErrorCallbackType UnknownArgumentCallback{ nullptr };
|
||||||
void* ClientData;
|
void* ClientData{ nullptr };
|
||||||
|
|
||||||
VectorOfStrings::size_type LastArgument;
|
VectorOfStrings::size_type LastArgument{ 0 };
|
||||||
|
|
||||||
VectorOfStrings UnusedArguments;
|
VectorOfStrings UnusedArguments;
|
||||||
};
|
};
|
||||||
@@ -424,8 +419,7 @@ void CommandLineArguments::SetUnknownArgumentCallback(
|
|||||||
|
|
||||||
const char* CommandLineArguments::GetHelp(const char* arg)
|
const char* CommandLineArguments::GetHelp(const char* arg)
|
||||||
{
|
{
|
||||||
CommandLineArguments::Internal::CallbacksMap::iterator it =
|
auto it = this->Internals->Callbacks.find(arg);
|
||||||
this->Internals->Callbacks.find(arg);
|
|
||||||
if (it == this->Internals->Callbacks.end()) {
|
if (it == this->Internals->Callbacks.end()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -434,8 +428,7 @@ const char* CommandLineArguments::GetHelp(const char* arg)
|
|||||||
// one point to if this one is pointing to another argument.
|
// one point to if this one is pointing to another argument.
|
||||||
CommandLineArgumentsCallbackStructure* cs = &(it->second);
|
CommandLineArgumentsCallbackStructure* cs = &(it->second);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
CommandLineArguments::Internal::CallbacksMap::iterator hit =
|
auto hit = this->Internals->Callbacks.find(cs->Help);
|
||||||
this->Internals->Callbacks.find(cs->Help);
|
|
||||||
if (hit == this->Internals->Callbacks.end()) {
|
if (hit == this->Internals->Callbacks.end()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -470,9 +463,8 @@ void CommandLineArguments::GenerateHelp()
|
|||||||
// Collapse all arguments into the map of vectors of all arguments that do
|
// Collapse all arguments into the map of vectors of all arguments that do
|
||||||
// the same thing.
|
// the same thing.
|
||||||
CommandLineArguments::Internal::CallbacksMap::iterator it;
|
CommandLineArguments::Internal::CallbacksMap::iterator it;
|
||||||
typedef std::map<CommandLineArguments::Internal::String,
|
using MapArgs = std::map<CommandLineArguments::Internal::String,
|
||||||
CommandLineArguments::Internal::SetOfStrings>
|
CommandLineArguments::Internal::SetOfStrings>;
|
||||||
MapArgs;
|
|
||||||
MapArgs mp;
|
MapArgs mp;
|
||||||
MapArgs::iterator mpit, smpit;
|
MapArgs::iterator mpit, smpit;
|
||||||
for (it = this->Internals->Callbacks.begin();
|
for (it = this->Internals->Callbacks.begin();
|
||||||
@@ -709,7 +701,7 @@ bool CommandLineArguments::PopulateVariable(
|
|||||||
if (cs->Callback) {
|
if (cs->Callback) {
|
||||||
if (!cs->Callback(cs->Argument, value, cs->CallData)) {
|
if (!cs->Callback(cs->Argument, value, cs->CallData)) {
|
||||||
this->Internals->LastArgument--;
|
this->Internals->LastArgument--;
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CommandLineArguments_DEBUG("Set argument: " << cs->Argument << " to "
|
CommandLineArguments_DEBUG("Set argument: " << cs->Argument << " to "
|
||||||
@@ -759,10 +751,10 @@ bool CommandLineArguments::PopulateVariable(
|
|||||||
std::cerr << "Got unknown variable type: \"" << cs->VariableType
|
std::cerr << "Got unknown variable type: \"" << cs->VariableType
|
||||||
<< "\"" << std::endl;
|
<< "\"" << std::endl;
|
||||||
this->Internals->LastArgument--;
|
this->Internals->LastArgument--;
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace KWSYS_NAMESPACE
|
} // namespace KWSYS_NAMESPACE
|
||||||
|
|||||||
+3
-3
@@ -204,15 +204,15 @@ bool Directory::Load(const std::string& name)
|
|||||||
DIR* dir = opendir(name.c_str());
|
DIR* dir = opendir(name.c_str());
|
||||||
|
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (kwsys_dirent* d = readdir(dir); d; d = readdir(dir)) {
|
for (kwsys_dirent* d = readdir(dir); d; d = readdir(dir)) {
|
||||||
this->Internal->Files.push_back(d->d_name);
|
this->Internal->Files.emplace_back(d->d_name);
|
||||||
}
|
}
|
||||||
this->Internal->Path = name;
|
this->Internal->Path = name;
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
|
unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
MESSAGE("*** This message is generated by message inside a file that is included in DartTestfile.txt ***")
|
message("*** This message is generated by message inside a file that is included in DartTestfile.txt ***")
|
||||||
|
|||||||
@@ -415,8 +415,7 @@ bool Glob::FindFiles(const std::string& inexpr, GlobMessages* messages)
|
|||||||
|
|
||||||
void Glob::AddExpression(const std::string& expr)
|
void Glob::AddExpression(const std::string& expr)
|
||||||
{
|
{
|
||||||
this->Internals->Expressions.push_back(
|
this->Internals->Expressions.emplace_back(this->PatternToRegex(expr));
|
||||||
kwsys::RegularExpression(this->PatternToRegex(expr)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Glob::SetRelative(const char* dir)
|
void Glob::SetRelative(const char* dir)
|
||||||
|
|||||||
+2
-2
@@ -180,8 +180,8 @@ kwsysEXPORT void kwsysProcess_SetPipeShared(kwsysProcess* cp, int pipe,
|
|||||||
* write end of the pipe will be closed in the parent process and the
|
* write end of the pipe will be closed in the parent process and the
|
||||||
* read end will be closed in the child process.
|
* read end will be closed in the child process.
|
||||||
*/
|
*/
|
||||||
kwsysEXPORT void kwsysProcess_SetPipeNative(kwsysProcess* cp, int pipe,
|
kwsysEXPORT void kwsysProcess_SetPipeNative(
|
||||||
kwsysProcess_Pipe_Handle p[2]);
|
kwsysProcess* cp, int pipe, const kwsysProcess_Pipe_Handle p[2]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get/Set a possibly platform-specific option. Possible options are:
|
* Get/Set a possibly platform-specific option. Possible options are:
|
||||||
|
|||||||
+7
-5
@@ -152,10 +152,11 @@ static int kwsysProcessCreate(kwsysProcess* cp, int prIndex,
|
|||||||
static void kwsysProcessDestroy(kwsysProcess* cp);
|
static void kwsysProcessDestroy(kwsysProcess* cp);
|
||||||
static int kwsysProcessSetupOutputPipeFile(int* p, const char* name);
|
static int kwsysProcessSetupOutputPipeFile(int* p, const char* name);
|
||||||
static int kwsysProcessSetupOutputPipeNative(int* p, int des[2]);
|
static int kwsysProcessSetupOutputPipeNative(int* p, int des[2]);
|
||||||
static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
|
static int kwsysProcessGetTimeoutTime(kwsysProcess* cp,
|
||||||
|
const double* userTimeout,
|
||||||
kwsysProcessTime* timeoutTime);
|
kwsysProcessTime* timeoutTime);
|
||||||
static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
|
static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
|
||||||
double* userTimeout,
|
const double* userTimeout,
|
||||||
kwsysProcessTimeNative* timeoutLength,
|
kwsysProcessTimeNative* timeoutLength,
|
||||||
int zeroIsExpired);
|
int zeroIsExpired);
|
||||||
static kwsysProcessTime kwsysProcessTimeGetCurrent(void);
|
static kwsysProcessTime kwsysProcessTimeGetCurrent(void);
|
||||||
@@ -571,7 +572,7 @@ void kwsysProcess_SetPipeShared(kwsysProcess* cp, int prPipe, int shared)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void kwsysProcess_SetPipeNative(kwsysProcess* cp, int prPipe, int p[2])
|
void kwsysProcess_SetPipeNative(kwsysProcess* cp, int prPipe, const int p[2])
|
||||||
{
|
{
|
||||||
int* pPipeNative = 0;
|
int* pPipeNative = 0;
|
||||||
|
|
||||||
@@ -1959,7 +1960,8 @@ static int kwsysProcessSetupOutputPipeNative(int* p, int des[2])
|
|||||||
|
|
||||||
/* Get the time at which either the process or user timeout will
|
/* Get the time at which either the process or user timeout will
|
||||||
expire. Returns 1 if the user timeout is first, and 0 otherwise. */
|
expire. Returns 1 if the user timeout is first, and 0 otherwise. */
|
||||||
static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
|
static int kwsysProcessGetTimeoutTime(kwsysProcess* cp,
|
||||||
|
const double* userTimeout,
|
||||||
kwsysProcessTime* timeoutTime)
|
kwsysProcessTime* timeoutTime)
|
||||||
{
|
{
|
||||||
/* The first time this is called, we need to calculate the time at
|
/* The first time this is called, we need to calculate the time at
|
||||||
@@ -1991,7 +1993,7 @@ static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
|
|||||||
/* Get the length of time before the given timeout time arrives.
|
/* Get the length of time before the given timeout time arrives.
|
||||||
Returns 1 if the time has already arrived, and 0 otherwise. */
|
Returns 1 if the time has already arrived, and 0 otherwise. */
|
||||||
static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
|
static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
|
||||||
double* userTimeout,
|
const double* userTimeout,
|
||||||
kwsysProcessTimeNative* timeoutLength,
|
kwsysProcessTimeNative* timeoutLength,
|
||||||
int zeroIsExpired)
|
int zeroIsExpired)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -761,7 +761,7 @@ void kwsysProcess_SetPipeShared(kwsysProcess* cp, int pipe, int shared)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void kwsysProcess_SetPipeNative(kwsysProcess* cp, int pipe, HANDLE p[2])
|
void kwsysProcess_SetPipeNative(kwsysProcess* cp, int pipe, const HANDLE p[2])
|
||||||
{
|
{
|
||||||
HANDLE* pPipeNative = 0;
|
HANDLE* pPipeNative = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ typedef ptrdiff_t kwsysSystem_ptrdiff_t;
|
|||||||
typedef int kwsysSystem_ptrdiff_t;
|
typedef int kwsysSystem_ptrdiff_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int kwsysSystem__AppendByte(char* local, char** begin, char** end,
|
static int kwsysSystem__AppendByte(const char* local, char** begin, char** end,
|
||||||
int* size, char c)
|
int* size, char c)
|
||||||
{
|
{
|
||||||
/* Allocate space for the character. */
|
/* Allocate space for the character. */
|
||||||
|
|||||||
+118
-77
@@ -132,7 +132,7 @@ typedef int siginfo_t;
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# if defined(KWSYS_CXX_HAS_RLIMIT64)
|
# if defined(KWSYS_CXX_HAS_RLIMIT64)
|
||||||
typedef struct rlimit64 ResourceLimitType;
|
using ResourceLimitType = struct rlimit64;
|
||||||
# define GetResourceLimit getrlimit64
|
# define GetResourceLimit getrlimit64
|
||||||
# else
|
# else
|
||||||
typedef struct rlimit ResourceLimitType;
|
typedef struct rlimit ResourceLimitType;
|
||||||
@@ -303,34 +303,34 @@ T min(T a, T b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
typedef void (*SigAction)(int, siginfo_t*, void*);
|
using SigAction = void (*)(int, siginfo_t*, void*);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define SystemInformationImplementation class
|
// Define SystemInformationImplementation class
|
||||||
typedef void (*DELAY_FUNC)(unsigned int uiMS);
|
using DELAY_FUNC = void (*)(unsigned int);
|
||||||
|
|
||||||
class SystemInformationImplementation
|
class SystemInformationImplementation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef SystemInformation::LongLong LongLong;
|
using LongLong = SystemInformation::LongLong;
|
||||||
SystemInformationImplementation();
|
SystemInformationImplementation();
|
||||||
~SystemInformationImplementation();
|
~SystemInformationImplementation() = default;
|
||||||
|
|
||||||
const char* GetVendorString();
|
const char* GetVendorString() const;
|
||||||
const char* GetVendorID();
|
const char* GetVendorID();
|
||||||
std::string GetTypeID();
|
std::string GetTypeID() const;
|
||||||
std::string GetFamilyID();
|
std::string GetFamilyID() const;
|
||||||
std::string GetModelID();
|
std::string GetModelID() const;
|
||||||
std::string GetModelName();
|
std::string GetModelName() const;
|
||||||
std::string GetSteppingCode();
|
std::string GetSteppingCode() const;
|
||||||
const char* GetExtendedProcessorName();
|
const char* GetExtendedProcessorName() const;
|
||||||
const char* GetProcessorSerialNumber();
|
const char* GetProcessorSerialNumber() const;
|
||||||
int GetProcessorCacheSize();
|
int GetProcessorCacheSize() const;
|
||||||
unsigned int GetLogicalProcessorsPerPhysical();
|
unsigned int GetLogicalProcessorsPerPhysical() const;
|
||||||
float GetProcessorClockFrequency();
|
float GetProcessorClockFrequency() const;
|
||||||
int GetProcessorAPICID();
|
int GetProcessorAPICID() const;
|
||||||
int GetProcessorCacheXSize(long int);
|
int GetProcessorCacheXSize(long int) const;
|
||||||
bool DoesCPUSupportFeature(long int);
|
bool DoesCPUSupportFeature(long int) const;
|
||||||
|
|
||||||
const char* GetOSName();
|
const char* GetOSName();
|
||||||
const char* GetHostname();
|
const char* GetHostname();
|
||||||
@@ -339,24 +339,24 @@ public:
|
|||||||
const char* GetOSVersion();
|
const char* GetOSVersion();
|
||||||
const char* GetOSPlatform();
|
const char* GetOSPlatform();
|
||||||
|
|
||||||
bool Is64Bits();
|
bool Is64Bits() const;
|
||||||
|
|
||||||
unsigned int GetNumberOfLogicalCPU(); // per physical cpu
|
unsigned int GetNumberOfLogicalCPU() const; // per physical cpu
|
||||||
unsigned int GetNumberOfPhysicalCPU();
|
unsigned int GetNumberOfPhysicalCPU() const;
|
||||||
|
|
||||||
bool DoesCPUSupportCPUID();
|
bool DoesCPUSupportCPUID();
|
||||||
|
|
||||||
// Retrieve memory information in MiB.
|
// Retrieve memory information in MiB.
|
||||||
size_t GetTotalVirtualMemory();
|
size_t GetTotalVirtualMemory() const;
|
||||||
size_t GetAvailableVirtualMemory();
|
size_t GetAvailableVirtualMemory() const;
|
||||||
size_t GetTotalPhysicalMemory();
|
size_t GetTotalPhysicalMemory() const;
|
||||||
size_t GetAvailablePhysicalMemory();
|
size_t GetAvailablePhysicalMemory() const;
|
||||||
|
|
||||||
LongLong GetProcessId();
|
LongLong GetProcessId();
|
||||||
|
|
||||||
// Retrieve memory information in KiB.
|
// Retrieve memory information in KiB.
|
||||||
LongLong GetHostMemoryTotal();
|
LongLong GetHostMemoryTotal();
|
||||||
LongLong GetHostMemoryAvailable(const char* envVarName);
|
LongLong GetHostMemoryAvailable(const char* hostLimitEnvVarName);
|
||||||
LongLong GetHostMemoryUsed();
|
LongLong GetHostMemoryUsed();
|
||||||
|
|
||||||
LongLong GetProcMemoryAvailable(const char* hostLimitEnvVarName,
|
LongLong GetProcMemoryAvailable(const char* hostLimitEnvVarName,
|
||||||
@@ -377,60 +377,103 @@ public:
|
|||||||
void RunMemoryCheck();
|
void RunMemoryCheck();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef struct tagID
|
using ID = struct tagID
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
int Type;
|
int Type;
|
||||||
|
|
||||||
int Family;
|
int Family;
|
||||||
|
|
||||||
int Model;
|
int Model;
|
||||||
|
|
||||||
int Revision;
|
int Revision;
|
||||||
|
|
||||||
int ExtendedFamily;
|
int ExtendedFamily;
|
||||||
|
|
||||||
int ExtendedModel;
|
int ExtendedModel;
|
||||||
|
|
||||||
std::string ProcessorName;
|
std::string ProcessorName;
|
||||||
|
|
||||||
std::string Vendor;
|
std::string Vendor;
|
||||||
|
|
||||||
std::string SerialNumber;
|
std::string SerialNumber;
|
||||||
|
|
||||||
std::string ModelName;
|
std::string ModelName;
|
||||||
} ID;
|
};
|
||||||
|
|
||||||
|
using CPUPowerManagement = struct tagCPUPowerManagement
|
||||||
|
|
||||||
typedef struct tagCPUPowerManagement
|
|
||||||
{
|
{
|
||||||
|
|
||||||
bool HasVoltageID;
|
bool HasVoltageID;
|
||||||
|
|
||||||
bool HasFrequencyID;
|
bool HasFrequencyID;
|
||||||
|
|
||||||
bool HasTempSenseDiode;
|
bool HasTempSenseDiode;
|
||||||
} CPUPowerManagement;
|
};
|
||||||
|
|
||||||
|
using CPUExtendedFeatures = struct tagCPUExtendedFeatures
|
||||||
|
|
||||||
typedef struct tagCPUExtendedFeatures
|
|
||||||
{
|
{
|
||||||
|
|
||||||
bool Has3DNow;
|
bool Has3DNow;
|
||||||
bool Has3DNowPlus;
|
|
||||||
bool SupportsMP;
|
|
||||||
bool HasMMXPlus;
|
|
||||||
bool HasSSEMMX;
|
|
||||||
unsigned int LogicalProcessorsPerPhysical;
|
|
||||||
int APIC_ID;
|
|
||||||
CPUPowerManagement PowerManagement;
|
|
||||||
} CPUExtendedFeatures;
|
|
||||||
|
|
||||||
typedef struct CPUtagFeatures
|
bool Has3DNowPlus;
|
||||||
|
|
||||||
|
bool SupportsMP;
|
||||||
|
|
||||||
|
bool HasMMXPlus;
|
||||||
|
|
||||||
|
bool HasSSEMMX;
|
||||||
|
|
||||||
|
unsigned int LogicalProcessorsPerPhysical;
|
||||||
|
|
||||||
|
int APIC_ID;
|
||||||
|
|
||||||
|
CPUPowerManagement PowerManagement;
|
||||||
|
};
|
||||||
|
|
||||||
|
using CPUFeatures = struct CPUtagFeatures
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
bool HasFPU;
|
bool HasFPU;
|
||||||
|
|
||||||
bool HasTSC;
|
bool HasTSC;
|
||||||
|
|
||||||
bool HasMMX;
|
bool HasMMX;
|
||||||
|
|
||||||
bool HasSSE;
|
bool HasSSE;
|
||||||
|
|
||||||
bool HasSSEFP;
|
bool HasSSEFP;
|
||||||
|
|
||||||
bool HasSSE2;
|
bool HasSSE2;
|
||||||
|
|
||||||
bool HasIA64;
|
bool HasIA64;
|
||||||
|
|
||||||
bool HasAPIC;
|
bool HasAPIC;
|
||||||
|
|
||||||
bool HasCMOV;
|
bool HasCMOV;
|
||||||
|
|
||||||
bool HasMTRR;
|
bool HasMTRR;
|
||||||
|
|
||||||
bool HasACPI;
|
bool HasACPI;
|
||||||
|
|
||||||
bool HasSerial;
|
bool HasSerial;
|
||||||
|
|
||||||
bool HasThermal;
|
bool HasThermal;
|
||||||
|
|
||||||
int CPUSpeed;
|
int CPUSpeed;
|
||||||
|
|
||||||
int L1CacheSize;
|
int L1CacheSize;
|
||||||
|
|
||||||
int L2CacheSize;
|
int L2CacheSize;
|
||||||
|
|
||||||
int L3CacheSize;
|
int L3CacheSize;
|
||||||
|
|
||||||
CPUExtendedFeatures ExtendedFeatures;
|
CPUExtendedFeatures ExtendedFeatures;
|
||||||
} CPUFeatures;
|
};
|
||||||
|
|
||||||
enum Manufacturer
|
enum Manufacturer
|
||||||
{
|
{
|
||||||
@@ -476,7 +519,7 @@ protected:
|
|||||||
|
|
||||||
void CPUCountWindows(); // For windows
|
void CPUCountWindows(); // For windows
|
||||||
unsigned char GetAPICId(); // For windows
|
unsigned char GetAPICId(); // For windows
|
||||||
bool IsSMTSupported();
|
bool IsSMTSupported() const;
|
||||||
static LongLong GetCyclesDifference(DELAY_FUNC, unsigned int); // For windows
|
static LongLong GetCyclesDifference(DELAY_FUNC, unsigned int); // For windows
|
||||||
|
|
||||||
// For Linux and Cygwin, /proc/cpuinfo formats are slightly different
|
// For Linux and Cygwin, /proc/cpuinfo formats are slightly different
|
||||||
@@ -885,7 +928,7 @@ int LoadLines(FILE* file, std::vector<std::string>& lines)
|
|||||||
*pBuf = '\0';
|
*pBuf = '\0';
|
||||||
pBuf += 1;
|
pBuf += 1;
|
||||||
}
|
}
|
||||||
lines.push_back(buf);
|
lines.emplace_back(buf);
|
||||||
++nRead;
|
++nRead;
|
||||||
}
|
}
|
||||||
if (ferror(file)) {
|
if (ferror(file)) {
|
||||||
@@ -899,7 +942,7 @@ int LoadLines(FILE* file, std::vector<std::string>& lines)
|
|||||||
int LoadLines(const char* fileName, std::vector<std::string>& lines)
|
int LoadLines(const char* fileName, std::vector<std::string>& lines)
|
||||||
{
|
{
|
||||||
FILE* file = fopen(fileName, "r");
|
FILE* file = fopen(fileName, "r");
|
||||||
if (file == 0) {
|
if (file == nullptr) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int nRead = LoadLines(file, lines);
|
int nRead = LoadLines(file, lines);
|
||||||
@@ -1464,10 +1507,6 @@ SystemInformationImplementation::SystemInformationImplementation()
|
|||||||
this->OSIs64Bit = (sizeof(void*) == 8);
|
this->OSIs64Bit = (sizeof(void*) == 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemInformationImplementation::~SystemInformationImplementation()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void SystemInformationImplementation::RunCPUCheck()
|
void SystemInformationImplementation::RunCPUCheck()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -1564,7 +1603,7 @@ void SystemInformationImplementation::RunMemoryCheck()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Get the vendor string */
|
/** Get the vendor string */
|
||||||
const char* SystemInformationImplementation::GetVendorString()
|
const char* SystemInformationImplementation::GetVendorString() const
|
||||||
{
|
{
|
||||||
return this->ChipID.Vendor.c_str();
|
return this->ChipID.Vendor.c_str();
|
||||||
}
|
}
|
||||||
@@ -1760,7 +1799,7 @@ const char* SystemInformationImplementation::GetVendorID()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Return the type ID of the CPU */
|
/** Return the type ID of the CPU */
|
||||||
std::string SystemInformationImplementation::GetTypeID()
|
std::string SystemInformationImplementation::GetTypeID() const
|
||||||
{
|
{
|
||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
str << this->ChipID.Type;
|
str << this->ChipID.Type;
|
||||||
@@ -1768,7 +1807,7 @@ std::string SystemInformationImplementation::GetTypeID()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Return the family of the CPU present */
|
/** Return the family of the CPU present */
|
||||||
std::string SystemInformationImplementation::GetFamilyID()
|
std::string SystemInformationImplementation::GetFamilyID() const
|
||||||
{
|
{
|
||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
str << this->ChipID.Family;
|
str << this->ChipID.Family;
|
||||||
@@ -1776,7 +1815,7 @@ std::string SystemInformationImplementation::GetFamilyID()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return the model of CPU present */
|
// Return the model of CPU present */
|
||||||
std::string SystemInformationImplementation::GetModelID()
|
std::string SystemInformationImplementation::GetModelID() const
|
||||||
{
|
{
|
||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
str << this->ChipID.Model;
|
str << this->ChipID.Model;
|
||||||
@@ -1784,13 +1823,13 @@ std::string SystemInformationImplementation::GetModelID()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return the model name of CPU present */
|
// Return the model name of CPU present */
|
||||||
std::string SystemInformationImplementation::GetModelName()
|
std::string SystemInformationImplementation::GetModelName() const
|
||||||
{
|
{
|
||||||
return this->ChipID.ModelName;
|
return this->ChipID.ModelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the stepping code of the CPU present. */
|
/** Return the stepping code of the CPU present. */
|
||||||
std::string SystemInformationImplementation::GetSteppingCode()
|
std::string SystemInformationImplementation::GetSteppingCode() const
|
||||||
{
|
{
|
||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
str << this->ChipID.Revision;
|
str << this->ChipID.Revision;
|
||||||
@@ -1798,44 +1837,46 @@ std::string SystemInformationImplementation::GetSteppingCode()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Return the stepping code of the CPU present. */
|
/** Return the stepping code of the CPU present. */
|
||||||
const char* SystemInformationImplementation::GetExtendedProcessorName()
|
const char* SystemInformationImplementation::GetExtendedProcessorName() const
|
||||||
{
|
{
|
||||||
return this->ChipID.ProcessorName.c_str();
|
return this->ChipID.ProcessorName.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the serial number of the processor
|
/** Return the serial number of the processor
|
||||||
* in hexadecimal: xxxx-xxxx-xxxx-xxxx-xxxx-xxxx. */
|
* in hexadecimal: xxxx-xxxx-xxxx-xxxx-xxxx-xxxx. */
|
||||||
const char* SystemInformationImplementation::GetProcessorSerialNumber()
|
const char* SystemInformationImplementation::GetProcessorSerialNumber() const
|
||||||
{
|
{
|
||||||
return this->ChipID.SerialNumber.c_str();
|
return this->ChipID.SerialNumber.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the logical processors per physical */
|
/** Return the logical processors per physical */
|
||||||
unsigned int SystemInformationImplementation::GetLogicalProcessorsPerPhysical()
|
unsigned int SystemInformationImplementation::GetLogicalProcessorsPerPhysical()
|
||||||
|
const
|
||||||
{
|
{
|
||||||
return this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical;
|
return this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the processor clock frequency. */
|
/** Return the processor clock frequency. */
|
||||||
float SystemInformationImplementation::GetProcessorClockFrequency()
|
float SystemInformationImplementation::GetProcessorClockFrequency() const
|
||||||
{
|
{
|
||||||
return this->CPUSpeedInMHz;
|
return this->CPUSpeedInMHz;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the APIC ID. */
|
/** Return the APIC ID. */
|
||||||
int SystemInformationImplementation::GetProcessorAPICID()
|
int SystemInformationImplementation::GetProcessorAPICID() const
|
||||||
{
|
{
|
||||||
return this->Features.ExtendedFeatures.APIC_ID;
|
return this->Features.ExtendedFeatures.APIC_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the L1 cache size. */
|
/** Return the L1 cache size. */
|
||||||
int SystemInformationImplementation::GetProcessorCacheSize()
|
int SystemInformationImplementation::GetProcessorCacheSize() const
|
||||||
{
|
{
|
||||||
return this->Features.L1CacheSize;
|
return this->Features.L1CacheSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the chosen cache size. */
|
/** Return the chosen cache size. */
|
||||||
int SystemInformationImplementation::GetProcessorCacheXSize(long int dwCacheID)
|
int SystemInformationImplementation::GetProcessorCacheXSize(
|
||||||
|
long int dwCacheID) const
|
||||||
{
|
{
|
||||||
switch (dwCacheID) {
|
switch (dwCacheID) {
|
||||||
case SystemInformation::CPU_FEATURE_L1CACHE:
|
case SystemInformation::CPU_FEATURE_L1CACHE:
|
||||||
@@ -1848,7 +1889,8 @@ int SystemInformationImplementation::GetProcessorCacheXSize(long int dwCacheID)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SystemInformationImplementation::DoesCPUSupportFeature(long int dwFeature)
|
bool SystemInformationImplementation::DoesCPUSupportFeature(
|
||||||
|
long int dwFeature) const
|
||||||
{
|
{
|
||||||
bool bHasFeature = false;
|
bool bHasFeature = false;
|
||||||
|
|
||||||
@@ -3409,7 +3451,7 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
|
|||||||
// We want to record the total number of cores in this->NumberOfPhysicalCPU
|
// We want to record the total number of cores in this->NumberOfPhysicalCPU
|
||||||
// (checking only the first proc)
|
// (checking only the first proc)
|
||||||
std::string Cores = this->ExtractValueFromCpuInfoFile(buffer, "cpu cores");
|
std::string Cores = this->ExtractValueFromCpuInfoFile(buffer, "cpu cores");
|
||||||
unsigned int NumberOfCoresPerSocket = (unsigned int)atoi(Cores.c_str());
|
auto NumberOfCoresPerSocket = (unsigned int)atoi(Cores.c_str());
|
||||||
NumberOfCoresPerSocket = std::max(NumberOfCoresPerSocket, 1u);
|
NumberOfCoresPerSocket = std::max(NumberOfCoresPerSocket, 1u);
|
||||||
this->NumberOfPhysicalCPU =
|
this->NumberOfPhysicalCPU =
|
||||||
NumberOfCoresPerSocket * (unsigned int)NumberOfSockets;
|
NumberOfCoresPerSocket * (unsigned int)NumberOfSockets;
|
||||||
@@ -3441,7 +3483,7 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
|
|||||||
// Linux Sparc: CPU speed is in Hz and encoded in hexadecimal
|
// Linux Sparc: CPU speed is in Hz and encoded in hexadecimal
|
||||||
CPUSpeed = this->ExtractValueFromCpuInfoFile(buffer, "Cpu0ClkTck");
|
CPUSpeed = this->ExtractValueFromCpuInfoFile(buffer, "Cpu0ClkTck");
|
||||||
this->CPUSpeedInMHz =
|
this->CPUSpeedInMHz =
|
||||||
static_cast<float>(strtoull(CPUSpeed.c_str(), 0, 16)) / 1000000.0f;
|
static_cast<float>(strtoull(CPUSpeed.c_str(), nullptr, 16)) / 1000000.0f;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -3502,9 +3544,8 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
|
|||||||
cachename.push_back("D-cache"); // e.g. PA-RISC
|
cachename.push_back("D-cache"); // e.g. PA-RISC
|
||||||
|
|
||||||
this->Features.L1CacheSize = 0;
|
this->Features.L1CacheSize = 0;
|
||||||
for (size_t index = 0; index < cachename.size(); index++) {
|
for (auto& index : cachename) {
|
||||||
std::string cacheSize =
|
std::string cacheSize = this->ExtractValueFromCpuInfoFile(buffer, index);
|
||||||
this->ExtractValueFromCpuInfoFile(buffer, cachename[index]);
|
|
||||||
if (!cacheSize.empty()) {
|
if (!cacheSize.empty()) {
|
||||||
pos = cacheSize.find(" KB");
|
pos = cacheSize.find(" KB");
|
||||||
if (pos != std::string::npos) {
|
if (pos != std::string::npos) {
|
||||||
@@ -4249,24 +4290,24 @@ bool SystemInformationImplementation::QueryMemory()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
size_t SystemInformationImplementation::GetTotalVirtualMemory()
|
size_t SystemInformationImplementation::GetTotalVirtualMemory() const
|
||||||
{
|
{
|
||||||
return this->TotalVirtualMemory;
|
return this->TotalVirtualMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
size_t SystemInformationImplementation::GetAvailableVirtualMemory()
|
size_t SystemInformationImplementation::GetAvailableVirtualMemory() const
|
||||||
{
|
{
|
||||||
return this->AvailableVirtualMemory;
|
return this->AvailableVirtualMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SystemInformationImplementation::GetTotalPhysicalMemory()
|
size_t SystemInformationImplementation::GetTotalPhysicalMemory() const
|
||||||
{
|
{
|
||||||
return this->TotalPhysicalMemory;
|
return this->TotalPhysicalMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
size_t SystemInformationImplementation::GetAvailablePhysicalMemory()
|
size_t SystemInformationImplementation::GetAvailablePhysicalMemory() const
|
||||||
{
|
{
|
||||||
return this->AvailablePhysicalMemory;
|
return this->AvailablePhysicalMemory;
|
||||||
}
|
}
|
||||||
@@ -4350,7 +4391,7 @@ void SystemInformationImplementation::DelayOverhead(unsigned int uiMS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Works only for windows */
|
/** Works only for windows */
|
||||||
bool SystemInformationImplementation::IsSMTSupported()
|
bool SystemInformationImplementation::IsSMTSupported() const
|
||||||
{
|
{
|
||||||
return this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical > 1;
|
return this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical > 1;
|
||||||
}
|
}
|
||||||
@@ -4432,13 +4473,13 @@ void SystemInformationImplementation::CPUCountWindows()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Return the number of logical CPUs on the system */
|
/** Return the number of logical CPUs on the system */
|
||||||
unsigned int SystemInformationImplementation::GetNumberOfLogicalCPU()
|
unsigned int SystemInformationImplementation::GetNumberOfLogicalCPU() const
|
||||||
{
|
{
|
||||||
return this->NumberOfLogicalCPU;
|
return this->NumberOfLogicalCPU;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the number of physical CPUs on the system */
|
/** Return the number of physical CPUs on the system */
|
||||||
unsigned int SystemInformationImplementation::GetNumberOfPhysicalCPU()
|
unsigned int SystemInformationImplementation::GetNumberOfPhysicalCPU() const
|
||||||
{
|
{
|
||||||
return this->NumberOfPhysicalCPU;
|
return this->NumberOfPhysicalCPU;
|
||||||
}
|
}
|
||||||
@@ -4739,8 +4780,8 @@ std::string SystemInformationImplementation::ParseValueFromKStat(
|
|||||||
args.reserve(3 + args_string.size());
|
args.reserve(3 + args_string.size());
|
||||||
args.push_back("kstat");
|
args.push_back("kstat");
|
||||||
args.push_back("-p");
|
args.push_back("-p");
|
||||||
for (size_t i = 0; i < args_string.size(); ++i) {
|
for (auto& i : args_string) {
|
||||||
args.push_back(args_string[i].c_str());
|
args.push_back(i.c_str());
|
||||||
}
|
}
|
||||||
args.push_back(nullptr);
|
args.push_back(nullptr);
|
||||||
|
|
||||||
@@ -5459,7 +5500,7 @@ void SystemInformationImplementation::TrimNewline(std::string& output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Return true if the machine is 64 bits */
|
/** Return true if the machine is 64 bits */
|
||||||
bool SystemInformationImplementation::Is64Bits()
|
bool SystemInformationImplementation::Is64Bits() const
|
||||||
{
|
{
|
||||||
return this->OSIs64Bit;
|
return this->OSIs64Bit;
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-13
@@ -350,7 +350,7 @@ extern int putenv(char* __string) __THROW;
|
|||||||
|
|
||||||
namespace KWSYS_NAMESPACE {
|
namespace KWSYS_NAMESPACE {
|
||||||
|
|
||||||
double SystemTools::GetTime(void)
|
double SystemTools::GetTime()
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
@@ -368,7 +368,7 @@ double SystemTools::GetTime(void)
|
|||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
typedef wchar_t envchar;
|
typedef wchar_t envchar;
|
||||||
#else
|
#else
|
||||||
typedef char envchar;
|
using envchar = char;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Order by environment key only (VAR from VAR=VALUE). */
|
/* Order by environment key only (VAR from VAR=VALUE). */
|
||||||
@@ -421,7 +421,7 @@ public:
|
|||||||
const envchar* Release(const envchar* env)
|
const envchar* Release(const envchar* env)
|
||||||
{
|
{
|
||||||
const envchar* old = nullptr;
|
const envchar* old = nullptr;
|
||||||
iterator i = this->find(env);
|
auto i = this->find(env);
|
||||||
if (i != this->end()) {
|
if (i != this->end()) {
|
||||||
old = *i;
|
old = *i;
|
||||||
this->erase(i);
|
this->erase(i);
|
||||||
@@ -452,7 +452,7 @@ struct SystemToolsPathCaseCmp
|
|||||||
class SystemToolsStatic
|
class SystemToolsStatic
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::map<std::string, std::string> StringMap;
|
using StringMap = std::map<std::string, std::string>;
|
||||||
#if KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP
|
#if KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP
|
||||||
/**
|
/**
|
||||||
* Path translation table from dir to refdir
|
* Path translation table from dir to refdir
|
||||||
@@ -488,7 +488,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
static std::string FindName(
|
static std::string FindName(
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
const std::vector<std::string>& path = std::vector<std::string>(),
|
const std::vector<std::string>& userPaths = std::vector<std::string>(),
|
||||||
bool no_system_path = false);
|
bool no_system_path = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -613,8 +613,7 @@ void SystemTools::GetPath(std::vector<std::string>& path, const char* env)
|
|||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (std::vector<std::string>::iterator i = path.begin() + old_size;
|
for (auto i = path.begin() + old_size; i != path.end(); ++i) {
|
||||||
i != path.end(); ++i) {
|
|
||||||
SystemTools::ConvertToUnixSlashes(*i);
|
SystemTools::ConvertToUnixSlashes(*i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1858,7 +1857,7 @@ char* SystemTools::DuplicateString(const char* str)
|
|||||||
// Return a cropped string
|
// Return a cropped string
|
||||||
std::string SystemTools::CropString(const std::string& s, size_t max_len)
|
std::string SystemTools::CropString(const std::string& s, size_t max_len)
|
||||||
{
|
{
|
||||||
if (!s.size() || max_len == 0 || max_len >= s.size()) {
|
if (s.empty() || max_len == 0 || max_len >= s.size()) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1893,7 +1892,7 @@ std::vector<std::string> SystemTools::SplitString(const std::string& p,
|
|||||||
}
|
}
|
||||||
if (isPath && path[0] == '/') {
|
if (isPath && path[0] == '/') {
|
||||||
path.erase(path.begin());
|
path.erase(path.begin());
|
||||||
paths.push_back("/");
|
paths.emplace_back("/");
|
||||||
}
|
}
|
||||||
std::string::size_type pos1 = 0;
|
std::string::size_type pos1 = 0;
|
||||||
std::string::size_type pos2 = path.find(sep, pos1 + 1);
|
std::string::size_type pos2 = path.find(sep, pos1 + 1);
|
||||||
@@ -3571,14 +3570,14 @@ void SystemTools::SplitPath(const std::string& p,
|
|||||||
for (; *last; ++last) {
|
for (; *last; ++last) {
|
||||||
if (*last == '/' || *last == '\\') {
|
if (*last == '/' || *last == '\\') {
|
||||||
// End of a component. Save it.
|
// End of a component. Save it.
|
||||||
components.push_back(std::string(first, last));
|
components.emplace_back(first, last);
|
||||||
first = last + 1;
|
first = last + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the last component unless there were no components.
|
// Save the last component unless there were no components.
|
||||||
if (last != c) {
|
if (last != c) {
|
||||||
components.push_back(std::string(first, last));
|
components.emplace_back(first, last);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3594,7 +3593,7 @@ std::string SystemTools::JoinPath(
|
|||||||
// Construct result in a single string.
|
// Construct result in a single string.
|
||||||
std::string result;
|
std::string result;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
for (std::vector<std::string>::const_iterator i = first; i != last; ++i) {
|
for (auto i = first; i != last; ++i) {
|
||||||
len += 1 + i->size();
|
len += 1 + i->size();
|
||||||
}
|
}
|
||||||
result.reserve(len);
|
result.reserve(len);
|
||||||
@@ -3828,7 +3827,7 @@ SystemTools::FileTypeEnum SystemTools::DetectFileType(const char* filename,
|
|||||||
|
|
||||||
// Allocate buffer and read bytes
|
// Allocate buffer and read bytes
|
||||||
|
|
||||||
unsigned char* buffer = new unsigned char[length];
|
auto* buffer = new unsigned char[length];
|
||||||
size_t read_length = fread(buffer, 1, length, fp);
|
size_t read_length = fread(buffer, 1, length, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if (read_length == 0) {
|
if (read_length == 0) {
|
||||||
|
|||||||
+150
-150
@@ -1,185 +1,185 @@
|
|||||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
# file Copyright.txt or https://cmake.org/licensing#kwsys for details.
|
# file Copyright.txt or https://cmake.org/licensing#kwsys for details.
|
||||||
|
|
||||||
SET(KWSYS_PLATFORM_TEST_FILE_C kwsysPlatformTestsC.c)
|
set(KWSYS_PLATFORM_TEST_FILE_C kwsysPlatformTestsC.c)
|
||||||
SET(KWSYS_PLATFORM_TEST_FILE_CXX kwsysPlatformTestsCXX.cxx)
|
set(KWSYS_PLATFORM_TEST_FILE_CXX kwsysPlatformTestsCXX.cxx)
|
||||||
|
|
||||||
MACRO(KWSYS_PLATFORM_TEST lang var description invert)
|
macro(KWSYS_PLATFORM_TEST lang var description invert)
|
||||||
IF(NOT DEFINED ${var}_COMPILED)
|
if(NOT DEFINED ${var}_COMPILED)
|
||||||
MESSAGE(STATUS "${description}")
|
message(STATUS "${description}")
|
||||||
set(maybe_cxx_standard "")
|
set(maybe_cxx_standard "")
|
||||||
if(CMAKE_VERSION VERSION_LESS 3.8 AND CMAKE_CXX_STANDARD)
|
if(CMAKE_VERSION VERSION_LESS 3.8 AND CMAKE_CXX_STANDARD)
|
||||||
set(maybe_cxx_standard "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}")
|
set(maybe_cxx_standard "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}")
|
||||||
endif()
|
endif()
|
||||||
TRY_COMPILE(${var}_COMPILED
|
try_compile(${var}_COMPILED
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}}
|
${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}}
|
||||||
COMPILE_DEFINITIONS -DTEST_${var} ${KWSYS_PLATFORM_TEST_DEFINES} ${KWSYS_PLATFORM_TEST_EXTRA_FLAGS}
|
COMPILE_DEFINITIONS -DTEST_${var} ${KWSYS_PLATFORM_TEST_DEFINES} ${KWSYS_PLATFORM_TEST_EXTRA_FLAGS}
|
||||||
CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=${KWSYS_PLATFORM_TEST_LINK_LIBRARIES}"
|
CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=${KWSYS_PLATFORM_TEST_LINK_LIBRARIES}"
|
||||||
${maybe_cxx_standard}
|
${maybe_cxx_standard}
|
||||||
OUTPUT_VARIABLE OUTPUT)
|
OUTPUT_VARIABLE OUTPUT)
|
||||||
IF(${var}_COMPILED)
|
if(${var}_COMPILED)
|
||||||
FILE(APPEND
|
file(APPEND
|
||||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||||
"${description} compiled with the following output:\n${OUTPUT}\n\n")
|
"${description} compiled with the following output:\n${OUTPUT}\n\n")
|
||||||
ELSE()
|
else()
|
||||||
FILE(APPEND
|
file(APPEND
|
||||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||||
"${description} failed to compile with the following output:\n${OUTPUT}\n\n")
|
"${description} failed to compile with the following output:\n${OUTPUT}\n\n")
|
||||||
ENDIF()
|
endif()
|
||||||
IF(${invert} MATCHES INVERT)
|
if(${invert} MATCHES INVERT)
|
||||||
IF(${var}_COMPILED)
|
if(${var}_COMPILED)
|
||||||
MESSAGE(STATUS "${description} - no")
|
message(STATUS "${description} - no")
|
||||||
ELSE()
|
else()
|
||||||
MESSAGE(STATUS "${description} - yes")
|
message(STATUS "${description} - yes")
|
||||||
ENDIF()
|
endif()
|
||||||
ELSE()
|
else()
|
||||||
IF(${var}_COMPILED)
|
if(${var}_COMPILED)
|
||||||
MESSAGE(STATUS "${description} - yes")
|
message(STATUS "${description} - yes")
|
||||||
ELSE()
|
else()
|
||||||
MESSAGE(STATUS "${description} - no")
|
message(STATUS "${description} - no")
|
||||||
ENDIF()
|
endif()
|
||||||
ENDIF()
|
endif()
|
||||||
ENDIF()
|
endif()
|
||||||
IF(${invert} MATCHES INVERT)
|
if(${invert} MATCHES INVERT)
|
||||||
IF(${var}_COMPILED)
|
if(${var}_COMPILED)
|
||||||
SET(${var} 0)
|
set(${var} 0)
|
||||||
ELSE()
|
else()
|
||||||
SET(${var} 1)
|
set(${var} 1)
|
||||||
ENDIF()
|
endif()
|
||||||
ELSE()
|
else()
|
||||||
IF(${var}_COMPILED)
|
if(${var}_COMPILED)
|
||||||
SET(${var} 1)
|
set(${var} 1)
|
||||||
ELSE()
|
else()
|
||||||
SET(${var} 0)
|
set(${var} 0)
|
||||||
ENDIF()
|
endif()
|
||||||
ENDIF()
|
endif()
|
||||||
ENDMACRO()
|
endmacro()
|
||||||
|
|
||||||
MACRO(KWSYS_PLATFORM_TEST_RUN lang var description invert)
|
macro(KWSYS_PLATFORM_TEST_RUN lang var description invert)
|
||||||
IF(NOT DEFINED ${var})
|
if(NOT DEFINED ${var})
|
||||||
MESSAGE(STATUS "${description}")
|
message(STATUS "${description}")
|
||||||
TRY_RUN(${var} ${var}_COMPILED
|
try_run(${var} ${var}_COMPILED
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}}
|
${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}}
|
||||||
COMPILE_DEFINITIONS -DTEST_${var} ${KWSYS_PLATFORM_TEST_DEFINES} ${KWSYS_PLATFORM_TEST_EXTRA_FLAGS}
|
COMPILE_DEFINITIONS -DTEST_${var} ${KWSYS_PLATFORM_TEST_DEFINES} ${KWSYS_PLATFORM_TEST_EXTRA_FLAGS}
|
||||||
OUTPUT_VARIABLE OUTPUT)
|
OUTPUT_VARIABLE OUTPUT)
|
||||||
|
|
||||||
# Note that ${var} will be a 0 return value on success.
|
# Note that ${var} will be a 0 return value on success.
|
||||||
IF(${var}_COMPILED)
|
if(${var}_COMPILED)
|
||||||
IF(${var})
|
if(${var})
|
||||||
FILE(APPEND
|
file(APPEND
|
||||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||||
"${description} compiled but failed to run with the following output:\n${OUTPUT}\n\n")
|
"${description} compiled but failed to run with the following output:\n${OUTPUT}\n\n")
|
||||||
ELSE()
|
else()
|
||||||
FILE(APPEND
|
file(APPEND
|
||||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||||
"${description} compiled and ran with the following output:\n${OUTPUT}\n\n")
|
"${description} compiled and ran with the following output:\n${OUTPUT}\n\n")
|
||||||
ENDIF()
|
endif()
|
||||||
ELSE()
|
else()
|
||||||
FILE(APPEND
|
file(APPEND
|
||||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||||
"${description} failed to compile with the following output:\n${OUTPUT}\n\n")
|
"${description} failed to compile with the following output:\n${OUTPUT}\n\n")
|
||||||
SET(${var} -1 CACHE INTERNAL "${description} failed to compile.")
|
set(${var} -1 CACHE INTERNAL "${description} failed to compile.")
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
IF(${invert} MATCHES INVERT)
|
if(${invert} MATCHES INVERT)
|
||||||
IF(${var}_COMPILED)
|
if(${var}_COMPILED)
|
||||||
IF(${var})
|
if(${var})
|
||||||
MESSAGE(STATUS "${description} - yes")
|
message(STATUS "${description} - yes")
|
||||||
ELSE()
|
else()
|
||||||
MESSAGE(STATUS "${description} - no")
|
message(STATUS "${description} - no")
|
||||||
ENDIF()
|
endif()
|
||||||
ELSE()
|
else()
|
||||||
MESSAGE(STATUS "${description} - failed to compile")
|
message(STATUS "${description} - failed to compile")
|
||||||
ENDIF()
|
endif()
|
||||||
ELSE()
|
else()
|
||||||
IF(${var}_COMPILED)
|
if(${var}_COMPILED)
|
||||||
IF(${var})
|
if(${var})
|
||||||
MESSAGE(STATUS "${description} - no")
|
message(STATUS "${description} - no")
|
||||||
ELSE()
|
else()
|
||||||
MESSAGE(STATUS "${description} - yes")
|
message(STATUS "${description} - yes")
|
||||||
ENDIF()
|
endif()
|
||||||
ELSE()
|
else()
|
||||||
MESSAGE(STATUS "${description} - failed to compile")
|
message(STATUS "${description} - failed to compile")
|
||||||
ENDIF()
|
endif()
|
||||||
ENDIF()
|
endif()
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
IF(${invert} MATCHES INVERT)
|
if(${invert} MATCHES INVERT)
|
||||||
IF(${var}_COMPILED)
|
if(${var}_COMPILED)
|
||||||
IF(${var})
|
if(${var})
|
||||||
SET(${var} 1)
|
set(${var} 1)
|
||||||
ELSE()
|
else()
|
||||||
SET(${var} 0)
|
set(${var} 0)
|
||||||
ENDIF()
|
endif()
|
||||||
ELSE()
|
else()
|
||||||
SET(${var} 1)
|
set(${var} 1)
|
||||||
ENDIF()
|
endif()
|
||||||
ELSE()
|
else()
|
||||||
IF(${var}_COMPILED)
|
if(${var}_COMPILED)
|
||||||
IF(${var})
|
if(${var})
|
||||||
SET(${var} 0)
|
set(${var} 0)
|
||||||
ELSE()
|
else()
|
||||||
SET(${var} 1)
|
set(${var} 1)
|
||||||
ENDIF()
|
endif()
|
||||||
ELSE()
|
else()
|
||||||
SET(${var} 0)
|
set(${var} 0)
|
||||||
ENDIF()
|
endif()
|
||||||
ENDIF()
|
endif()
|
||||||
ENDMACRO()
|
endmacro()
|
||||||
|
|
||||||
MACRO(KWSYS_PLATFORM_C_TEST var description invert)
|
macro(KWSYS_PLATFORM_C_TEST var description invert)
|
||||||
SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES})
|
set(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES})
|
||||||
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_C_TEST_EXTRA_FLAGS})
|
set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_C_TEST_EXTRA_FLAGS})
|
||||||
KWSYS_PLATFORM_TEST(C "${var}" "${description}" "${invert}")
|
KWSYS_PLATFORM_TEST(C "${var}" "${description}" "${invert}")
|
||||||
SET(KWSYS_PLATFORM_TEST_DEFINES)
|
set(KWSYS_PLATFORM_TEST_DEFINES)
|
||||||
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
|
set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
|
||||||
ENDMACRO()
|
endmacro()
|
||||||
|
|
||||||
MACRO(KWSYS_PLATFORM_C_TEST_RUN var description invert)
|
macro(KWSYS_PLATFORM_C_TEST_RUN var description invert)
|
||||||
SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES})
|
set(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES})
|
||||||
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_C_TEST_EXTRA_FLAGS})
|
set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_C_TEST_EXTRA_FLAGS})
|
||||||
KWSYS_PLATFORM_TEST_RUN(C "${var}" "${description}" "${invert}")
|
KWSYS_PLATFORM_TEST_RUN(C "${var}" "${description}" "${invert}")
|
||||||
SET(KWSYS_PLATFORM_TEST_DEFINES)
|
set(KWSYS_PLATFORM_TEST_DEFINES)
|
||||||
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
|
set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
|
||||||
ENDMACRO()
|
endmacro()
|
||||||
|
|
||||||
MACRO(KWSYS_PLATFORM_CXX_TEST var description invert)
|
macro(KWSYS_PLATFORM_CXX_TEST var description invert)
|
||||||
SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
|
set(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
|
||||||
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS})
|
set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS})
|
||||||
SET(KWSYS_PLATFORM_TEST_LINK_LIBRARIES ${KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES})
|
set(KWSYS_PLATFORM_TEST_LINK_LIBRARIES ${KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES})
|
||||||
KWSYS_PLATFORM_TEST(CXX "${var}" "${description}" "${invert}")
|
KWSYS_PLATFORM_TEST(CXX "${var}" "${description}" "${invert}")
|
||||||
SET(KWSYS_PLATFORM_TEST_DEFINES)
|
set(KWSYS_PLATFORM_TEST_DEFINES)
|
||||||
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
|
set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
|
||||||
SET(KWSYS_PLATFORM_TEST_LINK_LIBRARIES)
|
set(KWSYS_PLATFORM_TEST_LINK_LIBRARIES)
|
||||||
ENDMACRO()
|
endmacro()
|
||||||
|
|
||||||
MACRO(KWSYS_PLATFORM_CXX_TEST_RUN var description invert)
|
macro(KWSYS_PLATFORM_CXX_TEST_RUN var description invert)
|
||||||
SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
|
set(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
|
||||||
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS})
|
set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS})
|
||||||
KWSYS_PLATFORM_TEST_RUN(CXX "${var}" "${description}" "${invert}")
|
KWSYS_PLATFORM_TEST_RUN(CXX "${var}" "${description}" "${invert}")
|
||||||
SET(KWSYS_PLATFORM_TEST_DEFINES)
|
set(KWSYS_PLATFORM_TEST_DEFINES)
|
||||||
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
|
set(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
|
||||||
ENDMACRO()
|
endmacro()
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# KWSYS_PLATFORM_INFO_TEST(lang var description)
|
# KWSYS_PLATFORM_INFO_TEST(lang var description)
|
||||||
#
|
#
|
||||||
# Compile test named by ${var} and store INFO strings extracted from binary.
|
# Compile test named by ${var} and store INFO strings extracted from binary.
|
||||||
MACRO(KWSYS_PLATFORM_INFO_TEST lang var description)
|
macro(KWSYS_PLATFORM_INFO_TEST lang var description)
|
||||||
# We can implement this macro on CMake 2.6 and above.
|
# We can implement this macro on CMake 2.6 and above.
|
||||||
IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6)
|
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6)
|
||||||
SET(${var} "")
|
set(${var} "")
|
||||||
ELSE()
|
else()
|
||||||
# Choose a location for the result binary.
|
# Choose a location for the result binary.
|
||||||
SET(KWSYS_PLATFORM_INFO_FILE
|
set(KWSYS_PLATFORM_INFO_FILE
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${var}.bin)
|
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${var}.bin)
|
||||||
|
|
||||||
# Compile the test binary.
|
# Compile the test binary.
|
||||||
IF(NOT EXISTS ${KWSYS_PLATFORM_INFO_FILE})
|
if(NOT EXISTS ${KWSYS_PLATFORM_INFO_FILE})
|
||||||
MESSAGE(STATUS "${description}")
|
message(STATUS "${description}")
|
||||||
TRY_COMPILE(${var}_COMPILED
|
try_compile(${var}_COMPILED
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}}
|
${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}}
|
||||||
COMPILE_DEFINITIONS -DTEST_${var}
|
COMPILE_DEFINITIONS -DTEST_${var}
|
||||||
@@ -188,29 +188,29 @@ MACRO(KWSYS_PLATFORM_INFO_TEST lang var description)
|
|||||||
OUTPUT_VARIABLE OUTPUT
|
OUTPUT_VARIABLE OUTPUT
|
||||||
COPY_FILE ${KWSYS_PLATFORM_INFO_FILE}
|
COPY_FILE ${KWSYS_PLATFORM_INFO_FILE}
|
||||||
)
|
)
|
||||||
IF(${var}_COMPILED)
|
if(${var}_COMPILED)
|
||||||
FILE(APPEND
|
file(APPEND
|
||||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||||
"${description} compiled with the following output:\n${OUTPUT}\n\n")
|
"${description} compiled with the following output:\n${OUTPUT}\n\n")
|
||||||
ELSE()
|
else()
|
||||||
FILE(APPEND
|
file(APPEND
|
||||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||||
"${description} failed to compile with the following output:\n${OUTPUT}\n\n")
|
"${description} failed to compile with the following output:\n${OUTPUT}\n\n")
|
||||||
ENDIF()
|
endif()
|
||||||
IF(${var}_COMPILED)
|
if(${var}_COMPILED)
|
||||||
MESSAGE(STATUS "${description} - compiled")
|
message(STATUS "${description} - compiled")
|
||||||
ELSE()
|
else()
|
||||||
MESSAGE(STATUS "${description} - failed")
|
message(STATUS "${description} - failed")
|
||||||
ENDIF()
|
endif()
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# Parse info strings out of the compiled binary.
|
# Parse info strings out of the compiled binary.
|
||||||
IF(${var}_COMPILED)
|
if(${var}_COMPILED)
|
||||||
FILE(STRINGS ${KWSYS_PLATFORM_INFO_FILE} ${var} REGEX "INFO:[A-Za-z0-9]+\\[[^]]*\\]")
|
file(STRINGS ${KWSYS_PLATFORM_INFO_FILE} ${var} REGEX "INFO:[A-Za-z0-9]+\\[[^]]*\\]")
|
||||||
ELSE()
|
else()
|
||||||
SET(${var} "")
|
set(${var} "")
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
SET(KWSYS_PLATFORM_INFO_FILE)
|
set(KWSYS_PLATFORM_INFO_FILE)
|
||||||
ENDIF()
|
endif()
|
||||||
ENDMACRO()
|
endmacro()
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ int testCommandLineArguments(int argc, char* argv[])
|
|||||||
std::vector<std::string> stl_strings_argument;
|
std::vector<std::string> stl_strings_argument;
|
||||||
std::string valid_stl_strings[] = { "ken", "brad", "bill", "andy" };
|
std::string valid_stl_strings[] = { "ken", "brad", "bill", "andy" };
|
||||||
|
|
||||||
typedef kwsys::CommandLineArguments argT;
|
using argT = kwsys::CommandLineArguments;
|
||||||
|
|
||||||
arg.AddArgument("--some-int-variable", argT::SPACE_ARGUMENT,
|
arg.AddArgument("--some-int-variable", argT::SPACE_ARGUMENT,
|
||||||
&some_int_variable, "Set some random int variable");
|
&some_int_variable, "Set some random int variable");
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ int testCommandLineArguments1(int argc, char* argv[])
|
|||||||
std::string p;
|
std::string p;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
typedef kwsys::CommandLineArguments argT;
|
using argT = kwsys::CommandLineArguments;
|
||||||
arg.AddArgument("-n", argT::SPACE_ARGUMENT, &n, "Argument N");
|
arg.AddArgument("-n", argT::SPACE_ARGUMENT, &n, "Argument N");
|
||||||
arg.AddArgument("-m", argT::EQUAL_ARGUMENT, &m, "Argument M");
|
arg.AddArgument("-m", argT::EQUAL_ARGUMENT, &m, "Argument M");
|
||||||
arg.AddBooleanArgument("-p", &p, "Argument P");
|
arg.AddBooleanArgument("-p", &p, "Argument P");
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ static std::string GetLibName(const char* lname, const char* subdir = nullptr)
|
|||||||
{
|
{
|
||||||
// Construct proper name of lib
|
// Construct proper name of lib
|
||||||
std::string slname;
|
std::string slname;
|
||||||
slname = EXECUTABLE_OUTPUT_PATH;
|
slname = RUNTIME_OUTPUT_DIRECTORY;
|
||||||
if (subdir) {
|
if (subdir) {
|
||||||
slname += "/";
|
slname += "/";
|
||||||
slname += subdir;
|
slname += subdir;
|
||||||
|
|||||||
+9
-10
@@ -85,7 +85,7 @@ static int testRobustEncoding()
|
|||||||
std::wstring wstr = kwsys::Encoding::ToWide(cstr);
|
std::wstring wstr = kwsys::Encoding::ToWide(cstr);
|
||||||
|
|
||||||
wstr = kwsys::Encoding::ToWide(nullptr);
|
wstr = kwsys::Encoding::ToWide(nullptr);
|
||||||
if (wstr != L"") {
|
if (!wstr.empty()) {
|
||||||
const wchar_t* wcstr = wstr.c_str();
|
const wchar_t* wcstr = wstr.c_str();
|
||||||
std::cout << "ToWide(NULL) returned";
|
std::cout << "ToWide(NULL) returned";
|
||||||
for (size_t i = 0; i < wstr.size(); i++) {
|
for (size_t i = 0; i < wstr.size(); i++) {
|
||||||
@@ -95,7 +95,7 @@ static int testRobustEncoding()
|
|||||||
ret++;
|
ret++;
|
||||||
}
|
}
|
||||||
wstr = kwsys::Encoding::ToWide("");
|
wstr = kwsys::Encoding::ToWide("");
|
||||||
if (wstr != L"") {
|
if (!wstr.empty()) {
|
||||||
const wchar_t* wcstr = wstr.c_str();
|
const wchar_t* wcstr = wstr.c_str();
|
||||||
std::cout << "ToWide(\"\") returned";
|
std::cout << "ToWide(\"\") returned";
|
||||||
for (size_t i = 0; i < wstr.size(); i++) {
|
for (size_t i = 0; i < wstr.size(); i++) {
|
||||||
@@ -113,13 +113,13 @@ static int testRobustEncoding()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string str = kwsys::Encoding::ToNarrow(nullptr);
|
std::string str = kwsys::Encoding::ToNarrow(nullptr);
|
||||||
if (str != "") {
|
if (!str.empty()) {
|
||||||
std::cout << "ToNarrow(NULL) returned " << str << std::endl;
|
std::cout << "ToNarrow(NULL) returned " << str << std::endl;
|
||||||
ret++;
|
ret++;
|
||||||
}
|
}
|
||||||
|
|
||||||
str = kwsys::Encoding::ToNarrow(L"");
|
str = kwsys::Encoding::ToNarrow(L"");
|
||||||
if (wstr != L"") {
|
if (!wstr.empty()) {
|
||||||
std::cout << "ToNarrow(\"\") returned " << str << std::endl;
|
std::cout << "ToNarrow(\"\") returned " << str << std::endl;
|
||||||
ret++;
|
ret++;
|
||||||
}
|
}
|
||||||
@@ -140,14 +140,13 @@ static int testWithNulls()
|
|||||||
strings.push_back(std::string("k") + '\0' + '\0');
|
strings.push_back(std::string("k") + '\0' + '\0');
|
||||||
strings.push_back(std::string("\0\0\0\0", 4) + "lmn" +
|
strings.push_back(std::string("\0\0\0\0", 4) + "lmn" +
|
||||||
std::string("\0\0\0\0", 4));
|
std::string("\0\0\0\0", 4));
|
||||||
for (std::vector<std::string>::iterator it = strings.begin();
|
for (auto& string : strings) {
|
||||||
it != strings.end(); ++it) {
|
std::wstring wstr = kwsys::Encoding::ToWide(string);
|
||||||
std::wstring wstr = kwsys::Encoding::ToWide(*it);
|
|
||||||
std::string str = kwsys::Encoding::ToNarrow(wstr);
|
std::string str = kwsys::Encoding::ToNarrow(wstr);
|
||||||
std::string s(*it);
|
std::string s(string);
|
||||||
std::replace(s.begin(), s.end(), '\0', ' ');
|
std::replace(s.begin(), s.end(), '\0', ' ');
|
||||||
std::cout << "'" << s << "' (" << it->size() << ")" << std::endl;
|
std::cout << "'" << s << "' (" << string.size() << ")" << std::endl;
|
||||||
if (str != *it) {
|
if (str != string) {
|
||||||
std::replace(str.begin(), str.end(), '\0', ' ');
|
std::replace(str.begin(), str.end(), '\0', ' ');
|
||||||
std::cout << "string with null was different: '" << str << "' ("
|
std::cout << "string with null was different: '" << str << "' ("
|
||||||
<< str.size() << ")" << std::endl;
|
<< str.size() << ")" << std::endl;
|
||||||
|
|||||||
+8
-8
@@ -27,30 +27,30 @@ template class kwsys::hash_set<int>;
|
|||||||
|
|
||||||
static bool test_hash_map()
|
static bool test_hash_map()
|
||||||
{
|
{
|
||||||
typedef kwsys::hash_map<const char*, int> mtype;
|
using mtype = kwsys::hash_map<const char*, int>;
|
||||||
mtype m;
|
mtype m;
|
||||||
const char* keys[] = { "hello", "world" };
|
const char* keys[] = { "hello", "world" };
|
||||||
m[keys[0]] = 1;
|
m[keys[0]] = 1;
|
||||||
m.insert(mtype::value_type(keys[1], 2));
|
m.insert(mtype::value_type(keys[1], 2));
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for (mtype::iterator mi = m.begin(); mi != m.end(); ++mi) {
|
for (auto& mi : m) {
|
||||||
std::cout << "Found entry [" << mi->first << "," << mi->second << "]"
|
std::cout << "Found entry [" << mi.first << "," << mi.second << "]"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
sum += mi->second;
|
sum += mi.second;
|
||||||
}
|
}
|
||||||
return sum == 3;
|
return sum == 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool test_hash_set()
|
static bool test_hash_set()
|
||||||
{
|
{
|
||||||
typedef kwsys::hash_set<int> stype;
|
using stype = kwsys::hash_set<int>;
|
||||||
stype s;
|
stype s;
|
||||||
s.insert(1);
|
s.insert(1);
|
||||||
s.insert(2);
|
s.insert(2);
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for (stype::iterator si = s.begin(); si != s.end(); ++si) {
|
for (int si : s) {
|
||||||
std::cout << "Found entry [" << *si << "]" << std::endl;
|
std::cout << "Found entry [" << si << "]" << std::endl;
|
||||||
sum += *si;
|
sum += si;
|
||||||
}
|
}
|
||||||
return sum == 3;
|
return sum == 3;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-7
@@ -721,8 +721,7 @@ static std::string StringVectorToString(const std::vector<std::string>& vec)
|
|||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "vector(";
|
ss << "vector(";
|
||||||
for (std::vector<std::string>::const_iterator i = vec.begin();
|
for (auto i = vec.begin(); i != vec.end(); ++i) {
|
||||||
i != vec.end(); ++i) {
|
|
||||||
if (i != vec.begin()) {
|
if (i != vec.begin()) {
|
||||||
ss << ", ";
|
ss << ", ";
|
||||||
}
|
}
|
||||||
@@ -743,16 +742,16 @@ static bool CheckGetPath()
|
|||||||
const char* registryPath = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MyApp; MyKey]";
|
const char* registryPath = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MyApp; MyKey]";
|
||||||
|
|
||||||
std::vector<std::string> originalPaths;
|
std::vector<std::string> originalPaths;
|
||||||
originalPaths.push_back(registryPath);
|
originalPaths.emplace_back(registryPath);
|
||||||
|
|
||||||
std::vector<std::string> expectedPaths;
|
std::vector<std::string> expectedPaths;
|
||||||
expectedPaths.push_back(registryPath);
|
expectedPaths.emplace_back(registryPath);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
expectedPaths.push_back("C:/Somewhere/something");
|
expectedPaths.push_back("C:/Somewhere/something");
|
||||||
expectedPaths.push_back("D:/Temp");
|
expectedPaths.push_back("D:/Temp");
|
||||||
#else
|
#else
|
||||||
expectedPaths.push_back("/Somewhere/something");
|
expectedPaths.emplace_back("/Somewhere/something");
|
||||||
expectedPaths.push_back("/tmp");
|
expectedPaths.emplace_back("/tmp");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool res = true;
|
bool res = true;
|
||||||
@@ -817,7 +816,7 @@ static bool CheckFind()
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> searchPaths;
|
std::vector<std::string> searchPaths;
|
||||||
searchPaths.push_back(TEST_SYSTEMTOOLS_BINARY_DIR);
|
searchPaths.emplace_back(TEST_SYSTEMTOOLS_BINARY_DIR);
|
||||||
if (kwsys::SystemTools::FindFile(testFindFileName, searchPaths, true)
|
if (kwsys::SystemTools::FindFile(testFindFileName, searchPaths, true)
|
||||||
.empty()) {
|
.empty()) {
|
||||||
std::cerr << "Problem with FindFile without system paths for: "
|
std::cerr << "Problem with FindFile without system paths for: "
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#ifndef @KWSYS_NAMESPACE@_testSystemtools_h
|
#ifndef @KWSYS_NAMESPACE@_testSystemtools_h
|
||||||
#define @KWSYS_NAMESPACE@_testSystemtools_h
|
#define @KWSYS_NAMESPACE@_testSystemtools_h
|
||||||
|
|
||||||
#define EXECUTABLE_OUTPUT_PATH "@CMAKE_CURRENT_BINARY_DIR@"
|
#define RUNTIME_OUTPUT_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@"
|
||||||
|
|
||||||
#define TEST_SYSTEMTOOLS_SOURCE_DIR "@TEST_SYSTEMTOOLS_SOURCE_DIR@"
|
#define TEST_SYSTEMTOOLS_SOURCE_DIR "@TEST_SYSTEMTOOLS_SOURCE_DIR@"
|
||||||
#define TEST_SYSTEMTOOLS_BINARY_DIR "@TEST_SYSTEMTOOLS_BINARY_DIR@"
|
#define TEST_SYSTEMTOOLS_BINARY_DIR "@TEST_SYSTEMTOOLS_BINARY_DIR@"
|
||||||
|
|||||||
Reference in New Issue
Block a user