mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-30 02:59:22 -05:00
cmSourceFile: Add IsGenerated method
All cmSourceFiles are checked at least once whether they're `GENERATED` or not. This adds a convenience method `GetIsGenerated` that returns a private boolean cache variable `IsGenerated`. `IsGenerated` is updated every time the `GENERATED` property is written.
This commit is contained in:
+10
-2
@@ -17,8 +17,6 @@ cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name,
|
|||||||
cmSourceFileLocationKind kind)
|
cmSourceFileLocationKind kind)
|
||||||
: Location(mf, name, kind)
|
: Location(mf, name, kind)
|
||||||
{
|
{
|
||||||
this->CustomCommand = nullptr;
|
|
||||||
this->FindFullPathFailed = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmSourceFile::~cmSourceFile()
|
cmSourceFile::~cmSourceFile()
|
||||||
@@ -244,12 +242,22 @@ bool cmSourceFile::Matches(cmSourceFileLocation const& loc)
|
|||||||
void cmSourceFile::SetProperty(const std::string& prop, const char* value)
|
void cmSourceFile::SetProperty(const std::string& prop, const char* value)
|
||||||
{
|
{
|
||||||
this->Properties.SetProperty(prop, value);
|
this->Properties.SetProperty(prop, value);
|
||||||
|
|
||||||
|
// Update IsGenerated flag
|
||||||
|
if (prop == propGENERATED) {
|
||||||
|
this->IsGenerated = cmSystemTools::IsOn(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmSourceFile::AppendProperty(const std::string& prop, const char* value,
|
void cmSourceFile::AppendProperty(const std::string& prop, const char* value,
|
||||||
bool asString)
|
bool asString)
|
||||||
{
|
{
|
||||||
this->Properties.AppendProperty(prop, value, asString);
|
this->Properties.AppendProperty(prop, value, asString);
|
||||||
|
|
||||||
|
// Update IsGenerated flag
|
||||||
|
if (prop == propGENERATED) {
|
||||||
|
this->IsGenerated = this->GetPropertyAsBool(propGENERATED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* cmSourceFile::GetPropertyForUser(const std::string& prop)
|
const char* cmSourceFile::GetPropertyForUser(const std::string& prop)
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ public:
|
|||||||
command like get_property or get_source_file_property. */
|
command like get_property or get_source_file_property. */
|
||||||
const char* GetPropertyForUser(const std::string& prop);
|
const char* GetPropertyForUser(const std::string& prop);
|
||||||
|
|
||||||
|
///! Checks is the GENERATED property is set and true
|
||||||
|
/// @return Equivalent to GetPropertyAsBool("GENERATED")
|
||||||
|
bool GetIsGenerated() const { return this->IsGenerated; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The full path to the file. The non-const version of this method
|
* The full path to the file. The non-const version of this method
|
||||||
* may attempt to locate the file on disk and finalize its location.
|
* may attempt to locate the file on disk and finalize its location.
|
||||||
@@ -106,13 +110,14 @@ public:
|
|||||||
private:
|
private:
|
||||||
cmSourceFileLocation Location;
|
cmSourceFileLocation Location;
|
||||||
cmPropertyMap Properties;
|
cmPropertyMap Properties;
|
||||||
cmCustomCommand* CustomCommand;
|
cmCustomCommand* CustomCommand = nullptr;
|
||||||
std::string Extension;
|
std::string Extension;
|
||||||
std::string Language;
|
std::string Language;
|
||||||
std::string FullPath;
|
std::string FullPath;
|
||||||
std::string ObjectLibrary;
|
std::string ObjectLibrary;
|
||||||
std::vector<std::string> Depends;
|
std::vector<std::string> Depends;
|
||||||
bool FindFullPathFailed;
|
bool FindFullPathFailed = false;
|
||||||
|
bool IsGenerated = false;
|
||||||
|
|
||||||
bool FindFullPath(std::string* error);
|
bool FindFullPath(std::string* error);
|
||||||
bool TryFullPath(const std::string& path, const std::string& ext);
|
bool TryFullPath(const std::string& path, const std::string& ext);
|
||||||
|
|||||||
Reference in New Issue
Block a user