mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 16:32:14 -06:00
cmState: Track known projects
Add a member to directory state that records the set of known projects. Add a method to query whether a project exists. Internally, while this doesn't allow us to confirm that a variable like `foo_VERSION` is actually associated with a project `foo`, it provides a much stronger indicator than the mere existence of said variable.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "cmConfigure.h" // IWYU pragma: keep
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
@@ -82,6 +83,8 @@ struct cmStateDetail::BuildsystemDirectoryStateType
|
||||
std::vector<std::string> NormalTargetNames;
|
||||
std::vector<std::string> ImportedTargetNames;
|
||||
|
||||
std::set<std::string> Projects;
|
||||
|
||||
std::string ProjectName;
|
||||
|
||||
cmPropertyMap Properties;
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <cm/iterator>
|
||||
#include <cmext/algorithm>
|
||||
|
||||
#include "cmDefinitions.h"
|
||||
#include "cmLinkedTree.h"
|
||||
@@ -413,6 +415,7 @@ cmStateDirectory cmStateSnapshot::GetDirectory() const
|
||||
void cmStateSnapshot::SetProjectName(std::string const& name)
|
||||
{
|
||||
this->Position->BuildSystemDirectory->ProjectName = name;
|
||||
this->Position->BuildSystemDirectory->Projects.insert(name);
|
||||
}
|
||||
|
||||
std::string cmStateSnapshot::GetProjectName() const
|
||||
@@ -420,6 +423,11 @@ std::string cmStateSnapshot::GetProjectName() const
|
||||
return this->Position->BuildSystemDirectory->ProjectName;
|
||||
}
|
||||
|
||||
bool cmStateSnapshot::CheckProjectName(std::string const& name) const
|
||||
{
|
||||
return cm::contains(this->Position->BuildSystemDirectory->Projects, name);
|
||||
}
|
||||
|
||||
cmPackageState& cmStateSnapshot::GetPackageState(
|
||||
std::string const& packagePath)
|
||||
{
|
||||
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
|
||||
void SetProjectName(std::string const& name);
|
||||
std::string GetProjectName() const;
|
||||
bool CheckProjectName(std::string const& name) const;
|
||||
|
||||
cmPackageState& GetPackageState(std::string const& packagePath);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user