mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-16 12:11:04 -06:00
Refactoring: introduce function to check if a string is a generator expression
This commit is contained in:
committed by
Craig Scott
parent
1fea56c3bd
commit
5ca130e223
@@ -168,7 +168,7 @@ static std::string stripAllGeneratorExpressions(const std::string& input)
|
||||
const char* c = input.c_str() + pos;
|
||||
const char* const cStart = c;
|
||||
for (; *c; ++c) {
|
||||
if (c[0] == '$' && c[1] == '<') {
|
||||
if (cmGeneratorExpression::StartsWithGeneratorExpression(c)) {
|
||||
++nestingLevel;
|
||||
++c;
|
||||
continue;
|
||||
@@ -243,7 +243,7 @@ static std::string stripExportInterface(
|
||||
const char* c = input.c_str() + pos;
|
||||
const char* const cStart = c;
|
||||
for (; *c; ++c) {
|
||||
if (c[0] == '$' && c[1] == '<') {
|
||||
if (cmGeneratorExpression::StartsWithGeneratorExpression(c)) {
|
||||
++nestingLevel;
|
||||
++c;
|
||||
continue;
|
||||
@@ -310,7 +310,7 @@ void cmGeneratorExpression::Split(const std::string& input,
|
||||
const char* c = input.c_str() + pos;
|
||||
const char* const cStart = c;
|
||||
for (; *c; ++c) {
|
||||
if (c[0] == '$' && c[1] == '<') {
|
||||
if (cmGeneratorExpression::StartsWithGeneratorExpression(c)) {
|
||||
++nestingLevel;
|
||||
++c;
|
||||
continue;
|
||||
|
||||
@@ -63,6 +63,15 @@ public:
|
||||
|
||||
static std::string StripEmptyListElements(const std::string& input);
|
||||
|
||||
static inline bool StartsWithGeneratorExpression(const std::string& input)
|
||||
{
|
||||
return input.length() >= 2 && input[0] == '$' && input[1] == '<';
|
||||
}
|
||||
static inline bool StartsWithGeneratorExpression(const char* input)
|
||||
{
|
||||
return input != nullptr && input[0] == '$' && input[1] == '<';
|
||||
}
|
||||
|
||||
private:
|
||||
cmListFileBacktrace Backtrace;
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
|
||||
#include "cmGeneratorExpression.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
@@ -69,11 +70,6 @@ bool cmIncludeDirectoryCommand::InitialPass(
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool StartsWithGeneratorExpression(const std::string& input)
|
||||
{
|
||||
return input[0] == '$' && input[1] == '<';
|
||||
}
|
||||
|
||||
// do a lot of cleanup on the arguments because this is one place where folks
|
||||
// sometimes take the output of a program and pass it directly into this
|
||||
// command not thinking that a single argument could be filled with spaces
|
||||
@@ -124,7 +120,7 @@ void cmIncludeDirectoryCommand::NormalizeInclude(std::string& inc)
|
||||
cmSystemTools::ConvertToUnixSlashes(inc);
|
||||
|
||||
if (!cmSystemTools::FileIsFullPath(inc)) {
|
||||
if (!StartsWithGeneratorExpression(inc)) {
|
||||
if (!cmGeneratorExpression::StartsWithGeneratorExpression(inc)) {
|
||||
std::string tmp = this->Makefile->GetCurrentSourceDirectory();
|
||||
tmp += "/";
|
||||
tmp += inc;
|
||||
|
||||
@@ -514,9 +514,7 @@ void cmTarget::AddSources(std::vector<std::string> const& srcs)
|
||||
std::string srcFiles;
|
||||
const char* sep = "";
|
||||
for (auto filename : srcs) {
|
||||
const char* src = filename.c_str();
|
||||
|
||||
if (!(src[0] == '$' && src[1] == '<')) {
|
||||
if (!cmGeneratorExpression::StartsWithGeneratorExpression(filename)) {
|
||||
if (!filename.empty()) {
|
||||
filename = this->ProcessSourceItemCMP0049(filename);
|
||||
if (filename.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user