2015-04-04 22:20:12 +03:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2015 Stephen Kelly <steveire@gmail.com>
|
|
|
|
|
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
|
|
|
#include "cmState.h"
|
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmAlgorithms.h"
|
2015-04-07 23:45:54 +03:00
|
|
|
#include "cmCacheManager.h"
|
2015-04-11 13:30:26 +03:00
|
|
|
#include "cmCommand.h"
|
2015-06-21 22:26:43 +03:00
|
|
|
#include "cmDefinitions.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmVersion.h"
|
|
|
|
#include "cmake.h"
|
2015-04-11 13:30:26 +03:00
|
|
|
|
|
|
|
#include <assert.h>
|
2015-04-04 22:20:12 +03:00
|
|
|
|
2015-05-23 10:54:07 +03:00
|
|
|
struct cmState::SnapshotDataType
|
|
|
|
{
|
2015-08-01 20:41:26 +03:00
|
|
|
cmState::PositionType ScopeParent;
|
2015-05-23 10:54:07 +03:00
|
|
|
cmState::PositionType DirectoryParent;
|
2015-07-26 14:04:09 +03:00
|
|
|
cmLinkedTree<cmState::PolicyStackEntry>::iterator Policies;
|
|
|
|
cmLinkedTree<cmState::PolicyStackEntry>::iterator PolicyRoot;
|
|
|
|
cmLinkedTree<cmState::PolicyStackEntry>::iterator PolicyScope;
|
2015-05-23 10:54:07 +03:00
|
|
|
cmState::SnapshotType SnapshotType;
|
2015-11-24 23:00:47 +03:00
|
|
|
bool Keep;
|
2015-05-31 20:37:08 +03:00
|
|
|
cmLinkedTree<std::string>::iterator ExecutionListFile;
|
2015-05-23 01:04:09 +03:00
|
|
|
cmLinkedTree<cmState::BuildsystemDirectoryStateType>::iterator
|
2016-05-16 17:34:04 +03:00
|
|
|
BuildSystemDirectory;
|
2015-06-21 22:26:43 +03:00
|
|
|
cmLinkedTree<cmDefinitions>::iterator Vars;
|
|
|
|
cmLinkedTree<cmDefinitions>::iterator Root;
|
|
|
|
cmLinkedTree<cmDefinitions>::iterator Parent;
|
2015-07-18 13:28:49 +03:00
|
|
|
std::vector<std::string>::size_type IncludeDirectoryPosition;
|
|
|
|
std::vector<std::string>::size_type CompileDefinitionsPosition;
|
|
|
|
std::vector<std::string>::size_type CompileOptionsPosition;
|
2015-05-23 11:37:07 +03:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
struct cmState::PolicyStackEntry : public cmPolicies::PolicyMap
|
2015-07-26 14:04:09 +03:00
|
|
|
{
|
|
|
|
typedef cmPolicies::PolicyMap derived;
|
2016-05-16 17:34:04 +03:00
|
|
|
PolicyStackEntry(bool w = false)
|
|
|
|
: derived()
|
|
|
|
, Weak(w)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
PolicyStackEntry(derived const& d, bool w)
|
|
|
|
: derived(d)
|
|
|
|
, Weak(w)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
PolicyStackEntry(PolicyStackEntry const& r)
|
|
|
|
: derived(r)
|
|
|
|
, Weak(r.Weak)
|
|
|
|
{
|
|
|
|
}
|
2015-07-26 14:04:09 +03:00
|
|
|
bool Weak;
|
|
|
|
};
|
|
|
|
|
2015-05-23 11:37:07 +03:00
|
|
|
struct cmState::BuildsystemDirectoryStateType
|
|
|
|
{
|
2015-08-01 08:20:26 +03:00
|
|
|
cmState::PositionType DirectoryEnd;
|
|
|
|
|
2015-05-23 11:37:07 +03:00
|
|
|
std::string Location;
|
|
|
|
std::string OutputLocation;
|
|
|
|
|
|
|
|
std::vector<std::string> CurrentSourceDirectoryComponents;
|
|
|
|
std::vector<std::string> CurrentBinaryDirectoryComponents;
|
|
|
|
// The top-most directories for relative path conversion. Both the
|
|
|
|
// source and destination location of a relative path conversion
|
|
|
|
// must be underneath one of these directories (both under source or
|
|
|
|
// both under binary) in order for the relative path to be evaluated
|
|
|
|
// safely by the build tools.
|
|
|
|
std::string RelativePathTopSource;
|
|
|
|
std::string RelativePathTopBinary;
|
2015-07-18 13:28:49 +03:00
|
|
|
|
|
|
|
std::vector<std::string> IncludeDirectories;
|
|
|
|
std::vector<cmListFileBacktrace> IncludeDirectoryBacktraces;
|
|
|
|
|
|
|
|
std::vector<std::string> CompileDefinitions;
|
|
|
|
std::vector<cmListFileBacktrace> CompileDefinitionsBacktraces;
|
|
|
|
|
|
|
|
std::vector<std::string> CompileOptions;
|
|
|
|
std::vector<cmListFileBacktrace> CompileOptionsBacktraces;
|
2015-07-18 16:18:59 +03:00
|
|
|
|
2015-08-02 10:41:06 +03:00
|
|
|
std::string ProjectName;
|
|
|
|
|
2015-07-18 16:18:59 +03:00
|
|
|
cmPropertyMap Properties;
|
2015-07-19 17:26:49 +03:00
|
|
|
|
|
|
|
std::vector<cmState::Snapshot> Children;
|
2015-05-23 10:54:07 +03:00
|
|
|
};
|
|
|
|
|
2015-10-10 16:42:02 +03:00
|
|
|
cmState::cmState()
|
2016-05-16 17:34:04 +03:00
|
|
|
: IsInTryCompile(false)
|
|
|
|
, WindowsShell(false)
|
|
|
|
, WindowsVSIDE(false)
|
|
|
|
, WatcomWMake(false)
|
|
|
|
, MinGWMake(false)
|
|
|
|
, NMake(false)
|
|
|
|
, MSYSShell(false)
|
2015-04-04 22:20:12 +03:00
|
|
|
{
|
2015-10-10 16:42:02 +03:00
|
|
|
this->CacheManager = new cmCacheManager;
|
2015-04-04 22:20:12 +03:00
|
|
|
}
|
2015-04-07 23:45:54 +03:00
|
|
|
|
2015-04-11 13:30:26 +03:00
|
|
|
cmState::~cmState()
|
|
|
|
{
|
2015-10-10 16:42:02 +03:00
|
|
|
delete this->CacheManager;
|
2015-04-11 13:30:26 +03:00
|
|
|
cmDeleteAll(this->Commands);
|
|
|
|
}
|
|
|
|
|
2015-10-08 01:26:50 +03:00
|
|
|
const char* cmState::GetTargetTypeName(cmState::TargetType targetType)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (targetType) {
|
|
|
|
case cmState::STATIC_LIBRARY:
|
|
|
|
return "STATIC_LIBRARY";
|
|
|
|
case cmState::MODULE_LIBRARY:
|
|
|
|
return "MODULE_LIBRARY";
|
|
|
|
case cmState::SHARED_LIBRARY:
|
|
|
|
return "SHARED_LIBRARY";
|
|
|
|
case cmState::OBJECT_LIBRARY:
|
|
|
|
return "OBJECT_LIBRARY";
|
|
|
|
case cmState::EXECUTABLE:
|
|
|
|
return "EXECUTABLE";
|
|
|
|
case cmState::UTILITY:
|
|
|
|
return "UTILITY";
|
|
|
|
case cmState::GLOBAL_TARGET:
|
|
|
|
return "GLOBAL_TARGET";
|
|
|
|
case cmState::INTERFACE_LIBRARY:
|
|
|
|
return "INTERFACE_LIBRARY";
|
|
|
|
case cmState::UNKNOWN_LIBRARY:
|
|
|
|
return "UNKNOWN_LIBRARY";
|
|
|
|
}
|
2015-10-08 01:26:50 +03:00
|
|
|
assert(0 && "Unexpected target type");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmCacheEntryTypes[] = { "BOOL", "PATH", "FILEPATH",
|
|
|
|
"STRING", "INTERNAL", "STATIC",
|
|
|
|
"UNINITIALIZED", 0 };
|
2015-04-07 23:45:54 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmState::CacheEntryTypeToString(cmState::CacheEntryType type)
|
2015-04-04 22:20:12 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (type > 6) {
|
2015-04-07 23:45:54 +03:00
|
|
|
return cmCacheEntryTypes[6];
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-07 23:45:54 +03:00
|
|
|
return cmCacheEntryTypes[type];
|
2015-04-04 22:20:12 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmState::CacheEntryType cmState::StringToCacheEntryType(const char* s)
|
2015-04-04 22:20:12 +03:00
|
|
|
{
|
2015-04-07 23:45:54 +03:00
|
|
|
int i = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (cmCacheEntryTypes[i]) {
|
|
|
|
if (strcmp(s, cmCacheEntryTypes[i]) == 0) {
|
2015-04-07 23:45:54 +03:00
|
|
|
return static_cast<cmState::CacheEntryType>(i);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
++i;
|
|
|
|
}
|
2015-04-07 23:45:54 +03:00
|
|
|
return STRING;
|
2015-04-04 22:20:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::IsCacheEntryType(std::string const& key)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
for (int i = 0; cmCacheEntryTypes[i]; ++i) {
|
|
|
|
if (strcmp(key.c_str(), cmCacheEntryTypes[i]) == 0) {
|
2015-04-07 23:45:54 +03:00
|
|
|
return true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-07 23:45:54 +03:00
|
|
|
return false;
|
2015-04-04 22:20:12 +03:00
|
|
|
}
|
|
|
|
|
2015-10-10 16:21:41 +03:00
|
|
|
bool cmState::LoadCache(const std::string& path, bool internal,
|
|
|
|
std::set<std::string>& excludes,
|
|
|
|
std::set<std::string>& includes)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return this->CacheManager->LoadCache(path, internal, excludes, includes);
|
2015-10-10 16:21:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::SaveCache(const std::string& path)
|
|
|
|
{
|
2015-10-10 16:42:02 +03:00
|
|
|
return this->CacheManager->SaveCache(path);
|
2015-10-10 16:21:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::DeleteCache(const std::string& path)
|
|
|
|
{
|
2015-10-10 16:42:02 +03:00
|
|
|
return this->CacheManager->DeleteCache(path);
|
2015-10-10 16:21:41 +03:00
|
|
|
}
|
|
|
|
|
2015-04-04 22:20:12 +03:00
|
|
|
std::vector<std::string> cmState::GetCacheEntryKeys() const
|
|
|
|
{
|
|
|
|
std::vector<std::string> definitions;
|
2015-10-10 16:42:02 +03:00
|
|
|
definitions.reserve(this->CacheManager->GetSize());
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCacheManager::CacheIterator cit = this->CacheManager->GetCacheIterator();
|
|
|
|
for (cit.Begin(); !cit.IsAtEnd(); cit.Next()) {
|
2015-04-04 22:20:12 +03:00
|
|
|
definitions.push_back(cit.GetName());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-04 22:20:12 +03:00
|
|
|
return definitions;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* cmState::GetCacheEntryValue(std::string const& key) const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCacheManager::CacheEntry* e = this->CacheManager->GetCacheEntry(key);
|
|
|
|
if (!e) {
|
2015-04-04 22:20:12 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-04 22:20:12 +03:00
|
|
|
return e->Value.c_str();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmState::GetInitializedCacheValue(std::string const& key) const
|
2015-04-04 22:20:12 +03:00
|
|
|
{
|
2015-10-10 16:42:02 +03:00
|
|
|
return this->CacheManager->GetInitializedCacheValue(key);
|
2015-04-04 22:20:12 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmState::CacheEntryType cmState::GetCacheEntryType(
|
|
|
|
std::string const& key) const
|
2015-04-04 22:20:12 +03:00
|
|
|
{
|
|
|
|
cmCacheManager::CacheIterator it =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CacheManager->GetCacheIterator(key.c_str());
|
2015-04-04 22:20:12 +03:00
|
|
|
return it.GetType();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::SetCacheEntryValue(std::string const& key,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string const& value)
|
2015-04-04 22:20:12 +03:00
|
|
|
{
|
2015-10-10 16:42:02 +03:00
|
|
|
this->CacheManager->SetCacheEntryValue(key, value);
|
2015-04-04 22:20:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::SetCacheEntryProperty(std::string const& key,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string const& propertyName,
|
|
|
|
std::string const& value)
|
2015-04-04 22:20:12 +03:00
|
|
|
{
|
|
|
|
cmCacheManager::CacheIterator it =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CacheManager->GetCacheIterator(key.c_str());
|
2015-04-04 22:20:12 +03:00
|
|
|
it.SetProperty(propertyName, value.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::SetCacheEntryBoolProperty(std::string const& key,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string const& propertyName,
|
|
|
|
bool value)
|
2015-04-04 22:20:12 +03:00
|
|
|
{
|
|
|
|
cmCacheManager::CacheIterator it =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CacheManager->GetCacheIterator(key.c_str());
|
2015-04-04 22:20:12 +03:00
|
|
|
it.SetProperty(propertyName, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* cmState::GetCacheEntryProperty(std::string const& key,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string const& propertyName)
|
2015-04-04 22:20:12 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCacheManager::CacheIterator it =
|
|
|
|
this->CacheManager->GetCacheIterator(key.c_str());
|
|
|
|
if (!it.PropertyExists(propertyName)) {
|
2015-04-04 22:20:12 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-04 22:20:12 +03:00
|
|
|
return it.GetProperty(propertyName);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::GetCacheEntryPropertyAsBool(std::string const& key,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string const& propertyName)
|
2015-04-04 22:20:12 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return this->CacheManager->GetCacheIterator(key.c_str())
|
|
|
|
.GetPropertyAsBool(propertyName);
|
2015-04-04 22:20:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::AddCacheEntry(const std::string& key, const char* value,
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* helpString,
|
|
|
|
cmState::CacheEntryType type)
|
2015-04-04 22:20:12 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CacheManager->AddCacheEntry(key, value, helpString, type);
|
2015-04-04 22:20:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::RemoveCacheEntry(std::string const& key)
|
|
|
|
{
|
2015-10-10 16:42:02 +03:00
|
|
|
this->CacheManager->RemoveCacheEntry(key);
|
2015-04-04 22:20:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::AppendCacheEntryProperty(const std::string& key,
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& property,
|
|
|
|
const std::string& value, bool asString)
|
2015-04-04 22:20:12 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CacheManager->GetCacheIterator(key.c_str())
|
|
|
|
.AppendProperty(property, value.c_str(), asString);
|
2015-04-04 22:20:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::RemoveCacheEntryProperty(std::string const& key,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string const& propertyName)
|
2015-04-04 22:20:12 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CacheManager->GetCacheIterator(key.c_str())
|
|
|
|
.SetProperty(propertyName, (void*)0);
|
2015-04-04 22:20:12 +03:00
|
|
|
}
|
2015-04-05 00:33:26 +03:00
|
|
|
|
2015-06-14 02:08:34 +03:00
|
|
|
cmState::Snapshot cmState::Reset()
|
2015-04-05 00:33:26 +03:00
|
|
|
{
|
2015-04-11 15:17:46 +03:00
|
|
|
this->GlobalProperties.clear();
|
2015-04-05 00:33:26 +03:00
|
|
|
this->PropertyDefinitions.clear();
|
2015-05-24 14:00:20 +03:00
|
|
|
|
2015-08-01 08:20:26 +03:00
|
|
|
PositionType pos = this->SnapshotData.Truncate();
|
|
|
|
this->ExecutionListFiles.Truncate();
|
|
|
|
|
2015-07-18 13:28:49 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmLinkedTree<BuildsystemDirectoryStateType>::iterator it =
|
2015-07-18 13:28:49 +03:00
|
|
|
this->BuildsystemDirectory.Truncate();
|
2016-05-16 17:34:04 +03:00
|
|
|
it->IncludeDirectories.clear();
|
|
|
|
it->IncludeDirectoryBacktraces.clear();
|
|
|
|
it->CompileDefinitions.clear();
|
|
|
|
it->CompileDefinitionsBacktraces.clear();
|
|
|
|
it->CompileOptions.clear();
|
|
|
|
it->CompileOptionsBacktraces.clear();
|
|
|
|
it->DirectoryEnd = pos;
|
|
|
|
it->Properties.clear();
|
|
|
|
it->Children.clear();
|
2015-07-18 13:28:49 +03:00
|
|
|
}
|
2015-05-24 14:00:20 +03:00
|
|
|
|
2015-07-26 14:04:09 +03:00
|
|
|
this->PolicyStack.Clear();
|
|
|
|
pos->Policies = this->PolicyStack.Root();
|
|
|
|
pos->PolicyRoot = this->PolicyStack.Root();
|
|
|
|
pos->PolicyScope = this->PolicyStack.Root();
|
|
|
|
assert(pos->Policies.IsValid());
|
|
|
|
assert(pos->PolicyRoot.IsValid());
|
2015-10-13 22:52:33 +03:00
|
|
|
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string srcDir =
|
2015-10-13 22:52:33 +03:00
|
|
|
cmDefinitions::Get("CMAKE_SOURCE_DIR", pos->Vars, pos->Root);
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string binDir =
|
2015-10-13 22:52:33 +03:00
|
|
|
cmDefinitions::Get("CMAKE_BINARY_DIR", pos->Vars, pos->Root);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->VarTree.Clear();
|
|
|
|
pos->Vars = this->VarTree.Push(this->VarTree.Root());
|
|
|
|
pos->Parent = this->VarTree.Root();
|
|
|
|
pos->Root = this->VarTree.Root();
|
2015-07-26 14:04:09 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
pos->Vars->Set("CMAKE_SOURCE_DIR", srcDir.c_str());
|
|
|
|
pos->Vars->Set("CMAKE_BINARY_DIR", binDir.c_str());
|
2015-10-13 22:52:33 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
this->DefineProperty("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, "", "",
|
|
|
|
true);
|
|
|
|
this->DefineProperty("RULE_LAUNCH_LINK", cmProperty::DIRECTORY, "", "",
|
|
|
|
true);
|
|
|
|
this->DefineProperty("RULE_LAUNCH_CUSTOM", cmProperty::DIRECTORY, "", "",
|
|
|
|
true);
|
|
|
|
|
|
|
|
this->DefineProperty("RULE_LAUNCH_COMPILE", cmProperty::TARGET, "", "",
|
|
|
|
true);
|
|
|
|
this->DefineProperty("RULE_LAUNCH_LINK", cmProperty::TARGET, "", "", true);
|
|
|
|
this->DefineProperty("RULE_LAUNCH_CUSTOM", cmProperty::TARGET, "", "", true);
|
2015-06-14 02:08:34 +03:00
|
|
|
|
|
|
|
return Snapshot(this, pos);
|
2015-04-05 00:33:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::DefineProperty(const std::string& name,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmProperty::ScopeType scope,
|
|
|
|
const char* ShortDescription,
|
|
|
|
const char* FullDescription, bool chained)
|
2015-04-05 00:33:26 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
this->PropertyDefinitions[scope].DefineProperty(
|
|
|
|
name, scope, ShortDescription, FullDescription, chained);
|
2015-04-05 00:33:26 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmPropertyDefinition const* cmState::GetPropertyDefinition(
|
|
|
|
const std::string& name, cmProperty::ScopeType scope) const
|
2015-04-05 00:33:26 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsPropertyDefined(name, scope)) {
|
2015-06-06 10:46:38 +03:00
|
|
|
cmPropertyDefinitionMap const& defs =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->PropertyDefinitions.find(scope)->second;
|
2015-06-06 10:46:38 +03:00
|
|
|
return &defs.find(name)->second;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-05 00:33:26 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::IsPropertyDefined(const std::string& name,
|
2015-06-06 10:46:38 +03:00
|
|
|
cmProperty::ScopeType scope) const
|
2015-04-05 00:33:26 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>::const_iterator it =
|
|
|
|
this->PropertyDefinitions.find(scope);
|
|
|
|
if (it == this->PropertyDefinitions.end()) {
|
2015-06-06 10:46:38 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-06-06 10:46:38 +03:00
|
|
|
return it->second.IsPropertyDefined(name);
|
2015-04-05 00:33:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::IsPropertyChained(const std::string& name,
|
2015-06-06 10:46:38 +03:00
|
|
|
cmProperty::ScopeType scope) const
|
2015-04-05 00:33:26 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>::const_iterator it =
|
|
|
|
this->PropertyDefinitions.find(scope);
|
|
|
|
if (it == this->PropertyDefinitions.end()) {
|
2015-06-06 10:46:38 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-06-06 10:46:38 +03:00
|
|
|
return it->second.IsPropertyChained(name);
|
2015-04-05 00:33:26 +03:00
|
|
|
}
|
2015-04-11 15:16:39 +03:00
|
|
|
|
|
|
|
void cmState::SetLanguageEnabled(std::string const& l)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<std::string>::iterator it = std::lower_bound(
|
|
|
|
this->EnabledLanguages.begin(), this->EnabledLanguages.end(), l);
|
|
|
|
if (it == this->EnabledLanguages.end() || *it != l) {
|
2015-04-11 15:16:39 +03:00
|
|
|
this->EnabledLanguages.insert(it, l);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-11 15:16:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::GetLanguageEnabled(std::string const& l) const
|
|
|
|
{
|
|
|
|
return std::binary_search(this->EnabledLanguages.begin(),
|
|
|
|
this->EnabledLanguages.end(), l);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> cmState::GetEnabledLanguages() const
|
|
|
|
{
|
|
|
|
return this->EnabledLanguages;
|
|
|
|
}
|
|
|
|
|
2015-04-30 15:56:48 +03:00
|
|
|
void cmState::SetEnabledLanguages(std::vector<std::string> const& langs)
|
|
|
|
{
|
|
|
|
this->EnabledLanguages = langs;
|
|
|
|
}
|
|
|
|
|
2015-04-11 15:16:39 +03:00
|
|
|
void cmState::ClearEnabledLanguages()
|
|
|
|
{
|
|
|
|
this->EnabledLanguages.clear();
|
|
|
|
}
|
2015-04-11 13:16:54 +03:00
|
|
|
|
|
|
|
bool cmState::GetIsInTryCompile() const
|
|
|
|
{
|
|
|
|
return this->IsInTryCompile;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::SetIsInTryCompile(bool b)
|
|
|
|
{
|
|
|
|
this->IsInTryCompile = b;
|
|
|
|
}
|
2015-04-11 13:30:26 +03:00
|
|
|
|
|
|
|
void cmState::RenameCommand(std::string const& oldName,
|
|
|
|
std::string const& newName)
|
|
|
|
{
|
|
|
|
// if the command already exists, free the old one
|
|
|
|
std::string sOldName = cmSystemTools::LowerCase(oldName);
|
|
|
|
std::string sNewName = cmSystemTools::LowerCase(newName);
|
|
|
|
std::map<std::string, cmCommand*>::iterator pos =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Commands.find(sOldName);
|
|
|
|
if (pos == this->Commands.end()) {
|
2015-04-11 13:30:26 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-11 13:30:26 +03:00
|
|
|
cmCommand* cmd = pos->second;
|
|
|
|
|
|
|
|
pos = this->Commands.find(sNewName);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pos != this->Commands.end()) {
|
2015-04-11 13:30:26 +03:00
|
|
|
delete pos->second;
|
|
|
|
this->Commands.erase(pos);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-11 13:30:26 +03:00
|
|
|
this->Commands.insert(std::make_pair(sNewName, cmd));
|
|
|
|
pos = this->Commands.find(sOldName);
|
|
|
|
this->Commands.erase(pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::AddCommand(cmCommand* command)
|
|
|
|
{
|
|
|
|
std::string name = cmSystemTools::LowerCase(command->GetName());
|
|
|
|
// if the command already exists, free the old one
|
|
|
|
std::map<std::string, cmCommand*>::iterator pos = this->Commands.find(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pos != this->Commands.end()) {
|
2015-04-11 13:30:26 +03:00
|
|
|
delete pos->second;
|
|
|
|
this->Commands.erase(pos);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-11 13:30:26 +03:00
|
|
|
this->Commands.insert(std::make_pair(name, command));
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::RemoveUnscriptableCommands()
|
|
|
|
{
|
|
|
|
std::vector<std::string> unscriptableCommands;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::map<std::string, cmCommand*>::iterator pos =
|
|
|
|
this->Commands.begin();
|
|
|
|
pos != this->Commands.end();) {
|
|
|
|
if (!pos->second->IsScriptable()) {
|
2015-04-11 13:30:26 +03:00
|
|
|
delete pos->second;
|
|
|
|
this->Commands.erase(pos++);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-04-11 13:30:26 +03:00
|
|
|
++pos;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-11 13:30:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
cmCommand* cmState::GetCommand(std::string const& name) const
|
|
|
|
{
|
|
|
|
cmCommand* command = 0;
|
|
|
|
std::string sName = cmSystemTools::LowerCase(name);
|
|
|
|
std::map<std::string, cmCommand*>::const_iterator pos =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Commands.find(sName);
|
|
|
|
if (pos != this->Commands.end()) {
|
2015-04-11 13:30:26 +03:00
|
|
|
command = (*pos).second;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-11 13:30:26 +03:00
|
|
|
return command;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> cmState::GetCommandNames() const
|
|
|
|
{
|
|
|
|
std::vector<std::string> commandNames;
|
|
|
|
commandNames.reserve(this->Commands.size());
|
2016-05-16 17:34:04 +03:00
|
|
|
std::map<std::string, cmCommand*>::const_iterator cmds =
|
|
|
|
this->Commands.begin();
|
|
|
|
for (; cmds != this->Commands.end(); ++cmds) {
|
2015-04-11 13:30:26 +03:00
|
|
|
commandNames.push_back(cmds->first);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-11 13:30:26 +03:00
|
|
|
return commandNames;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::RemoveUserDefinedCommands()
|
|
|
|
{
|
2015-07-11 11:51:36 +03:00
|
|
|
std::vector<cmCommand*> renamedCommands;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::map<std::string, cmCommand*>::iterator j = this->Commands.begin();
|
|
|
|
j != this->Commands.end();) {
|
2015-04-11 13:30:26 +03:00
|
|
|
if (j->second->IsA("cmMacroHelperCommand") ||
|
2016-05-16 17:34:04 +03:00
|
|
|
j->second->IsA("cmFunctionHelperCommand")) {
|
2015-04-11 13:30:26 +03:00
|
|
|
delete j->second;
|
|
|
|
this->Commands.erase(j++);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (j->first != j->second->GetName()) {
|
2015-07-11 11:51:36 +03:00
|
|
|
renamedCommands.push_back(j->second);
|
|
|
|
this->Commands.erase(j++);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-04-11 13:30:26 +03:00
|
|
|
++j;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-11 11:51:36 +03:00
|
|
|
for (std::vector<cmCommand*>::const_iterator it = renamedCommands.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
it != renamedCommands.end(); ++it) {
|
2015-07-11 11:51:36 +03:00
|
|
|
this->Commands[cmSystemTools::LowerCase((*it)->GetName())] = *it;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-11 13:30:26 +03:00
|
|
|
}
|
2015-04-11 15:17:46 +03:00
|
|
|
|
|
|
|
void cmState::SetGlobalProperty(const std::string& prop, const char* value)
|
|
|
|
{
|
2015-06-06 10:41:15 +03:00
|
|
|
this->GlobalProperties.SetProperty(prop, value);
|
2015-04-11 15:17:46 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmState::AppendGlobalProperty(const std::string& prop, const char* value,
|
|
|
|
bool asString)
|
2015-04-11 15:17:46 +03:00
|
|
|
{
|
2015-06-06 10:41:15 +03:00
|
|
|
this->GlobalProperties.AppendProperty(prop, value, asString);
|
2015-04-11 15:17:46 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmState::GetGlobalProperty(const std::string& prop)
|
2015-04-11 15:17:46 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (prop == "CACHE_VARIABLES") {
|
2015-04-11 15:17:46 +03:00
|
|
|
std::vector<std::string> cacheKeys = this->GetCacheEntryKeys();
|
|
|
|
this->SetGlobalProperty("CACHE_VARIABLES", cmJoin(cacheKeys, ";").c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (prop == "COMMANDS") {
|
2015-04-11 15:17:46 +03:00
|
|
|
std::vector<std::string> commands = this->GetCommandNames();
|
|
|
|
this->SetGlobalProperty("COMMANDS", cmJoin(commands, ";").c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (prop == "IN_TRY_COMPILE") {
|
2015-04-11 15:17:46 +03:00
|
|
|
this->SetGlobalProperty("IN_TRY_COMPILE",
|
2016-05-16 17:34:04 +03:00
|
|
|
this->IsInTryCompile ? "1" : "0");
|
|
|
|
} else if (prop == "ENABLED_LANGUAGES") {
|
2015-04-11 15:17:46 +03:00
|
|
|
std::string langs;
|
|
|
|
langs = cmJoin(this->EnabledLanguages, ";");
|
|
|
|
this->SetGlobalProperty("ENABLED_LANGUAGES", langs.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-11 15:17:46 +03:00
|
|
|
#define STRING_LIST_ELEMENT(F) ";" #F
|
2016-05-16 17:34:04 +03:00
|
|
|
if (prop == "CMAKE_C_KNOWN_FEATURES") {
|
2015-04-11 15:17:46 +03:00
|
|
|
return FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT) + 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (prop == "CMAKE_CXX_KNOWN_FEATURES") {
|
2015-04-11 15:17:46 +03:00
|
|
|
return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-11 15:17:46 +03:00
|
|
|
#undef STRING_LIST_ELEMENT
|
2015-06-06 10:41:30 +03:00
|
|
|
return this->GlobalProperties.GetPropertyValue(prop);
|
2015-04-11 15:17:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::GetGlobalPropertyAsBool(const std::string& prop)
|
|
|
|
{
|
|
|
|
return cmSystemTools::IsOn(this->GetGlobalProperty(prop));
|
|
|
|
}
|
2015-04-12 16:26:54 +03:00
|
|
|
|
|
|
|
void cmState::SetSourceDirectory(std::string const& sourceDirectory)
|
|
|
|
{
|
|
|
|
this->SourceDirectory = sourceDirectory;
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(this->SourceDirectory);
|
2015-05-05 00:01:29 +03:00
|
|
|
|
|
|
|
cmSystemTools::SplitPath(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::CollapseFullPath(this->SourceDirectory),
|
|
|
|
this->SourceDirectoryComponents);
|
2015-04-12 16:26:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* cmState::GetSourceDirectory() const
|
|
|
|
{
|
|
|
|
return this->SourceDirectory.c_str();
|
|
|
|
}
|
|
|
|
|
2015-05-05 00:01:29 +03:00
|
|
|
std::vector<std::string> const& cmState::GetSourceDirectoryComponents() const
|
|
|
|
{
|
|
|
|
return this->SourceDirectoryComponents;
|
|
|
|
}
|
|
|
|
|
2015-04-12 16:26:54 +03:00
|
|
|
void cmState::SetBinaryDirectory(std::string const& binaryDirectory)
|
|
|
|
{
|
|
|
|
this->BinaryDirectory = binaryDirectory;
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(this->BinaryDirectory);
|
2015-05-05 00:01:29 +03:00
|
|
|
|
|
|
|
cmSystemTools::SplitPath(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::CollapseFullPath(this->BinaryDirectory),
|
|
|
|
this->BinaryDirectoryComponents);
|
2015-04-12 16:26:54 +03:00
|
|
|
}
|
|
|
|
|
2015-05-24 12:46:30 +03:00
|
|
|
void cmState::SetWindowsShell(bool windowsShell)
|
|
|
|
{
|
|
|
|
this->WindowsShell = windowsShell;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::UseWindowsShell() const
|
|
|
|
{
|
|
|
|
return this->WindowsShell;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::SetWindowsVSIDE(bool windowsVSIDE)
|
|
|
|
{
|
|
|
|
this->WindowsVSIDE = windowsVSIDE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::UseWindowsVSIDE() const
|
|
|
|
{
|
|
|
|
return this->WindowsVSIDE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::SetWatcomWMake(bool watcomWMake)
|
|
|
|
{
|
|
|
|
this->WatcomWMake = watcomWMake;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::UseWatcomWMake() const
|
|
|
|
{
|
|
|
|
return this->WatcomWMake;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::SetMinGWMake(bool minGWMake)
|
|
|
|
{
|
|
|
|
this->MinGWMake = minGWMake;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::UseMinGWMake() const
|
|
|
|
{
|
|
|
|
return this->MinGWMake;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::SetNMake(bool nMake)
|
|
|
|
{
|
|
|
|
this->NMake = nMake;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::UseNMake() const
|
|
|
|
{
|
|
|
|
return this->NMake;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::SetMSYSShell(bool mSYSShell)
|
|
|
|
{
|
|
|
|
this->MSYSShell = mSYSShell;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::UseMSYSShell() const
|
|
|
|
{
|
|
|
|
return this->MSYSShell;
|
|
|
|
}
|
|
|
|
|
2015-10-10 15:34:26 +03:00
|
|
|
unsigned int cmState::GetCacheMajorVersion() const
|
|
|
|
{
|
2015-10-10 16:42:02 +03:00
|
|
|
return this->CacheManager->GetCacheMajorVersion();
|
2015-10-10 15:34:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int cmState::GetCacheMinorVersion() const
|
|
|
|
{
|
2015-10-10 16:42:02 +03:00
|
|
|
return this->CacheManager->GetCacheMinorVersion();
|
2015-10-10 15:34:26 +03:00
|
|
|
}
|
|
|
|
|
2015-04-12 16:26:54 +03:00
|
|
|
const char* cmState::GetBinaryDirectory() const
|
|
|
|
{
|
|
|
|
return this->BinaryDirectory.c_str();
|
|
|
|
}
|
2015-04-11 19:38:16 +03:00
|
|
|
|
2015-05-05 00:01:29 +03:00
|
|
|
std::vector<std::string> const& cmState::GetBinaryDirectoryComponents() const
|
|
|
|
{
|
|
|
|
return this->BinaryDirectoryComponents;
|
|
|
|
}
|
|
|
|
|
2015-07-18 20:11:05 +03:00
|
|
|
void cmState::Directory::ComputeRelativePathTopSource()
|
2015-05-05 00:30:29 +03:00
|
|
|
{
|
|
|
|
// Relative path conversion inside the source tree is not used to
|
|
|
|
// construct relative paths passed to build tools so it is safe to use
|
|
|
|
// even when the source is a network path.
|
|
|
|
|
2015-07-18 20:11:05 +03:00
|
|
|
cmState::Snapshot snapshot = this->Snapshot_;
|
2015-05-05 00:30:29 +03:00
|
|
|
std::vector<cmState::Snapshot> snapshots;
|
|
|
|
snapshots.push_back(snapshot);
|
2016-05-16 17:34:04 +03:00
|
|
|
while (true) {
|
2015-05-23 09:02:54 +03:00
|
|
|
snapshot = snapshot.GetBuildsystemDirectoryParent();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (snapshot.IsValid()) {
|
2015-05-05 00:30:29 +03:00
|
|
|
snapshots.push_back(snapshot);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-05-05 00:30:29 +03:00
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-05 00:30:29 +03:00
|
|
|
|
2015-07-18 20:11:05 +03:00
|
|
|
std::string result = snapshots.front().GetDirectory().GetCurrentSource();
|
2015-05-05 00:30:29 +03:00
|
|
|
|
|
|
|
for (std::vector<cmState::Snapshot>::const_iterator it =
|
2016-05-16 17:34:04 +03:00
|
|
|
snapshots.begin() + 1;
|
|
|
|
it != snapshots.end(); ++it) {
|
2015-07-18 20:11:05 +03:00
|
|
|
std::string currentSource = it->GetDirectory().GetCurrentSource();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::IsSubDirectory(result, currentSource)) {
|
2015-05-05 00:30:29 +03:00
|
|
|
result = currentSource;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-18 20:11:05 +03:00
|
|
|
this->DirectoryState->RelativePathTopSource = result;
|
2015-05-05 00:30:29 +03:00
|
|
|
}
|
|
|
|
|
2015-07-18 20:11:05 +03:00
|
|
|
void cmState::Directory::ComputeRelativePathTopBinary()
|
2015-05-05 00:30:29 +03:00
|
|
|
{
|
2015-07-18 20:11:05 +03:00
|
|
|
cmState::Snapshot snapshot = this->Snapshot_;
|
2015-05-05 00:30:29 +03:00
|
|
|
std::vector<cmState::Snapshot> snapshots;
|
|
|
|
snapshots.push_back(snapshot);
|
2016-05-16 17:34:04 +03:00
|
|
|
while (true) {
|
2015-05-23 09:02:54 +03:00
|
|
|
snapshot = snapshot.GetBuildsystemDirectoryParent();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (snapshot.IsValid()) {
|
2015-05-05 00:30:29 +03:00
|
|
|
snapshots.push_back(snapshot);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-05-05 00:30:29 +03:00
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-05 00:30:29 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string result = snapshots.front().GetDirectory().GetCurrentBinary();
|
2015-05-05 00:30:29 +03:00
|
|
|
|
|
|
|
for (std::vector<cmState::Snapshot>::const_iterator it =
|
2016-05-16 17:34:04 +03:00
|
|
|
snapshots.begin() + 1;
|
|
|
|
it != snapshots.end(); ++it) {
|
2015-07-18 20:11:05 +03:00
|
|
|
std::string currentBinary = it->GetDirectory().GetCurrentBinary();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::IsSubDirectory(result, currentBinary)) {
|
2015-05-05 00:30:29 +03:00
|
|
|
result = currentBinary;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-05 00:30:29 +03:00
|
|
|
|
|
|
|
// The current working directory on Windows cannot be a network
|
|
|
|
// path. Therefore relative paths cannot work when the binary tree
|
|
|
|
// is a network path.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (result.size() < 2 || result.substr(0, 2) != "//") {
|
2015-07-18 20:11:05 +03:00
|
|
|
this->DirectoryState->RelativePathTopBinary = result;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-07-18 20:11:05 +03:00
|
|
|
this->DirectoryState->RelativePathTopBinary = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-05 00:30:29 +03:00
|
|
|
}
|
|
|
|
|
2015-05-31 01:18:33 +03:00
|
|
|
cmState::Snapshot cmState::CreateBaseSnapshot()
|
|
|
|
{
|
2015-11-25 18:23:05 +03:00
|
|
|
PositionType pos = this->SnapshotData.Push(this->SnapshotData.Root());
|
2015-05-23 01:04:09 +03:00
|
|
|
pos->DirectoryParent = this->SnapshotData.Root();
|
2015-08-01 20:41:26 +03:00
|
|
|
pos->ScopeParent = this->SnapshotData.Root();
|
2015-08-01 20:44:47 +03:00
|
|
|
pos->SnapshotType = BaseType;
|
2015-11-24 23:00:47 +03:00
|
|
|
pos->Keep = true;
|
2015-05-23 01:04:09 +03:00
|
|
|
pos->BuildSystemDirectory =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->BuildsystemDirectory.Push(this->BuildsystemDirectory.Root());
|
2015-05-31 20:37:08 +03:00
|
|
|
pos->ExecutionListFile =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->ExecutionListFiles.Push(this->ExecutionListFiles.Root());
|
2015-07-18 13:28:49 +03:00
|
|
|
pos->IncludeDirectoryPosition = 0;
|
|
|
|
pos->CompileDefinitionsPosition = 0;
|
|
|
|
pos->CompileOptionsPosition = 0;
|
2015-08-01 08:20:26 +03:00
|
|
|
pos->BuildSystemDirectory->DirectoryEnd = pos;
|
2015-07-26 14:04:09 +03:00
|
|
|
pos->Policies = this->PolicyStack.Root();
|
|
|
|
pos->PolicyRoot = this->PolicyStack.Root();
|
|
|
|
pos->PolicyScope = this->PolicyStack.Root();
|
|
|
|
assert(pos->Policies.IsValid());
|
|
|
|
assert(pos->PolicyRoot.IsValid());
|
2015-11-25 18:23:05 +03:00
|
|
|
pos->Vars = this->VarTree.Push(this->VarTree.Root());
|
2015-06-21 22:26:43 +03:00
|
|
|
assert(pos->Vars.IsValid());
|
|
|
|
pos->Parent = this->VarTree.Root();
|
|
|
|
pos->Root = this->VarTree.Root();
|
2015-05-31 01:18:33 +03:00
|
|
|
return cmState::Snapshot(this, pos);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmState::Snapshot cmState::CreateBuildsystemDirectorySnapshot(
|
|
|
|
Snapshot originSnapshot)
|
2015-04-11 19:38:16 +03:00
|
|
|
{
|
2015-05-31 01:18:33 +03:00
|
|
|
assert(originSnapshot.IsValid());
|
2015-11-25 18:23:05 +03:00
|
|
|
PositionType pos = this->SnapshotData.Push(originSnapshot.Position);
|
2015-05-23 01:04:09 +03:00
|
|
|
pos->DirectoryParent = originSnapshot.Position;
|
2015-08-01 20:41:26 +03:00
|
|
|
pos->ScopeParent = originSnapshot.Position;
|
2015-05-23 01:04:09 +03:00
|
|
|
pos->SnapshotType = BuildsystemDirectoryType;
|
2015-11-24 23:00:47 +03:00
|
|
|
pos->Keep = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
pos->BuildSystemDirectory = this->BuildsystemDirectory.Push(
|
|
|
|
originSnapshot.Position->BuildSystemDirectory);
|
2015-05-31 20:37:08 +03:00
|
|
|
pos->ExecutionListFile =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->ExecutionListFiles.Push(originSnapshot.Position->ExecutionListFile);
|
2015-08-01 08:20:26 +03:00
|
|
|
pos->BuildSystemDirectory->DirectoryEnd = pos;
|
2015-07-26 14:04:09 +03:00
|
|
|
pos->Policies = originSnapshot.Position->Policies;
|
|
|
|
pos->PolicyRoot = originSnapshot.Position->Policies;
|
|
|
|
pos->PolicyScope = originSnapshot.Position->Policies;
|
|
|
|
assert(pos->Policies.IsValid());
|
|
|
|
assert(pos->PolicyRoot.IsValid());
|
2015-06-21 22:26:43 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmLinkedTree<cmDefinitions>::iterator origin = originSnapshot.Position->Vars;
|
2015-06-21 22:26:43 +03:00
|
|
|
pos->Parent = origin;
|
|
|
|
pos->Root = origin;
|
2015-11-25 18:23:05 +03:00
|
|
|
pos->Vars = this->VarTree.Push(origin);
|
2015-10-06 01:33:49 +03:00
|
|
|
|
2015-07-19 17:26:49 +03:00
|
|
|
cmState::Snapshot snapshot = cmState::Snapshot(this, pos);
|
|
|
|
originSnapshot.Position->BuildSystemDirectory->Children.push_back(snapshot);
|
2015-10-13 22:48:46 +03:00
|
|
|
snapshot.SetDefaultDefinitions();
|
2015-10-06 01:33:49 +03:00
|
|
|
snapshot.InitializeFromParent();
|
2015-10-13 22:52:33 +03:00
|
|
|
snapshot.SetDirectoryDefinitions();
|
2015-07-19 17:26:49 +03:00
|
|
|
return snapshot;
|
2015-04-11 19:38:16 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmState::Snapshot cmState::CreateFunctionCallSnapshot(
|
|
|
|
cmState::Snapshot originSnapshot, std::string const& fileName)
|
2015-06-21 22:26:36 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
PositionType pos =
|
|
|
|
this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position);
|
2015-08-01 20:41:26 +03:00
|
|
|
pos->ScopeParent = originSnapshot.Position;
|
2015-06-21 22:26:36 +03:00
|
|
|
pos->SnapshotType = FunctionCallType;
|
2015-11-24 23:00:47 +03:00
|
|
|
pos->Keep = false;
|
2015-11-25 18:23:05 +03:00
|
|
|
pos->ExecutionListFile = this->ExecutionListFiles.Push(
|
2016-05-16 17:34:04 +03:00
|
|
|
originSnapshot.Position->ExecutionListFile, fileName);
|
2015-08-01 08:20:26 +03:00
|
|
|
pos->BuildSystemDirectory->DirectoryEnd = pos;
|
2015-07-26 14:04:09 +03:00
|
|
|
pos->PolicyScope = originSnapshot.Position->Policies;
|
2015-06-21 22:26:43 +03:00
|
|
|
assert(originSnapshot.Position->Vars.IsValid());
|
2016-05-16 17:34:04 +03:00
|
|
|
cmLinkedTree<cmDefinitions>::iterator origin = originSnapshot.Position->Vars;
|
2015-06-21 22:26:43 +03:00
|
|
|
pos->Parent = origin;
|
2015-11-25 18:23:05 +03:00
|
|
|
pos->Vars = this->VarTree.Push(origin);
|
2015-06-21 22:26:36 +03:00
|
|
|
return cmState::Snapshot(this, pos);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmState::Snapshot cmState::CreateMacroCallSnapshot(
|
|
|
|
cmState::Snapshot originSnapshot, std::string const& fileName)
|
2015-06-21 22:26:36 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
PositionType pos =
|
|
|
|
this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position);
|
2015-06-21 22:26:36 +03:00
|
|
|
pos->SnapshotType = MacroCallType;
|
2015-11-24 23:00:47 +03:00
|
|
|
pos->Keep = false;
|
2015-11-25 18:23:05 +03:00
|
|
|
pos->ExecutionListFile = this->ExecutionListFiles.Push(
|
2016-05-16 17:34:04 +03:00
|
|
|
originSnapshot.Position->ExecutionListFile, fileName);
|
2015-06-21 22:26:43 +03:00
|
|
|
assert(originSnapshot.Position->Vars.IsValid());
|
2015-08-01 08:20:26 +03:00
|
|
|
pos->BuildSystemDirectory->DirectoryEnd = pos;
|
2015-07-26 14:04:09 +03:00
|
|
|
pos->PolicyScope = originSnapshot.Position->Policies;
|
2015-06-21 22:26:36 +03:00
|
|
|
return cmState::Snapshot(this, pos);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmState::Snapshot cmState::CreateIncludeFileSnapshot(
|
|
|
|
cmState::Snapshot originSnapshot, const std::string& fileName)
|
2015-06-21 22:26:36 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
PositionType pos =
|
|
|
|
this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position);
|
2016-04-12 23:08:24 +03:00
|
|
|
pos->SnapshotType = IncludeFileType;
|
2015-11-24 23:00:47 +03:00
|
|
|
pos->Keep = true;
|
2015-11-25 18:23:05 +03:00
|
|
|
pos->ExecutionListFile = this->ExecutionListFiles.Push(
|
2016-05-16 17:34:04 +03:00
|
|
|
originSnapshot.Position->ExecutionListFile, fileName);
|
2015-06-21 22:26:43 +03:00
|
|
|
assert(originSnapshot.Position->Vars.IsValid());
|
2015-08-01 08:20:26 +03:00
|
|
|
pos->BuildSystemDirectory->DirectoryEnd = pos;
|
2015-07-26 14:04:09 +03:00
|
|
|
pos->PolicyScope = originSnapshot.Position->Policies;
|
2015-06-21 22:26:36 +03:00
|
|
|
return cmState::Snapshot(this, pos);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmState::Snapshot cmState::CreateVariableScopeSnapshot(
|
|
|
|
cmState::Snapshot originSnapshot)
|
2015-08-01 20:41:26 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
PositionType pos =
|
|
|
|
this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position);
|
2015-08-01 20:41:26 +03:00
|
|
|
pos->ScopeParent = originSnapshot.Position;
|
|
|
|
pos->SnapshotType = VariableScopeType;
|
2015-11-24 23:00:47 +03:00
|
|
|
pos->Keep = false;
|
2015-11-24 21:37:34 +03:00
|
|
|
pos->PolicyScope = originSnapshot.Position->Policies;
|
2015-06-21 22:26:43 +03:00
|
|
|
assert(originSnapshot.Position->Vars.IsValid());
|
2015-08-01 20:41:26 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmLinkedTree<cmDefinitions>::iterator origin = originSnapshot.Position->Vars;
|
2015-06-21 22:26:43 +03:00
|
|
|
pos->Parent = origin;
|
2015-11-25 18:23:05 +03:00
|
|
|
pos->Vars = this->VarTree.Push(origin);
|
2015-06-21 22:26:43 +03:00
|
|
|
assert(pos->Vars.IsValid());
|
2015-08-01 20:41:26 +03:00
|
|
|
return cmState::Snapshot(this, pos);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmState::Snapshot cmState::CreateInlineListFileSnapshot(
|
|
|
|
cmState::Snapshot originSnapshot, const std::string& fileName)
|
2015-06-21 22:26:36 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
PositionType pos =
|
|
|
|
this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position);
|
2015-06-21 22:26:36 +03:00
|
|
|
pos->SnapshotType = InlineListFileType;
|
2015-11-24 23:00:47 +03:00
|
|
|
pos->Keep = true;
|
2015-11-25 18:23:05 +03:00
|
|
|
pos->ExecutionListFile = this->ExecutionListFiles.Push(
|
2016-05-16 17:34:04 +03:00
|
|
|
originSnapshot.Position->ExecutionListFile, fileName);
|
2015-08-01 08:20:26 +03:00
|
|
|
pos->BuildSystemDirectory->DirectoryEnd = pos;
|
2015-07-26 14:04:09 +03:00
|
|
|
pos->PolicyScope = originSnapshot.Position->Policies;
|
2015-06-21 22:26:36 +03:00
|
|
|
return cmState::Snapshot(this, pos);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmState::Snapshot cmState::CreatePolicyScopeSnapshot(
|
|
|
|
cmState::Snapshot originSnapshot)
|
2015-07-26 13:56:10 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
PositionType pos =
|
|
|
|
this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position);
|
2015-07-26 13:56:10 +03:00
|
|
|
pos->SnapshotType = PolicyScopeType;
|
2015-11-24 23:00:47 +03:00
|
|
|
pos->Keep = false;
|
2015-08-01 08:20:26 +03:00
|
|
|
pos->BuildSystemDirectory->DirectoryEnd = pos;
|
2015-07-26 14:04:09 +03:00
|
|
|
pos->PolicyScope = originSnapshot.Position->Policies;
|
2015-07-26 13:56:10 +03:00
|
|
|
return cmState::Snapshot(this, pos);
|
|
|
|
}
|
|
|
|
|
2015-06-21 22:26:36 +03:00
|
|
|
cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot)
|
|
|
|
{
|
|
|
|
PositionType pos = originSnapshot.Position;
|
|
|
|
PositionType prevPos = pos;
|
|
|
|
++prevPos;
|
2015-07-18 13:28:49 +03:00
|
|
|
prevPos->IncludeDirectoryPosition =
|
2016-05-16 17:34:04 +03:00
|
|
|
prevPos->BuildSystemDirectory->IncludeDirectories.size();
|
2015-07-18 13:28:49 +03:00
|
|
|
prevPos->CompileDefinitionsPosition =
|
2016-05-16 17:34:04 +03:00
|
|
|
prevPos->BuildSystemDirectory->CompileDefinitions.size();
|
2015-07-18 13:28:49 +03:00
|
|
|
prevPos->CompileOptionsPosition =
|
2016-05-16 17:34:04 +03:00
|
|
|
prevPos->BuildSystemDirectory->CompileOptions.size();
|
2015-08-01 08:20:26 +03:00
|
|
|
prevPos->BuildSystemDirectory->DirectoryEnd = prevPos;
|
2015-07-18 13:28:49 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!pos->Keep && this->SnapshotData.IsLast(pos)) {
|
|
|
|
if (pos->Vars != prevPos->Vars) {
|
2015-11-24 23:00:47 +03:00
|
|
|
assert(this->VarTree.IsLast(pos->Vars));
|
|
|
|
this->VarTree.Pop(pos->Vars);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (pos->ExecutionListFile != prevPos->ExecutionListFile) {
|
2015-11-24 23:00:47 +03:00
|
|
|
assert(this->ExecutionListFiles.IsLast(pos->ExecutionListFile));
|
|
|
|
this->ExecutionListFiles.Pop(pos->ExecutionListFile);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SnapshotData.Pop(pos);
|
|
|
|
}
|
2015-11-24 23:00:47 +03:00
|
|
|
|
2015-08-01 08:29:36 +03:00
|
|
|
return Snapshot(this, prevPos);
|
2015-06-21 22:26:36 +03:00
|
|
|
}
|
|
|
|
|
2015-07-23 16:11:37 +03:00
|
|
|
cmState::Snapshot::Snapshot(cmState* state)
|
|
|
|
: State(state)
|
|
|
|
, Position()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-07-19 17:26:49 +03:00
|
|
|
std::vector<cmState::Snapshot> cmState::Snapshot::GetChildren()
|
|
|
|
{
|
|
|
|
return this->Position->BuildSystemDirectory->Children;
|
|
|
|
}
|
|
|
|
|
2015-04-11 19:38:16 +03:00
|
|
|
cmState::Snapshot::Snapshot(cmState* state, PositionType position)
|
2016-05-16 17:34:04 +03:00
|
|
|
: State(state)
|
|
|
|
, Position(position)
|
2015-04-11 19:38:16 +03:00
|
|
|
{
|
|
|
|
}
|
2015-04-28 08:50:31 +03:00
|
|
|
|
2015-07-26 13:54:16 +03:00
|
|
|
cmState::SnapshotType cmState::Snapshot::GetType() const
|
|
|
|
{
|
|
|
|
return this->Position->SnapshotType;
|
|
|
|
}
|
|
|
|
|
2015-07-18 20:11:05 +03:00
|
|
|
const char* cmState::Directory::GetCurrentSource() const
|
2015-04-28 08:50:31 +03:00
|
|
|
{
|
2015-07-18 20:11:05 +03:00
|
|
|
return this->DirectoryState->Location.c_str();
|
2015-04-28 08:50:31 +03:00
|
|
|
}
|
|
|
|
|
2015-07-18 20:11:05 +03:00
|
|
|
void cmState::Directory::SetCurrentSource(std::string const& dir)
|
2015-04-28 08:50:31 +03:00
|
|
|
{
|
2015-07-18 20:11:05 +03:00
|
|
|
std::string& loc = this->DirectoryState->Location;
|
2015-05-23 11:37:07 +03:00
|
|
|
loc = dir;
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(loc);
|
|
|
|
loc = cmSystemTools::CollapseFullPath(loc);
|
2015-05-05 00:08:19 +03:00
|
|
|
|
|
|
|
cmSystemTools::SplitPath(
|
2016-05-16 17:34:04 +03:00
|
|
|
loc, this->DirectoryState->CurrentSourceDirectoryComponents);
|
2015-05-05 00:30:29 +03:00
|
|
|
this->ComputeRelativePathTopSource();
|
2015-10-13 22:57:54 +03:00
|
|
|
|
|
|
|
this->Snapshot_.SetDefinition("CMAKE_CURRENT_SOURCE_DIR", loc.c_str());
|
2015-04-28 08:50:31 +03:00
|
|
|
}
|
|
|
|
|
2015-07-18 20:11:05 +03:00
|
|
|
const char* cmState::Directory::GetCurrentBinary() const
|
2015-04-28 08:50:31 +03:00
|
|
|
{
|
2015-07-18 20:11:05 +03:00
|
|
|
return this->DirectoryState->OutputLocation.c_str();
|
2015-04-28 08:50:31 +03:00
|
|
|
}
|
|
|
|
|
2015-07-18 20:11:05 +03:00
|
|
|
void cmState::Directory::SetCurrentBinary(std::string const& dir)
|
2015-04-28 08:50:31 +03:00
|
|
|
{
|
2015-07-18 20:11:05 +03:00
|
|
|
std::string& loc = this->DirectoryState->OutputLocation;
|
2015-05-23 11:37:07 +03:00
|
|
|
loc = dir;
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(loc);
|
|
|
|
loc = cmSystemTools::CollapseFullPath(loc);
|
2015-05-05 00:08:19 +03:00
|
|
|
|
|
|
|
cmSystemTools::SplitPath(
|
2016-05-16 17:34:04 +03:00
|
|
|
loc, this->DirectoryState->CurrentBinaryDirectoryComponents);
|
2015-05-05 00:30:29 +03:00
|
|
|
this->ComputeRelativePathTopBinary();
|
2015-10-13 22:57:54 +03:00
|
|
|
|
|
|
|
this->Snapshot_.SetDefinition("CMAKE_CURRENT_BINARY_DIR", loc.c_str());
|
2015-05-05 00:08:19 +03:00
|
|
|
}
|
|
|
|
|
2015-05-31 20:37:08 +03:00
|
|
|
void cmState::Snapshot::SetListFile(const std::string& listfile)
|
|
|
|
{
|
|
|
|
*this->Position->ExecutionListFile = listfile;
|
|
|
|
}
|
|
|
|
|
2015-05-05 00:08:19 +03:00
|
|
|
std::vector<std::string> const&
|
2015-07-18 20:11:05 +03:00
|
|
|
cmState::Directory::GetCurrentSourceComponents() const
|
2015-05-05 00:08:19 +03:00
|
|
|
{
|
2015-07-18 20:11:05 +03:00
|
|
|
return this->DirectoryState->CurrentSourceDirectoryComponents;
|
2015-05-05 00:08:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> const&
|
2015-07-18 20:11:05 +03:00
|
|
|
cmState::Directory::GetCurrentBinaryComponents() const
|
2015-05-05 00:08:19 +03:00
|
|
|
{
|
2015-07-18 20:11:05 +03:00
|
|
|
return this->DirectoryState->CurrentBinaryDirectoryComponents;
|
2015-04-28 08:50:31 +03:00
|
|
|
}
|
2015-05-04 23:38:37 +03:00
|
|
|
|
2015-07-18 20:11:05 +03:00
|
|
|
const char* cmState::Directory::GetRelativePathTopSource() const
|
2015-05-05 00:30:29 +03:00
|
|
|
{
|
2015-07-18 20:11:05 +03:00
|
|
|
return this->DirectoryState->RelativePathTopSource.c_str();
|
2015-05-05 00:30:29 +03:00
|
|
|
}
|
|
|
|
|
2015-07-18 20:11:05 +03:00
|
|
|
const char* cmState::Directory::GetRelativePathTopBinary() const
|
2015-05-05 00:30:29 +03:00
|
|
|
{
|
2015-07-18 20:11:05 +03:00
|
|
|
return this->DirectoryState->RelativePathTopBinary.c_str();
|
2015-05-05 00:30:29 +03:00
|
|
|
}
|
|
|
|
|
2015-07-18 20:11:05 +03:00
|
|
|
void cmState::Directory::SetRelativePathTopSource(const char* dir)
|
2015-05-05 00:30:29 +03:00
|
|
|
{
|
2015-07-18 20:11:05 +03:00
|
|
|
this->DirectoryState->RelativePathTopSource = dir;
|
2015-05-05 00:30:29 +03:00
|
|
|
}
|
|
|
|
|
2015-07-18 20:11:05 +03:00
|
|
|
void cmState::Directory::SetRelativePathTopBinary(const char* dir)
|
2015-05-05 00:30:29 +03:00
|
|
|
{
|
2015-07-18 20:11:05 +03:00
|
|
|
this->DirectoryState->RelativePathTopBinary = dir;
|
2015-05-05 00:30:29 +03:00
|
|
|
}
|
|
|
|
|
2015-05-31 20:37:08 +03:00
|
|
|
std::string cmState::Snapshot::GetExecutionListFile() const
|
|
|
|
{
|
|
|
|
return *this->Position->ExecutionListFile;
|
|
|
|
}
|
|
|
|
|
2015-05-04 23:38:37 +03:00
|
|
|
bool cmState::Snapshot::IsValid() const
|
|
|
|
{
|
2015-05-23 01:04:09 +03:00
|
|
|
return this->State && this->Position.IsValid()
|
2016-05-16 17:34:04 +03:00
|
|
|
? this->Position != this->State->SnapshotData.Root()
|
|
|
|
: false;
|
2015-05-04 23:38:37 +03:00
|
|
|
}
|
|
|
|
|
2015-05-23 09:02:54 +03:00
|
|
|
cmState::Snapshot cmState::Snapshot::GetBuildsystemDirectoryParent() const
|
2015-05-04 23:38:37 +03:00
|
|
|
{
|
|
|
|
Snapshot snapshot;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->State || this->Position == this->State->SnapshotData.Root()) {
|
2015-05-04 23:38:37 +03:00
|
|
|
return snapshot;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-23 01:04:09 +03:00
|
|
|
PositionType parentPos = this->Position->DirectoryParent;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (parentPos != this->State->SnapshotData.Root()) {
|
|
|
|
snapshot =
|
|
|
|
Snapshot(this->State, parentPos->BuildSystemDirectory->DirectoryEnd);
|
|
|
|
}
|
2015-05-04 23:38:37 +03:00
|
|
|
|
|
|
|
return snapshot;
|
|
|
|
}
|
2015-06-04 20:33:38 +03:00
|
|
|
|
2015-07-04 07:56:13 +03:00
|
|
|
cmState::Snapshot cmState::Snapshot::GetCallStackParent() const
|
|
|
|
{
|
|
|
|
assert(this->State);
|
|
|
|
assert(this->Position != this->State->SnapshotData.Root());
|
|
|
|
|
|
|
|
Snapshot snapshot;
|
2015-07-26 13:56:10 +03:00
|
|
|
PositionType parentPos = this->Position;
|
2015-11-24 22:05:43 +03:00
|
|
|
while (parentPos->SnapshotType == cmState::PolicyScopeType ||
|
2016-05-16 17:34:04 +03:00
|
|
|
parentPos->SnapshotType == cmState::VariableScopeType) {
|
2015-07-26 13:56:10 +03:00
|
|
|
++parentPos;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (parentPos->SnapshotType == cmState::BuildsystemDirectoryType ||
|
|
|
|
parentPos->SnapshotType == cmState::BaseType) {
|
2015-07-04 07:56:13 +03:00
|
|
|
return snapshot;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-04 07:56:13 +03:00
|
|
|
|
|
|
|
++parentPos;
|
2015-11-24 22:05:43 +03:00
|
|
|
while (parentPos->SnapshotType == cmState::PolicyScopeType ||
|
2016-05-16 17:34:04 +03:00
|
|
|
parentPos->SnapshotType == cmState::VariableScopeType) {
|
2015-07-26 13:56:10 +03:00
|
|
|
++parentPos;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-26 13:56:10 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (parentPos == this->State->SnapshotData.Root()) {
|
2015-07-04 07:56:13 +03:00
|
|
|
return snapshot;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-04 07:56:13 +03:00
|
|
|
|
|
|
|
snapshot = Snapshot(this->State, parentPos);
|
|
|
|
return snapshot;
|
|
|
|
}
|
|
|
|
|
2016-04-13 16:41:24 +03:00
|
|
|
cmState::Snapshot cmState::Snapshot::GetCallStackBottom() const
|
|
|
|
{
|
|
|
|
assert(this->State);
|
|
|
|
assert(this->Position != this->State->SnapshotData.Root());
|
|
|
|
|
|
|
|
PositionType pos = this->Position;
|
|
|
|
while (pos->SnapshotType != cmState::BaseType &&
|
|
|
|
pos->SnapshotType != cmState::BuildsystemDirectoryType &&
|
2016-05-16 17:34:04 +03:00
|
|
|
pos != this->State->SnapshotData.Root()) {
|
2016-04-13 16:41:24 +03:00
|
|
|
++pos;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-04-13 16:41:24 +03:00
|
|
|
return Snapshot(this->State, pos);
|
|
|
|
}
|
|
|
|
|
2015-07-26 14:04:09 +03:00
|
|
|
void cmState::Snapshot::PushPolicy(cmPolicies::PolicyMap entry, bool weak)
|
|
|
|
{
|
|
|
|
PositionType pos = this->Position;
|
2016-05-16 17:34:04 +03:00
|
|
|
pos->Policies = this->State->PolicyStack.Push(pos->Policies,
|
|
|
|
PolicyStackEntry(entry, weak));
|
2015-07-26 14:04:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::Snapshot::PopPolicy()
|
|
|
|
{
|
|
|
|
PositionType pos = this->Position;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pos->Policies == pos->PolicyScope) {
|
2015-07-26 14:04:09 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-11-24 22:44:19 +03:00
|
|
|
pos->Policies = this->State->PolicyStack.Pop(pos->Policies);
|
2015-07-26 14:04:09 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::Snapshot::CanPopPolicyScope()
|
|
|
|
{
|
|
|
|
return this->Position->Policies == this->Position->PolicyScope;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::Snapshot::SetPolicy(cmPolicies::PolicyID id,
|
|
|
|
cmPolicies::PolicyStatus status)
|
|
|
|
{
|
|
|
|
// Update the policy stack from the top to the top-most strong entry.
|
|
|
|
bool previous_was_weak = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cmLinkedTree<PolicyStackEntry>::iterator psi = this->Position->Policies;
|
|
|
|
previous_was_weak && psi != this->Position->PolicyRoot; ++psi) {
|
2015-07-26 14:04:09 +03:00
|
|
|
psi->Set(id, status);
|
|
|
|
previous_was_weak = psi->Weak;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-26 14:04:09 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmPolicies::PolicyStatus cmState::Snapshot::GetPolicy(
|
|
|
|
cmPolicies::PolicyID id) const
|
2015-07-26 14:04:09 +03:00
|
|
|
{
|
|
|
|
cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (status == cmPolicies::REQUIRED_ALWAYS ||
|
|
|
|
status == cmPolicies::REQUIRED_IF_USED) {
|
2015-07-26 14:04:09 +03:00
|
|
|
return status;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-26 14:04:09 +03:00
|
|
|
|
|
|
|
cmLinkedTree<BuildsystemDirectoryStateType>::iterator dir =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Position->BuildSystemDirectory;
|
2015-07-26 14:04:09 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
while (true) {
|
2015-07-26 14:04:09 +03:00
|
|
|
assert(dir.IsValid());
|
|
|
|
cmLinkedTree<PolicyStackEntry>::iterator leaf =
|
2016-05-16 17:34:04 +03:00
|
|
|
dir->DirectoryEnd->Policies;
|
2015-07-26 14:04:09 +03:00
|
|
|
cmLinkedTree<PolicyStackEntry>::iterator root =
|
2016-05-16 17:34:04 +03:00
|
|
|
dir->DirectoryEnd->PolicyRoot;
|
|
|
|
for (; leaf != root; ++leaf) {
|
|
|
|
if (leaf->IsDefined(id)) {
|
2015-07-26 14:04:09 +03:00
|
|
|
status = leaf->Get(id);
|
|
|
|
return status;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-26 14:04:09 +03:00
|
|
|
cmState::PositionType e = dir->DirectoryEnd;
|
|
|
|
cmState::PositionType p = e->DirectoryParent;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (p == this->State->SnapshotData.Root()) {
|
2015-07-26 14:04:09 +03:00
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
dir = p->BuildSystemDirectory;
|
|
|
|
}
|
2015-07-26 14:04:09 +03:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::Snapshot::HasDefinedPolicyCMP0011()
|
|
|
|
{
|
|
|
|
return !this->Position->Policies->IsEmpty();
|
|
|
|
}
|
|
|
|
|
2015-06-21 22:26:43 +03:00
|
|
|
const char* cmState::Snapshot::GetDefinition(std::string const& name) const
|
|
|
|
{
|
|
|
|
assert(this->Position->Vars.IsValid());
|
2016-05-16 17:34:04 +03:00
|
|
|
return cmDefinitions::Get(name, this->Position->Vars, this->Position->Root);
|
2015-06-21 22:26:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::Snapshot::IsInitialized(std::string const& name) const
|
|
|
|
{
|
|
|
|
return cmDefinitions::HasKey(name, this->Position->Vars,
|
|
|
|
this->Position->Root);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::Snapshot::SetDefinition(std::string const& name,
|
|
|
|
std::string const& value)
|
|
|
|
{
|
|
|
|
this->Position->Vars->Set(name, value.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::Snapshot::RemoveDefinition(std::string const& name)
|
|
|
|
{
|
|
|
|
this->Position->Vars->Set(name, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> cmState::Snapshot::UnusedKeys() const
|
|
|
|
{
|
|
|
|
return this->Position->Vars->UnusedKeys();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> cmState::Snapshot::ClosureKeys() const
|
|
|
|
{
|
|
|
|
return cmDefinitions::ClosureKeys(this->Position->Vars,
|
|
|
|
this->Position->Root);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::Snapshot::RaiseScope(std::string const& var, const char* varDef)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Position->ScopeParent == this->Position->DirectoryParent) {
|
2015-06-21 22:26:43 +03:00
|
|
|
Snapshot parentDir = this->GetBuildsystemDirectoryParent();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!parentDir.IsValid()) {
|
2015-06-21 22:26:43 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-06-21 22:26:43 +03:00
|
|
|
// Update the definition in the parent directory top scope. This
|
|
|
|
// directory's scope was initialized by the closure of the parent
|
|
|
|
// scope, so we do not need to localize the definition first.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (varDef) {
|
2015-06-21 22:26:43 +03:00
|
|
|
parentDir.SetDefinition(var, varDef);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-06-21 22:26:43 +03:00
|
|
|
parentDir.RemoveDefinition(var);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return true;
|
|
|
|
}
|
2015-06-21 22:26:43 +03:00
|
|
|
// First localize the definition in the current scope.
|
2016-05-16 17:34:04 +03:00
|
|
|
cmDefinitions::Raise(var, this->Position->Vars, this->Position->Root);
|
2015-06-21 22:26:43 +03:00
|
|
|
|
|
|
|
// Now update the definition in the parent scope.
|
|
|
|
this->Position->Parent->Set(var, varDef);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-07-18 13:28:49 +03:00
|
|
|
static const std::string cmPropertySentinal = std::string();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <typename T, typename U, typename V>
|
|
|
|
void InitializeContentFromParent(T& parentContent, T& thisContent,
|
|
|
|
U& parentBacktraces, U& thisBacktraces,
|
|
|
|
V& contentEndPosition)
|
2015-07-18 13:28:49 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<std::string>::const_iterator parentBegin = parentContent.begin();
|
|
|
|
std::vector<std::string>::const_iterator parentEnd = parentContent.end();
|
2015-07-18 13:28:49 +03:00
|
|
|
|
|
|
|
std::vector<std::string>::const_reverse_iterator parentRbegin =
|
2016-05-16 17:34:04 +03:00
|
|
|
cmMakeReverseIterator(parentEnd);
|
2015-07-18 13:28:49 +03:00
|
|
|
std::vector<std::string>::const_reverse_iterator parentRend =
|
2016-05-16 17:34:04 +03:00
|
|
|
parentContent.rend();
|
2015-07-18 13:28:49 +03:00
|
|
|
parentRbegin = std::find(parentRbegin, parentRend, cmPropertySentinal);
|
|
|
|
std::vector<std::string>::const_iterator parentIt = parentRbegin.base();
|
|
|
|
|
|
|
|
thisContent = std::vector<std::string>(parentIt, parentEnd);
|
|
|
|
|
|
|
|
std::vector<cmListFileBacktrace>::const_iterator btIt =
|
2016-05-16 17:34:04 +03:00
|
|
|
parentBacktraces.begin() + std::distance(parentBegin, parentIt);
|
2015-07-18 13:28:49 +03:00
|
|
|
std::vector<cmListFileBacktrace>::const_iterator btEnd =
|
2016-05-16 17:34:04 +03:00
|
|
|
parentBacktraces.end();
|
2015-07-18 13:28:49 +03:00
|
|
|
|
|
|
|
thisBacktraces = std::vector<cmListFileBacktrace>(btIt, btEnd);
|
|
|
|
|
|
|
|
contentEndPosition = thisContent.size();
|
|
|
|
}
|
|
|
|
|
2015-10-13 22:48:46 +03:00
|
|
|
void cmState::Snapshot::SetDefaultDefinitions()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
/* Up to CMake 2.4 here only WIN32, UNIX and APPLE were set.
|
|
|
|
With CMake must separate between target and host platform. In most cases
|
|
|
|
the tests for WIN32, UNIX and APPLE will be for the target system, so an
|
|
|
|
additional set of variables for the host system is required ->
|
|
|
|
CMAKE_HOST_WIN32, CMAKE_HOST_UNIX, CMAKE_HOST_APPLE.
|
|
|
|
WIN32, UNIX and APPLE are now set in the platform files in
|
|
|
|
Modules/Platforms/.
|
|
|
|
To keep cmake scripts (-P) and custom language and compiler modules
|
|
|
|
working, these variables are still also set here in this place, but they
|
|
|
|
will be reset in CMakeSystemSpecificInformation.cmake before the platform
|
|
|
|
files are executed. */
|
|
|
|
#if defined(_WIN32)
|
|
|
|
this->SetDefinition("WIN32", "1");
|
|
|
|
this->SetDefinition("CMAKE_HOST_WIN32", "1");
|
|
|
|
#else
|
|
|
|
this->SetDefinition("UNIX", "1");
|
|
|
|
this->SetDefinition("CMAKE_HOST_UNIX", "1");
|
|
|
|
#endif
|
|
|
|
#if defined(__CYGWIN__)
|
|
|
|
if (cmSystemTools::IsOn(
|
|
|
|
cmSystemTools::GetEnv("CMAKE_LEGACY_CYGWIN_WIN32"))) {
|
2015-10-13 22:48:46 +03:00
|
|
|
this->SetDefinition("WIN32", "1");
|
|
|
|
this->SetDefinition("CMAKE_HOST_WIN32", "1");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if defined(__APPLE__)
|
|
|
|
this->SetDefinition("APPLE", "1");
|
|
|
|
this->SetDefinition("CMAKE_HOST_APPLE", "1");
|
|
|
|
#endif
|
|
|
|
#if defined(__sun__)
|
|
|
|
this->SetDefinition("CMAKE_HOST_SOLARIS", "1");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
char temp[1024];
|
|
|
|
sprintf(temp, "%d", cmVersion::GetMinorVersion());
|
|
|
|
this->SetDefinition("CMAKE_MINOR_VERSION", temp);
|
|
|
|
sprintf(temp, "%d", cmVersion::GetMajorVersion());
|
|
|
|
this->SetDefinition("CMAKE_MAJOR_VERSION", temp);
|
|
|
|
sprintf(temp, "%d", cmVersion::GetPatchVersion());
|
|
|
|
this->SetDefinition("CMAKE_PATCH_VERSION", temp);
|
|
|
|
sprintf(temp, "%d", cmVersion::GetTweakVersion());
|
|
|
|
this->SetDefinition("CMAKE_TWEAK_VERSION", temp);
|
|
|
|
this->SetDefinition("CMAKE_VERSION", cmVersion::GetCMakeVersion());
|
|
|
|
|
|
|
|
this->SetDefinition("CMAKE_FILES_DIRECTORY",
|
|
|
|
cmake::GetCMakeFilesDirectory());
|
2015-10-07 23:34:49 +03:00
|
|
|
|
|
|
|
// Setup the default include file regular expression (match everything).
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Position->BuildSystemDirectory->Properties.SetProperty(
|
|
|
|
"INCLUDE_REGULAR_EXPRESSION", "^.*$");
|
2015-10-13 22:48:46 +03:00
|
|
|
}
|
|
|
|
|
2015-10-13 22:52:33 +03:00
|
|
|
void cmState::Snapshot::SetDirectoryDefinitions()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SetDefinition("CMAKE_SOURCE_DIR", this->State->GetSourceDirectory());
|
2015-10-13 22:57:54 +03:00
|
|
|
this->SetDefinition("CMAKE_CURRENT_SOURCE_DIR",
|
|
|
|
this->State->GetSourceDirectory());
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SetDefinition("CMAKE_BINARY_DIR", this->State->GetBinaryDirectory());
|
2015-10-13 22:57:54 +03:00
|
|
|
this->SetDefinition("CMAKE_CURRENT_BINARY_DIR",
|
|
|
|
this->State->GetBinaryDirectory());
|
2015-10-13 22:52:33 +03:00
|
|
|
}
|
|
|
|
|
2015-07-18 13:28:49 +03:00
|
|
|
void cmState::Snapshot::InitializeFromParent()
|
|
|
|
{
|
|
|
|
PositionType parent = this->Position->DirectoryParent;
|
2015-06-21 22:26:43 +03:00
|
|
|
assert(this->Position->Vars.IsValid());
|
|
|
|
assert(parent->Vars.IsValid());
|
|
|
|
|
|
|
|
*this->Position->Vars =
|
2016-05-16 17:34:04 +03:00
|
|
|
cmDefinitions::MakeClosure(parent->Vars, parent->Root);
|
|
|
|
|
|
|
|
InitializeContentFromParent(
|
|
|
|
parent->BuildSystemDirectory->IncludeDirectories,
|
|
|
|
this->Position->BuildSystemDirectory->IncludeDirectories,
|
|
|
|
parent->BuildSystemDirectory->IncludeDirectoryBacktraces,
|
|
|
|
this->Position->BuildSystemDirectory->IncludeDirectoryBacktraces,
|
|
|
|
this->Position->IncludeDirectoryPosition);
|
|
|
|
|
|
|
|
InitializeContentFromParent(
|
|
|
|
parent->BuildSystemDirectory->CompileDefinitions,
|
|
|
|
this->Position->BuildSystemDirectory->CompileDefinitions,
|
|
|
|
parent->BuildSystemDirectory->CompileDefinitionsBacktraces,
|
|
|
|
this->Position->BuildSystemDirectory->CompileDefinitionsBacktraces,
|
|
|
|
this->Position->CompileDefinitionsPosition);
|
|
|
|
|
|
|
|
InitializeContentFromParent(
|
|
|
|
parent->BuildSystemDirectory->CompileOptions,
|
|
|
|
this->Position->BuildSystemDirectory->CompileOptions,
|
|
|
|
parent->BuildSystemDirectory->CompileOptionsBacktraces,
|
|
|
|
this->Position->BuildSystemDirectory->CompileOptionsBacktraces,
|
|
|
|
this->Position->CompileOptionsPosition);
|
2015-07-18 13:28:49 +03:00
|
|
|
}
|
|
|
|
|
2015-06-04 20:33:38 +03:00
|
|
|
cmState* cmState::Snapshot::GetState() const
|
|
|
|
{
|
|
|
|
return this->State;
|
|
|
|
}
|
2015-07-18 20:11:05 +03:00
|
|
|
|
|
|
|
cmState::Directory cmState::Snapshot::GetDirectory() const
|
|
|
|
{
|
|
|
|
return Directory(this->Position->BuildSystemDirectory, *this);
|
|
|
|
}
|
|
|
|
|
2015-08-02 10:41:06 +03:00
|
|
|
void cmState::Snapshot::SetProjectName(const std::string& name)
|
|
|
|
{
|
|
|
|
this->Position->BuildSystemDirectory->ProjectName = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string cmState::Snapshot::GetProjectName() const
|
|
|
|
{
|
|
|
|
return this->Position->BuildSystemDirectory->ProjectName;
|
|
|
|
}
|
|
|
|
|
2015-10-12 20:34:06 +03:00
|
|
|
void cmState::Snapshot::InitializeFromParent_ForSubdirsCommand()
|
|
|
|
{
|
|
|
|
std::string currentSrcDir = this->GetDefinition("CMAKE_CURRENT_SOURCE_DIR");
|
|
|
|
std::string currentBinDir = this->GetDefinition("CMAKE_CURRENT_BINARY_DIR");
|
|
|
|
this->InitializeFromParent();
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SetDefinition("CMAKE_SOURCE_DIR", this->State->GetSourceDirectory());
|
|
|
|
this->SetDefinition("CMAKE_BINARY_DIR", this->State->GetBinaryDirectory());
|
2015-10-12 20:34:06 +03:00
|
|
|
|
|
|
|
this->SetDefinition("CMAKE_CURRENT_SOURCE_DIR", currentSrcDir.c_str());
|
|
|
|
this->SetDefinition("CMAKE_CURRENT_BINARY_DIR", currentBinDir.c_str());
|
|
|
|
}
|
|
|
|
|
2015-07-18 20:11:05 +03:00
|
|
|
cmState::Directory::Directory(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmLinkedTree<BuildsystemDirectoryStateType>::iterator iter,
|
|
|
|
const cmState::Snapshot& snapshot)
|
|
|
|
: DirectoryState(iter)
|
|
|
|
, Snapshot_(snapshot)
|
2015-07-18 20:11:05 +03:00
|
|
|
{
|
|
|
|
}
|
2015-07-18 13:28:49 +03:00
|
|
|
|
|
|
|
template <typename T, typename U>
|
|
|
|
cmStringRange GetPropertyContent(T const& content, U contentEndPosition)
|
|
|
|
{
|
|
|
|
std::vector<std::string>::const_iterator end =
|
2016-05-16 17:34:04 +03:00
|
|
|
content.begin() + contentEndPosition;
|
2015-07-18 13:28:49 +03:00
|
|
|
|
|
|
|
std::vector<std::string>::const_reverse_iterator rbegin =
|
2016-05-16 17:34:04 +03:00
|
|
|
cmMakeReverseIterator(end);
|
2015-07-18 13:28:49 +03:00
|
|
|
rbegin = std::find(rbegin, content.rend(), cmPropertySentinal);
|
|
|
|
|
|
|
|
return cmMakeRange(rbegin.base(), end);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T, typename U, typename V>
|
2016-05-16 17:34:04 +03:00
|
|
|
cmBacktraceRange GetPropertyBacktraces(T const& content, U const& backtraces,
|
|
|
|
V contentEndPosition)
|
2015-07-18 13:28:49 +03:00
|
|
|
{
|
|
|
|
std::vector<std::string>::const_iterator entryEnd =
|
2016-05-16 17:34:04 +03:00
|
|
|
content.begin() + contentEndPosition;
|
2015-07-18 13:28:49 +03:00
|
|
|
|
|
|
|
std::vector<std::string>::const_reverse_iterator rbegin =
|
2016-05-16 17:34:04 +03:00
|
|
|
cmMakeReverseIterator(entryEnd);
|
2015-07-18 13:28:49 +03:00
|
|
|
rbegin = std::find(rbegin, content.rend(), cmPropertySentinal);
|
|
|
|
|
|
|
|
std::vector<cmListFileBacktrace>::const_iterator it =
|
2016-05-16 17:34:04 +03:00
|
|
|
backtraces.begin() + std::distance(content.begin(), rbegin.base());
|
2015-07-18 13:28:49 +03:00
|
|
|
|
|
|
|
std::vector<cmListFileBacktrace>::const_iterator end = backtraces.end();
|
|
|
|
return cmMakeRange(it, end);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T, typename U, typename V>
|
|
|
|
void AppendEntry(T& content, U& backtraces, V& endContentPosition,
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& value, const cmListFileBacktrace& lfbt)
|
2015-07-18 13:28:49 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (value.empty()) {
|
2015-09-11 00:00:27 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-09-11 00:00:27 +03:00
|
|
|
|
2015-07-18 13:28:49 +03:00
|
|
|
assert(endContentPosition == content.size());
|
|
|
|
|
2015-09-10 23:59:40 +03:00
|
|
|
content.push_back(value);
|
2015-07-18 13:28:49 +03:00
|
|
|
backtraces.push_back(lfbt);
|
|
|
|
|
|
|
|
endContentPosition = content.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T, typename U, typename V>
|
|
|
|
void SetContent(T& content, U& backtraces, V& endContentPosition,
|
|
|
|
const std::string& vec, const cmListFileBacktrace& lfbt)
|
|
|
|
{
|
|
|
|
assert(endContentPosition == content.size());
|
|
|
|
|
|
|
|
content.resize(content.size() + 2);
|
|
|
|
backtraces.resize(backtraces.size() + 2);
|
|
|
|
|
|
|
|
content.back() = vec;
|
|
|
|
backtraces.back() = lfbt;
|
|
|
|
|
|
|
|
endContentPosition = content.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T, typename U, typename V>
|
|
|
|
void ClearContent(T& content, U& backtraces, V& endContentPosition)
|
|
|
|
{
|
|
|
|
assert(endContentPosition == content.size());
|
|
|
|
|
|
|
|
content.resize(content.size() + 1);
|
|
|
|
backtraces.resize(backtraces.size() + 1);
|
|
|
|
|
|
|
|
endContentPosition = content.size();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmStringRange cmState::Directory::GetIncludeDirectoriesEntries() const
|
2015-07-18 13:28:49 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return GetPropertyContent(
|
|
|
|
this->DirectoryState->IncludeDirectories,
|
|
|
|
this->Snapshot_.Position->IncludeDirectoryPosition);
|
2015-07-18 13:28:49 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmBacktraceRange cmState::Directory::GetIncludeDirectoriesEntryBacktraces()
|
|
|
|
const
|
2015-07-18 13:28:49 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return GetPropertyBacktraces(
|
|
|
|
this->DirectoryState->IncludeDirectories,
|
|
|
|
this->DirectoryState->IncludeDirectoryBacktraces,
|
|
|
|
this->Snapshot_.Position->IncludeDirectoryPosition);
|
2015-07-18 13:28:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::Directory::AppendIncludeDirectoriesEntry(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& vec, const cmListFileBacktrace& lfbt)
|
2015-07-18 13:28:49 +03:00
|
|
|
{
|
|
|
|
AppendEntry(this->DirectoryState->IncludeDirectories,
|
|
|
|
this->DirectoryState->IncludeDirectoryBacktraces,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Snapshot_.Position->IncludeDirectoryPosition, vec, lfbt);
|
2015-07-18 13:28:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::Directory::PrependIncludeDirectoriesEntry(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& vec, const cmListFileBacktrace& lfbt)
|
2015-07-18 13:28:49 +03:00
|
|
|
{
|
|
|
|
std::vector<std::string>::iterator entryEnd =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->DirectoryState->IncludeDirectories.begin() +
|
|
|
|
this->Snapshot_.Position->IncludeDirectoryPosition;
|
2015-07-18 13:28:49 +03:00
|
|
|
|
2015-08-21 20:42:04 +03:00
|
|
|
std::vector<std::string>::reverse_iterator rend =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->DirectoryState->IncludeDirectories.rend();
|
2015-07-18 13:28:49 +03:00
|
|
|
std::vector<std::string>::reverse_iterator rbegin =
|
2016-05-16 17:34:04 +03:00
|
|
|
cmMakeReverseIterator(entryEnd);
|
2015-08-21 20:42:04 +03:00
|
|
|
rbegin = std::find(rbegin, rend, cmPropertySentinal);
|
2015-07-18 13:28:49 +03:00
|
|
|
|
2015-08-21 20:42:04 +03:00
|
|
|
std::vector<std::string>::iterator entryIt = rbegin.base();
|
|
|
|
std::vector<std::string>::iterator entryBegin =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->DirectoryState->IncludeDirectories.begin();
|
2015-07-18 13:28:49 +03:00
|
|
|
|
|
|
|
std::vector<cmListFileBacktrace>::iterator btIt =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->DirectoryState->IncludeDirectoryBacktraces.begin() +
|
|
|
|
std::distance(entryBegin, entryIt);
|
2015-07-18 13:28:49 +03:00
|
|
|
|
2015-08-21 20:42:04 +03:00
|
|
|
this->DirectoryState->IncludeDirectories.insert(entryIt, vec);
|
2015-07-18 13:28:49 +03:00
|
|
|
this->DirectoryState->IncludeDirectoryBacktraces.insert(btIt, lfbt);
|
|
|
|
|
|
|
|
this->Snapshot_.Position->IncludeDirectoryPosition =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->DirectoryState->IncludeDirectories.size();
|
2015-07-18 13:28:49 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmState::Directory::SetIncludeDirectories(const std::string& vec,
|
|
|
|
const cmListFileBacktrace& lfbt)
|
2015-07-18 13:28:49 +03:00
|
|
|
{
|
|
|
|
SetContent(this->DirectoryState->IncludeDirectories,
|
|
|
|
this->DirectoryState->IncludeDirectoryBacktraces,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Snapshot_.Position->IncludeDirectoryPosition, vec, lfbt);
|
2015-07-18 13:28:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::Directory::ClearIncludeDirectories()
|
|
|
|
{
|
|
|
|
ClearContent(this->DirectoryState->IncludeDirectories,
|
|
|
|
this->DirectoryState->IncludeDirectoryBacktraces,
|
|
|
|
this->Snapshot_.Position->IncludeDirectoryPosition);
|
|
|
|
}
|
|
|
|
|
|
|
|
cmStringRange cmState::Directory::GetCompileDefinitionsEntries() const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return GetPropertyContent(
|
|
|
|
this->DirectoryState->CompileDefinitions,
|
|
|
|
this->Snapshot_.Position->CompileDefinitionsPosition);
|
2015-07-18 13:28:49 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmBacktraceRange cmState::Directory::GetCompileDefinitionsEntryBacktraces()
|
|
|
|
const
|
2015-07-18 13:28:49 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return GetPropertyBacktraces(
|
|
|
|
this->DirectoryState->CompileDefinitions,
|
|
|
|
this->DirectoryState->CompileDefinitionsBacktraces,
|
|
|
|
this->Snapshot_.Position->CompileDefinitionsPosition);
|
2015-07-18 13:28:49 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmState::Directory::AppendCompileDefinitionsEntry(
|
|
|
|
const std::string& vec, const cmListFileBacktrace& lfbt)
|
2015-07-18 13:28:49 +03:00
|
|
|
{
|
|
|
|
AppendEntry(this->DirectoryState->CompileDefinitions,
|
|
|
|
this->DirectoryState->CompileDefinitionsBacktraces,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Snapshot_.Position->CompileDefinitionsPosition, vec, lfbt);
|
2015-07-18 13:28:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::Directory::SetCompileDefinitions(const std::string& vec,
|
|
|
|
const cmListFileBacktrace& lfbt)
|
|
|
|
{
|
|
|
|
SetContent(this->DirectoryState->CompileDefinitions,
|
|
|
|
this->DirectoryState->CompileDefinitionsBacktraces,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Snapshot_.Position->CompileDefinitionsPosition, vec, lfbt);
|
2015-07-18 13:28:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::Directory::ClearCompileDefinitions()
|
|
|
|
{
|
|
|
|
ClearContent(this->DirectoryState->CompileDefinitions,
|
|
|
|
this->DirectoryState->CompileDefinitionsBacktraces,
|
|
|
|
this->Snapshot_.Position->CompileDefinitionsPosition);
|
|
|
|
}
|
|
|
|
|
|
|
|
cmStringRange cmState::Directory::GetCompileOptionsEntries() const
|
|
|
|
{
|
|
|
|
return GetPropertyContent(this->DirectoryState->CompileOptions,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Snapshot_.Position->CompileOptionsPosition);
|
2015-07-18 13:28:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
cmBacktraceRange cmState::Directory::GetCompileOptionsEntryBacktraces() const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return GetPropertyBacktraces(
|
|
|
|
this->DirectoryState->CompileOptions,
|
|
|
|
this->DirectoryState->CompileOptionsBacktraces,
|
|
|
|
this->Snapshot_.Position->CompileOptionsPosition);
|
2015-07-18 13:28:49 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmState::Directory::AppendCompileOptionsEntry(
|
|
|
|
const std::string& vec, const cmListFileBacktrace& lfbt)
|
2015-07-18 13:28:49 +03:00
|
|
|
{
|
|
|
|
AppendEntry(this->DirectoryState->CompileOptions,
|
|
|
|
this->DirectoryState->CompileOptionsBacktraces,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Snapshot_.Position->CompileOptionsPosition, vec, lfbt);
|
2015-07-18 13:28:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::Directory::SetCompileOptions(const std::string& vec,
|
|
|
|
const cmListFileBacktrace& lfbt)
|
|
|
|
{
|
|
|
|
SetContent(this->DirectoryState->CompileOptions,
|
|
|
|
this->DirectoryState->CompileOptionsBacktraces,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Snapshot_.Position->CompileOptionsPosition, vec, lfbt);
|
2015-07-18 13:28:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::Directory::ClearCompileOptions()
|
|
|
|
{
|
|
|
|
ClearContent(this->DirectoryState->CompileOptions,
|
|
|
|
this->DirectoryState->CompileOptionsBacktraces,
|
|
|
|
this->Snapshot_.Position->CompileOptionsPosition);
|
|
|
|
}
|
2015-08-02 11:07:30 +03:00
|
|
|
|
|
|
|
bool cmState::Snapshot::StrictWeakOrder::operator()(
|
2016-05-16 17:34:04 +03:00
|
|
|
const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) const
|
2015-08-02 11:07:30 +03:00
|
|
|
{
|
|
|
|
return lhs.Position.StrictWeakOrdered(rhs.Position);
|
|
|
|
}
|
2015-07-18 16:18:59 +03:00
|
|
|
|
|
|
|
void cmState::Directory::SetProperty(const std::string& prop,
|
|
|
|
const char* value,
|
|
|
|
cmListFileBacktrace lfbt)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (prop == "INCLUDE_DIRECTORIES") {
|
|
|
|
if (!value) {
|
2015-07-18 16:18:59 +03:00
|
|
|
this->ClearIncludeDirectories();
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-18 16:18:59 +03:00
|
|
|
this->SetIncludeDirectories(value, lfbt);
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (prop == "COMPILE_OPTIONS") {
|
|
|
|
if (!value) {
|
2015-07-18 16:18:59 +03:00
|
|
|
this->ClearCompileOptions();
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-18 16:18:59 +03:00
|
|
|
this->SetCompileOptions(value, lfbt);
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (prop == "COMPILE_DEFINITIONS") {
|
|
|
|
if (!value) {
|
2015-07-18 16:18:59 +03:00
|
|
|
this->ClearCompileDefinitions();
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-18 16:18:59 +03:00
|
|
|
this->SetCompileDefinitions(value, lfbt);
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-18 16:18:59 +03:00
|
|
|
|
|
|
|
this->DirectoryState->Properties.SetProperty(prop, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::Directory::AppendProperty(const std::string& prop,
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* value, bool asString,
|
2015-07-18 16:18:59 +03:00
|
|
|
cmListFileBacktrace lfbt)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (prop == "INCLUDE_DIRECTORIES") {
|
2015-07-18 16:18:59 +03:00
|
|
|
this->AppendIncludeDirectoriesEntry(value, lfbt);
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (prop == "COMPILE_OPTIONS") {
|
2015-07-18 16:18:59 +03:00
|
|
|
this->AppendCompileOptionsEntry(value, lfbt);
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (prop == "COMPILE_DEFINITIONS") {
|
2015-07-18 16:18:59 +03:00
|
|
|
this->AppendCompileDefinitionsEntry(value, lfbt);
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-18 16:18:59 +03:00
|
|
|
|
|
|
|
this->DirectoryState->Properties.AppendProperty(prop, value, asString);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmState::Directory::GetProperty(const std::string& prop) const
|
2015-07-18 16:18:59 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
const bool chain =
|
|
|
|
this->Snapshot_.State->IsPropertyChained(prop, cmProperty::DIRECTORY);
|
2015-07-18 16:18:59 +03:00
|
|
|
return this->GetProperty(prop, chain);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmState::Directory::GetProperty(const std::string& prop,
|
|
|
|
bool chain) const
|
2015-07-18 16:18:59 +03:00
|
|
|
{
|
|
|
|
static std::string output;
|
|
|
|
output = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (prop == "PARENT_DIRECTORY") {
|
|
|
|
cmState::Snapshot parent = this->Snapshot_.GetBuildsystemDirectoryParent();
|
|
|
|
if (parent.IsValid()) {
|
2015-07-18 16:18:59 +03:00
|
|
|
return parent.GetDirectory().GetCurrentSource();
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return "";
|
|
|
|
} else if (prop == "LISTFILE_STACK") {
|
2015-07-18 16:18:59 +03:00
|
|
|
std::vector<std::string> listFiles;
|
|
|
|
cmState::Snapshot snp = this->Snapshot_;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (snp.IsValid()) {
|
2015-07-18 16:18:59 +03:00
|
|
|
listFiles.push_back(snp.GetExecutionListFile());
|
|
|
|
snp = snp.GetCallStackParent();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-18 16:18:59 +03:00
|
|
|
std::reverse(listFiles.begin(), listFiles.end());
|
|
|
|
output = cmJoin(listFiles, ";");
|
|
|
|
return output.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (prop == "CACHE_VARIABLES") {
|
2015-07-18 16:18:59 +03:00
|
|
|
output = cmJoin(this->Snapshot_.State->GetCacheEntryKeys(), ";");
|
|
|
|
return output.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (prop == "VARIABLES") {
|
2015-07-18 16:18:59 +03:00
|
|
|
std::vector<std::string> res = this->Snapshot_.ClosureKeys();
|
|
|
|
std::vector<std::string> cacheKeys =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Snapshot_.State->GetCacheEntryKeys();
|
2015-07-18 16:18:59 +03:00
|
|
|
res.insert(res.end(), cacheKeys.begin(), cacheKeys.end());
|
|
|
|
std::sort(res.begin(), res.end());
|
|
|
|
output = cmJoin(res, ";");
|
|
|
|
return output.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (prop == "INCLUDE_DIRECTORIES") {
|
2015-07-18 16:18:59 +03:00
|
|
|
output = cmJoin(this->GetIncludeDirectoriesEntries(), ";");
|
|
|
|
return output.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (prop == "COMPILE_OPTIONS") {
|
2015-07-18 16:18:59 +03:00
|
|
|
output = cmJoin(this->GetCompileOptionsEntries(), ";");
|
|
|
|
return output.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (prop == "COMPILE_DEFINITIONS") {
|
2015-07-18 16:18:59 +03:00
|
|
|
output = cmJoin(this->GetCompileDefinitionsEntries(), ";");
|
|
|
|
return output.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-18 16:18:59 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* retVal = this->DirectoryState->Properties.GetPropertyValue(prop);
|
|
|
|
if (!retVal && chain) {
|
2015-07-18 16:18:59 +03:00
|
|
|
Snapshot parentSnapshot = this->Snapshot_.GetBuildsystemDirectoryParent();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (parentSnapshot.IsValid()) {
|
2015-07-18 16:18:59 +03:00
|
|
|
return parentSnapshot.GetDirectory().GetProperty(prop, chain);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return this->Snapshot_.State->GetGlobalProperty(prop);
|
|
|
|
}
|
2015-07-18 16:18:59 +03:00
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::Directory::GetPropertyAsBool(const std::string& prop) const
|
|
|
|
{
|
|
|
|
return cmSystemTools::IsOn(this->GetProperty(prop));
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> cmState::Directory::GetPropertyKeys() const
|
|
|
|
{
|
|
|
|
std::vector<std::string> keys;
|
|
|
|
keys.reserve(this->DirectoryState->Properties.size());
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cmPropertyMap::const_iterator it =
|
|
|
|
this->DirectoryState->Properties.begin();
|
|
|
|
it != this->DirectoryState->Properties.end(); ++it) {
|
2015-07-18 16:18:59 +03:00
|
|
|
keys.push_back(it->first);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-18 16:18:59 +03:00
|
|
|
return keys;
|
|
|
|
}
|
2015-08-02 10:56:08 +03:00
|
|
|
|
|
|
|
bool operator==(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs)
|
|
|
|
{
|
|
|
|
return lhs.Position == rhs.Position;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs)
|
|
|
|
{
|
|
|
|
return lhs.Position != rhs.Position;
|
|
|
|
}
|
2015-10-10 16:08:15 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static bool ParseEntryWithoutType(const std::string& entry, std::string& var,
|
2015-10-10 16:08:15 +03:00
|
|
|
std::string& value)
|
|
|
|
{
|
|
|
|
// input line is: key=value
|
|
|
|
static cmsys::RegularExpression reg(
|
|
|
|
"^([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
|
|
|
|
// input line is: "key"=value
|
|
|
|
static cmsys::RegularExpression regQuoted(
|
|
|
|
"^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
|
|
|
|
bool flag = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (regQuoted.find(entry)) {
|
2015-10-10 16:08:15 +03:00
|
|
|
var = regQuoted.match(1);
|
|
|
|
value = regQuoted.match(2);
|
|
|
|
flag = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (reg.find(entry)) {
|
2015-10-10 16:08:15 +03:00
|
|
|
var = reg.match(1);
|
|
|
|
value = reg.match(2);
|
|
|
|
flag = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-10 16:08:15 +03:00
|
|
|
|
|
|
|
// if value is enclosed in single quotes ('foo') then remove them
|
|
|
|
// it is used to enclose trailing space or tab
|
2016-05-16 17:34:04 +03:00
|
|
|
if (flag && value.size() >= 2 && value[0] == '\'' &&
|
|
|
|
value[value.size() - 1] == '\'') {
|
|
|
|
value = value.substr(1, value.size() - 2);
|
|
|
|
}
|
2015-10-10 16:08:15 +03:00
|
|
|
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmState::ParseCacheEntry(const std::string& entry, std::string& var,
|
|
|
|
std::string& value, CacheEntryType& type)
|
2015-10-10 16:08:15 +03:00
|
|
|
{
|
|
|
|
// input line is: key:type=value
|
|
|
|
static cmsys::RegularExpression reg(
|
|
|
|
"^([^=:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
|
|
|
|
// input line is: "key":type=value
|
|
|
|
static cmsys::RegularExpression regQuoted(
|
|
|
|
"^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
|
|
|
|
bool flag = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (regQuoted.find(entry)) {
|
2015-10-10 16:08:15 +03:00
|
|
|
var = regQuoted.match(1);
|
|
|
|
type = cmState::StringToCacheEntryType(regQuoted.match(2).c_str());
|
|
|
|
value = regQuoted.match(3);
|
|
|
|
flag = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (reg.find(entry)) {
|
2015-10-10 16:08:15 +03:00
|
|
|
var = reg.match(1);
|
|
|
|
type = cmState::StringToCacheEntryType(reg.match(2).c_str());
|
|
|
|
value = reg.match(3);
|
|
|
|
flag = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-10 16:08:15 +03:00
|
|
|
|
|
|
|
// if value is enclosed in single quotes ('foo') then remove them
|
|
|
|
// it is used to enclose trailing space or tab
|
2016-05-16 17:34:04 +03:00
|
|
|
if (flag && value.size() >= 2 && value[0] == '\'' &&
|
|
|
|
value[value.size() - 1] == '\'') {
|
|
|
|
value = value.substr(1, value.size() - 2);
|
|
|
|
}
|
2015-10-10 16:08:15 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!flag) {
|
2015-10-10 16:08:15 +03:00
|
|
|
return ParseEntryWithoutType(entry, var, value);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-10 16:08:15 +03:00
|
|
|
|
|
|
|
return flag;
|
|
|
|
}
|