Source: Minor code improvements
This commit is contained in:
parent
ee87e53d37
commit
5e8fa0b7bc
@ -3,7 +3,6 @@
|
||||
#include "cmCTestBuildHandler.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
|
||||
@ -657,14 +656,14 @@ bool cmCTestBuildHandler::IsLaunchedErrorFile(const char* fname)
|
||||
{
|
||||
// error-{hash}.xml
|
||||
return (cmHasLiteralPrefix(fname, "error-") &&
|
||||
strcmp(fname + strlen(fname) - 4, ".xml") == 0);
|
||||
cmHasLiteralSuffix(fname, ".xml"));
|
||||
}
|
||||
|
||||
bool cmCTestBuildHandler::IsLaunchedWarningFile(const char* fname)
|
||||
{
|
||||
// warning-{hash}.xml
|
||||
return (cmHasLiteralPrefix(fname, "warning-") &&
|
||||
strcmp(fname + strlen(fname) - 4, ".xml") == 0);
|
||||
cmHasLiteralSuffix(fname, ".xml"));
|
||||
}
|
||||
|
||||
//######################################################################
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "cmCMakePath.h"
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmProperty.h"
|
||||
#include "cmRange.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSubcommandTable.h"
|
||||
@ -149,8 +150,8 @@ public:
|
||||
bool getInputPath(const std::string& arg, cmExecutionStatus& status,
|
||||
std::string& path)
|
||||
{
|
||||
const auto* def = status.GetMakefile().GetDefinition(arg);
|
||||
if (def == nullptr) {
|
||||
cmProp def = status.GetMakefile().GetDefinition(arg);
|
||||
if (!def) {
|
||||
status.SetError("undefined variable for input path.");
|
||||
return false;
|
||||
}
|
||||
|
@ -734,7 +734,7 @@ void CCONV cmSourceFileSetName2(void* arg, const char* name, const char* dir,
|
||||
}
|
||||
sf->SourceName = name;
|
||||
std::string fname = sf->SourceName;
|
||||
if (ext && strlen(ext)) {
|
||||
if (cmNonempty(ext)) {
|
||||
fname += ".";
|
||||
fname += ext;
|
||||
}
|
||||
|
@ -229,11 +229,10 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends,
|
||||
void cmDepends::SetIncludePathFromLanguage(const std::string& lang)
|
||||
{
|
||||
// Look for the new per "TARGET_" variant first:
|
||||
cmProp includePath = nullptr;
|
||||
std::string includePathVar =
|
||||
cmStrCat("CMAKE_", lang, "_TARGET_INCLUDE_PATH");
|
||||
cmMakefile* mf = this->LocalGenerator->GetMakefile();
|
||||
includePath = mf->GetDefinition(includePathVar);
|
||||
cmProp includePath = mf->GetDefinition(includePathVar);
|
||||
if (includePath) {
|
||||
cmExpandList(*includePath, this->IncludePath);
|
||||
} else {
|
||||
|
@ -2260,7 +2260,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
|
||||
|
||||
// Check whether the genex expansion of the property agrees in all
|
||||
// configurations.
|
||||
if (trueCount && falseCount) {
|
||||
if (trueCount > 0 && falseCount > 0) {
|
||||
std::ostringstream e;
|
||||
e << "The EXCLUDE_FROM_ALL property of target \"" << target->GetName()
|
||||
<< "\" varies by configuration. This is not supported by the \""
|
||||
|
@ -43,9 +43,7 @@ bool cmGlobalNMakeMakefileGenerator::FindMakeProgram(cmMakefile* mf)
|
||||
return false;
|
||||
}
|
||||
if (cmProp nmakeCommand = mf->GetDefinition("CMAKE_MAKE_PROGRAM")) {
|
||||
std::vector<std::string> command;
|
||||
command.emplace_back(*nmakeCommand);
|
||||
command.emplace_back("-?");
|
||||
std::vector<std::string> command{ *nmakeCommand, "-?" };
|
||||
std::string out;
|
||||
std::string err;
|
||||
if (!cmSystemTools::RunSingleCommand(command, &out, &err, nullptr, nullptr,
|
||||
|
@ -2786,7 +2786,7 @@ void cmLocalGenerator::IncludeFileInUnitySources(
|
||||
cmGeneratedFileStream& unity_file, std::string const& sf_full_path,
|
||||
cmProp beforeInclude, cmProp afterInclude, cmProp uniqueIdName) const
|
||||
{
|
||||
if (uniqueIdName && !uniqueIdName->empty()) {
|
||||
if (cmNonempty(uniqueIdName)) {
|
||||
std::string pathToHash;
|
||||
auto PathEqOrSubDir = [](std::string const& a, std::string const& b) {
|
||||
return (cmSystemTools::ComparePath(a, b) ||
|
||||
|
@ -2479,7 +2479,7 @@ const std::string& cmMakefile::GetRequiredDefinition(
|
||||
const std::string& name) const
|
||||
{
|
||||
static std::string const empty;
|
||||
const std::string* def = this->GetDefinition(name);
|
||||
cmProp def = this->GetDefinition(name);
|
||||
if (!def) {
|
||||
cmSystemTools::Error("Error required internal CMake variable not "
|
||||
"set, cmake may not be built correctly.\n"
|
||||
@ -2553,7 +2553,7 @@ cmProp cmMakefile::GetDefinition(const std::string& name) const
|
||||
const std::string& cmMakefile::GetSafeDefinition(const std::string& name) const
|
||||
{
|
||||
static std::string const empty;
|
||||
const std::string* def = this->GetDefinition(name);
|
||||
cmProp def = this->GetDefinition(name);
|
||||
if (!def) {
|
||||
return empty;
|
||||
}
|
||||
@ -3067,7 +3067,7 @@ MessageType cmMakefile::ExpandVariablesInStringNew(
|
||||
if (filename && variable == lineVar) {
|
||||
varresult = std::to_string(line);
|
||||
} else {
|
||||
const std::string* def = this->GetDefinition(variable);
|
||||
cmProp def = this->GetDefinition(variable);
|
||||
if (def) {
|
||||
varresult = *def;
|
||||
} else if (!this->SuppressSideEffects) {
|
||||
|
@ -498,7 +498,7 @@ void cmVisualStudio10TargetGenerator::Generate()
|
||||
cmProp targetFramework =
|
||||
this->GeneratorTarget->GetProperty("DOTNET_TARGET_FRAMEWORK");
|
||||
if (targetFramework) {
|
||||
if (std::strchr(targetFramework->c_str(), ';') != nullptr) {
|
||||
if (targetFramework->find(';') != std::string::npos) {
|
||||
e1.Element("TargetFrameworks", *targetFramework);
|
||||
} else {
|
||||
e1.Element("TargetFramework", *targetFramework);
|
||||
|
Loading…
Reference in New Issue
Block a user