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"
|
|
|
|
|
|
|
|
#include "cmake.h"
|
2015-04-07 23:45:54 +03:00
|
|
|
#include "cmCacheManager.h"
|
2015-04-11 13:30:26 +03:00
|
|
|
#include "cmCommand.h"
|
|
|
|
#include "cmAlgorithms.h"
|
|
|
|
|
|
|
|
#include <assert.h>
|
2015-04-04 22:20:12 +03:00
|
|
|
|
2015-05-23 10:54:07 +03:00
|
|
|
struct cmState::SnapshotDataType
|
|
|
|
{
|
|
|
|
cmState::PositionType DirectoryParent;
|
|
|
|
cmState::SnapshotType SnapshotType;
|
|
|
|
};
|
|
|
|
|
2015-04-04 22:20:12 +03:00
|
|
|
cmState::cmState(cmake* cm)
|
2015-04-11 13:16:54 +03:00
|
|
|
: CMakeInstance(cm),
|
2015-05-24 12:46:30 +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-04-07 23:45:54 +03:00
|
|
|
|
2015-04-11 13:30:26 +03:00
|
|
|
cmState::~cmState()
|
|
|
|
{
|
|
|
|
cmDeleteAll(this->Commands);
|
|
|
|
}
|
|
|
|
|
2015-04-07 23:45:54 +03:00
|
|
|
const char* cmCacheEntryTypes[] =
|
|
|
|
{ "BOOL",
|
|
|
|
"PATH",
|
|
|
|
"FILEPATH",
|
|
|
|
"STRING",
|
|
|
|
"INTERNAL",
|
|
|
|
"STATIC",
|
|
|
|
"UNINITIALIZED",
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
const char*
|
|
|
|
cmState::CacheEntryTypeToString(cmState::CacheEntryType type)
|
2015-04-04 22:20:12 +03:00
|
|
|
{
|
2015-04-07 23:45:54 +03:00
|
|
|
if ( type > 6 )
|
|
|
|
{
|
|
|
|
return cmCacheEntryTypes[6];
|
|
|
|
}
|
|
|
|
return cmCacheEntryTypes[type];
|
2015-04-04 22:20:12 +03:00
|
|
|
}
|
|
|
|
|
2015-04-07 23:45:54 +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;
|
|
|
|
while(cmCacheEntryTypes[i])
|
|
|
|
{
|
|
|
|
if(strcmp(s, cmCacheEntryTypes[i]) == 0)
|
|
|
|
{
|
|
|
|
return static_cast<cmState::CacheEntryType>(i);
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
return STRING;
|
2015-04-04 22:20:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::IsCacheEntryType(std::string const& key)
|
|
|
|
{
|
2015-04-07 23:45:54 +03:00
|
|
|
for(int i=0; cmCacheEntryTypes[i]; ++i)
|
|
|
|
{
|
|
|
|
if(strcmp(key.c_str(), cmCacheEntryTypes[i]) == 0)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2015-04-04 22:20:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> cmState::GetCacheEntryKeys() const
|
|
|
|
{
|
|
|
|
std::vector<std::string> definitions;
|
|
|
|
definitions.reserve(this->CMakeInstance->GetCacheManager()->GetSize());
|
|
|
|
cmCacheManager::CacheIterator cit =
|
|
|
|
this->CMakeInstance->GetCacheManager()->GetCacheIterator();
|
|
|
|
for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() )
|
|
|
|
{
|
|
|
|
definitions.push_back(cit.GetName());
|
|
|
|
}
|
|
|
|
return definitions;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* cmState::GetCacheEntryValue(std::string const& key) const
|
|
|
|
{
|
|
|
|
cmCacheManager::CacheEntry* e = this->CMakeInstance->GetCacheManager()
|
|
|
|
->GetCacheEntry(key);
|
|
|
|
if (!e)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return e->Value.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char*
|
|
|
|
cmState::GetInitializedCacheValue(std::string const& key) const
|
|
|
|
{
|
|
|
|
return this->CMakeInstance->GetCacheManager()->GetInitializedCacheValue(key);
|
|
|
|
}
|
|
|
|
|
2015-04-07 23:45:54 +03:00
|
|
|
cmState::CacheEntryType
|
2015-04-04 22:20:12 +03:00
|
|
|
cmState::GetCacheEntryType(std::string const& key) const
|
|
|
|
{
|
|
|
|
cmCacheManager::CacheIterator it =
|
|
|
|
this->CMakeInstance->GetCacheManager()->GetCacheIterator(key.c_str());
|
|
|
|
return it.GetType();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::SetCacheEntryValue(std::string const& key,
|
|
|
|
std::string const& value)
|
|
|
|
{
|
|
|
|
this->CMakeInstance->GetCacheManager()->SetCacheEntryValue(key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::SetCacheEntryProperty(std::string const& key,
|
|
|
|
std::string const& propertyName,
|
|
|
|
std::string const& value)
|
|
|
|
{
|
|
|
|
cmCacheManager::CacheIterator it =
|
|
|
|
this->CMakeInstance->GetCacheManager()->GetCacheIterator(key.c_str());
|
|
|
|
it.SetProperty(propertyName, value.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::SetCacheEntryBoolProperty(std::string const& key,
|
|
|
|
std::string const& propertyName,
|
|
|
|
bool value)
|
|
|
|
{
|
|
|
|
cmCacheManager::CacheIterator it =
|
|
|
|
this->CMakeInstance->GetCacheManager()->GetCacheIterator(key.c_str());
|
|
|
|
it.SetProperty(propertyName, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* cmState::GetCacheEntryProperty(std::string const& key,
|
|
|
|
std::string const& propertyName)
|
|
|
|
{
|
|
|
|
cmCacheManager::CacheIterator it = this->CMakeInstance->GetCacheManager()
|
|
|
|
->GetCacheIterator(key.c_str());
|
|
|
|
if (!it.PropertyExists(propertyName))
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return it.GetProperty(propertyName);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::GetCacheEntryPropertyAsBool(std::string const& key,
|
|
|
|
std::string const& propertyName)
|
|
|
|
{
|
|
|
|
return this->CMakeInstance->GetCacheManager()
|
|
|
|
->GetCacheIterator(key.c_str()).GetPropertyAsBool(propertyName);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::AddCacheEntry(const std::string& key, const char* value,
|
|
|
|
const char* helpString,
|
2015-04-07 23:45:54 +03:00
|
|
|
cmState::CacheEntryType type)
|
2015-04-04 22:20:12 +03:00
|
|
|
{
|
|
|
|
this->CMakeInstance->GetCacheManager()->AddCacheEntry(key, value,
|
|
|
|
helpString, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::RemoveCacheEntry(std::string const& key)
|
|
|
|
{
|
|
|
|
this->CMakeInstance->GetCacheManager()->RemoveCacheEntry(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::AppendCacheEntryProperty(const std::string& key,
|
|
|
|
const std::string& property,
|
|
|
|
const std::string& value,
|
|
|
|
bool asString)
|
|
|
|
{
|
|
|
|
this->CMakeInstance->GetCacheManager()
|
|
|
|
->GetCacheIterator(key.c_str()).AppendProperty(property,
|
|
|
|
value.c_str(),
|
|
|
|
asString);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::RemoveCacheEntryProperty(std::string const& key,
|
|
|
|
std::string const& propertyName)
|
|
|
|
{
|
|
|
|
this->CMakeInstance->GetCacheManager()
|
|
|
|
->GetCacheIterator(key.c_str()).SetProperty(propertyName, (void*)0);
|
|
|
|
}
|
2015-04-05 00:33:26 +03:00
|
|
|
|
2015-05-24 14:00:20 +03:00
|
|
|
void 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
|
|
|
|
|
|
|
assert(this->Locations.size() > 0);
|
|
|
|
assert(this->OutputLocations.size() > 0);
|
2015-05-23 10:54:07 +03:00
|
|
|
assert(this->SnapshotData.size() > 0);
|
2015-05-24 14:00:20 +03:00
|
|
|
assert(this->CurrentSourceDirectoryComponents.size() > 0);
|
|
|
|
assert(this->CurrentBinaryDirectoryComponents.size() > 0);
|
|
|
|
assert(this->RelativePathTopSource.size() > 0);
|
|
|
|
assert(this->RelativePathTopBinary.size() > 0);
|
|
|
|
|
|
|
|
this->Locations.erase(this->Locations.begin() + 1, this->Locations.end());
|
|
|
|
this->OutputLocations.erase(this->OutputLocations.begin() + 1,
|
|
|
|
this->OutputLocations.end());
|
2015-05-23 10:54:07 +03:00
|
|
|
this->SnapshotData.erase(this->SnapshotData.begin() + 1,
|
|
|
|
this->SnapshotData.end());
|
2015-05-24 14:00:20 +03:00
|
|
|
this->CurrentSourceDirectoryComponents.erase(
|
|
|
|
this->CurrentSourceDirectoryComponents.begin() + 1,
|
|
|
|
this->CurrentSourceDirectoryComponents.end());
|
|
|
|
this->CurrentBinaryDirectoryComponents.erase(
|
|
|
|
this->CurrentBinaryDirectoryComponents.begin() + 1,
|
|
|
|
this->CurrentBinaryDirectoryComponents.end());
|
|
|
|
this->RelativePathTopSource.erase(this->RelativePathTopSource.begin() + 1,
|
|
|
|
this->RelativePathTopSource.end());
|
|
|
|
this->RelativePathTopBinary.erase(this->RelativePathTopBinary.begin() + 1,
|
|
|
|
this->RelativePathTopBinary.end());
|
|
|
|
|
2015-04-05 00:33:26 +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);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::DefineProperty(const std::string& name,
|
|
|
|
cmProperty::ScopeType scope,
|
|
|
|
const char *ShortDescription,
|
|
|
|
const char *FullDescription,
|
|
|
|
bool chained)
|
|
|
|
{
|
|
|
|
this->PropertyDefinitions[scope].DefineProperty(name,scope,ShortDescription,
|
|
|
|
FullDescription,
|
|
|
|
chained);
|
|
|
|
}
|
|
|
|
|
|
|
|
cmPropertyDefinition *cmState
|
|
|
|
::GetPropertyDefinition(const std::string& name,
|
|
|
|
cmProperty::ScopeType scope)
|
|
|
|
{
|
|
|
|
if (this->IsPropertyDefined(name,scope))
|
|
|
|
{
|
|
|
|
return &(this->PropertyDefinitions[scope][name]);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::IsPropertyDefined(const std::string& name,
|
|
|
|
cmProperty::ScopeType scope)
|
|
|
|
{
|
|
|
|
return this->PropertyDefinitions[scope].IsPropertyDefined(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmState::IsPropertyChained(const std::string& name,
|
|
|
|
cmProperty::ScopeType scope)
|
|
|
|
{
|
|
|
|
return this->PropertyDefinitions[scope].IsPropertyChained(name);
|
|
|
|
}
|
2015-04-11 15:16:39 +03:00
|
|
|
|
|
|
|
void cmState::SetLanguageEnabled(std::string const& l)
|
|
|
|
{
|
|
|
|
std::vector<std::string>::iterator it =
|
|
|
|
std::lower_bound(this->EnabledLanguages.begin(),
|
|
|
|
this->EnabledLanguages.end(), l);
|
|
|
|
if (it == this->EnabledLanguages.end() || *it != l)
|
|
|
|
{
|
|
|
|
this->EnabledLanguages.insert(it, l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 =
|
|
|
|
this->Commands.find(sOldName);
|
|
|
|
if ( pos == this->Commands.end() )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cmCommand* cmd = pos->second;
|
|
|
|
|
|
|
|
pos = this->Commands.find(sNewName);
|
|
|
|
if (pos != this->Commands.end())
|
|
|
|
{
|
|
|
|
delete pos->second;
|
|
|
|
this->Commands.erase(pos);
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
if (pos != this->Commands.end())
|
|
|
|
{
|
|
|
|
delete pos->second;
|
|
|
|
this->Commands.erase(pos);
|
|
|
|
}
|
|
|
|
this->Commands.insert(std::make_pair(name, command));
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::RemoveUnscriptableCommands()
|
|
|
|
{
|
|
|
|
std::vector<std::string> unscriptableCommands;
|
|
|
|
for (std::map<std::string, cmCommand*>::iterator
|
|
|
|
pos = this->Commands.begin();
|
|
|
|
pos != this->Commands.end(); )
|
|
|
|
{
|
|
|
|
if (!pos->second->IsScriptable())
|
|
|
|
{
|
|
|
|
delete pos->second;
|
|
|
|
this->Commands.erase(pos++);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++pos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 =
|
|
|
|
this->Commands.find(sName);
|
|
|
|
if (pos != this->Commands.end())
|
|
|
|
{
|
|
|
|
command = (*pos).second;
|
|
|
|
}
|
|
|
|
return command;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> cmState::GetCommandNames() const
|
|
|
|
{
|
|
|
|
std::vector<std::string> commandNames;
|
|
|
|
commandNames.reserve(this->Commands.size());
|
|
|
|
std::map<std::string, cmCommand*>::const_iterator cmds
|
|
|
|
= this->Commands.begin();
|
|
|
|
for ( ; cmds != this->Commands.end(); ++ cmds )
|
|
|
|
{
|
|
|
|
commandNames.push_back(cmds->first);
|
|
|
|
}
|
|
|
|
return commandNames;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::RemoveUserDefinedCommands()
|
|
|
|
{
|
|
|
|
for(std::map<std::string, cmCommand*>::iterator j = this->Commands.begin();
|
|
|
|
j != this->Commands.end(); )
|
|
|
|
{
|
|
|
|
if (j->second->IsA("cmMacroHelperCommand") ||
|
|
|
|
j->second->IsA("cmFunctionHelperCommand"))
|
|
|
|
{
|
|
|
|
delete j->second;
|
|
|
|
this->Commands.erase(j++);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-04-11 15:17:46 +03:00
|
|
|
|
|
|
|
void cmState::SetGlobalProperty(const std::string& prop, const char* value)
|
|
|
|
{
|
|
|
|
this->GlobalProperties.SetProperty(prop, value, cmProperty::GLOBAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::AppendGlobalProperty(const std::string& prop,
|
|
|
|
const char* value, bool asString)
|
|
|
|
{
|
|
|
|
this->GlobalProperties.AppendProperty(prop, value,
|
|
|
|
cmProperty::GLOBAL, asString);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *cmState::GetGlobalProperty(const std::string& prop)
|
|
|
|
{
|
|
|
|
// watch for special properties
|
|
|
|
std::string output = "";
|
|
|
|
if ( prop == "CACHE_VARIABLES" )
|
|
|
|
{
|
|
|
|
std::vector<std::string> cacheKeys = this->GetCacheEntryKeys();
|
|
|
|
this->SetGlobalProperty("CACHE_VARIABLES", cmJoin(cacheKeys, ";").c_str());
|
|
|
|
}
|
|
|
|
else if ( prop == "COMMANDS" )
|
|
|
|
{
|
|
|
|
std::vector<std::string> commands = this->GetCommandNames();
|
|
|
|
this->SetGlobalProperty("COMMANDS", cmJoin(commands, ";").c_str());
|
|
|
|
}
|
|
|
|
else if ( prop == "IN_TRY_COMPILE" )
|
|
|
|
{
|
|
|
|
this->SetGlobalProperty("IN_TRY_COMPILE",
|
|
|
|
this->IsInTryCompile ? "1" : "0");
|
|
|
|
}
|
|
|
|
else if ( prop == "ENABLED_LANGUAGES" )
|
|
|
|
{
|
|
|
|
std::string langs;
|
|
|
|
langs = cmJoin(this->EnabledLanguages, ";");
|
|
|
|
this->SetGlobalProperty("ENABLED_LANGUAGES", langs.c_str());
|
|
|
|
}
|
|
|
|
#define STRING_LIST_ELEMENT(F) ";" #F
|
|
|
|
if (prop == "CMAKE_C_KNOWN_FEATURES")
|
|
|
|
{
|
|
|
|
return FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT) + 1;
|
|
|
|
}
|
|
|
|
if (prop == "CMAKE_CXX_KNOWN_FEATURES")
|
|
|
|
{
|
|
|
|
return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1;
|
|
|
|
}
|
|
|
|
#undef STRING_LIST_ELEMENT
|
|
|
|
bool dummy = false;
|
|
|
|
return this->GlobalProperties.GetPropertyValue(prop, cmProperty::GLOBAL,
|
|
|
|
dummy);
|
|
|
|
}
|
|
|
|
|
|
|
|
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(
|
|
|
|
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(
|
|
|
|
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-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-05-05 00:30:29 +03:00
|
|
|
void cmState::Snapshot::ComputeRelativePathTopSource()
|
|
|
|
{
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
cmState::Snapshot snapshot = *this;
|
|
|
|
std::vector<cmState::Snapshot> snapshots;
|
|
|
|
snapshots.push_back(snapshot);
|
|
|
|
while (true)
|
|
|
|
{
|
2015-05-23 09:02:54 +03:00
|
|
|
snapshot = snapshot.GetBuildsystemDirectoryParent();
|
2015-05-05 00:30:29 +03:00
|
|
|
if (snapshot.IsValid())
|
|
|
|
{
|
|
|
|
snapshots.push_back(snapshot);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string result = snapshots.front().GetCurrentSourceDirectory();
|
|
|
|
|
|
|
|
for (std::vector<cmState::Snapshot>::const_iterator it =
|
|
|
|
snapshots.begin() + 1; it != snapshots.end(); ++it)
|
|
|
|
{
|
|
|
|
std::string currentSource = it->GetCurrentSourceDirectory();
|
|
|
|
if(cmSystemTools::IsSubDirectory(result, currentSource))
|
|
|
|
{
|
|
|
|
result = currentSource;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this->State->RelativePathTopSource[this->Position] = result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::Snapshot::ComputeRelativePathTopBinary()
|
|
|
|
{
|
|
|
|
cmState::Snapshot snapshot = *this;
|
|
|
|
std::vector<cmState::Snapshot> snapshots;
|
|
|
|
snapshots.push_back(snapshot);
|
|
|
|
while (true)
|
|
|
|
{
|
2015-05-23 09:02:54 +03:00
|
|
|
snapshot = snapshot.GetBuildsystemDirectoryParent();
|
2015-05-05 00:30:29 +03:00
|
|
|
if (snapshot.IsValid())
|
|
|
|
{
|
|
|
|
snapshots.push_back(snapshot);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string result =
|
|
|
|
snapshots.front().GetCurrentBinaryDirectory();
|
|
|
|
|
|
|
|
for (std::vector<cmState::Snapshot>::const_iterator it =
|
|
|
|
snapshots.begin() + 1; it != snapshots.end(); ++it)
|
|
|
|
{
|
|
|
|
std::string currentBinary = it->GetCurrentBinaryDirectory();
|
|
|
|
if(cmSystemTools::IsSubDirectory(result, currentBinary))
|
|
|
|
{
|
|
|
|
result = currentBinary;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The current working directory on Windows cannot be a network
|
|
|
|
// path. Therefore relative paths cannot work when the binary tree
|
|
|
|
// is a network path.
|
|
|
|
if(result.size() < 2 || result.substr(0, 2) != "//")
|
|
|
|
{
|
|
|
|
this->State->RelativePathTopBinary[this->Position] = result;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->State->RelativePathTopBinary[this->Position] = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-31 01:18:33 +03:00
|
|
|
cmState::Snapshot cmState::CreateBaseSnapshot()
|
|
|
|
{
|
|
|
|
PositionType pos = 0;
|
2015-05-23 10:54:07 +03:00
|
|
|
this->SnapshotData.resize(1);
|
|
|
|
SnapshotDataType& snp = this->SnapshotData.back();
|
|
|
|
snp.DirectoryParent = 0;
|
|
|
|
snp.SnapshotType = BuildsystemDirectoryType;
|
2015-05-31 01:18:33 +03:00
|
|
|
this->Locations.resize(1);
|
|
|
|
this->OutputLocations.resize(1);
|
|
|
|
this->CurrentSourceDirectoryComponents.resize(1);
|
|
|
|
this->CurrentBinaryDirectoryComponents.resize(1);
|
|
|
|
this->RelativePathTopSource.resize(1);
|
|
|
|
this->RelativePathTopBinary.resize(1);
|
|
|
|
return cmState::Snapshot(this, pos);
|
|
|
|
}
|
|
|
|
|
2015-05-23 09:00:46 +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-05-23 10:54:07 +03:00
|
|
|
PositionType pos = this->SnapshotData.size();
|
|
|
|
this->SnapshotData.resize(this->SnapshotData.size() + 1);
|
|
|
|
SnapshotDataType& snp = this->SnapshotData.back();
|
|
|
|
snp.DirectoryParent = originSnapshot.Position;
|
|
|
|
snp.SnapshotType = BuildsystemDirectoryType;
|
2015-04-28 08:50:31 +03:00
|
|
|
this->Locations.resize(this->Locations.size() + 1);
|
|
|
|
this->OutputLocations.resize(this->OutputLocations.size() + 1);
|
2015-05-05 00:08:19 +03:00
|
|
|
this->CurrentSourceDirectoryComponents.resize(
|
|
|
|
this->CurrentSourceDirectoryComponents.size() + 1);
|
|
|
|
this->CurrentBinaryDirectoryComponents.resize(
|
|
|
|
this->CurrentBinaryDirectoryComponents.size() + 1);
|
2015-05-05 00:30:29 +03:00
|
|
|
this->RelativePathTopSource.resize(this->RelativePathTopSource.size() + 1);
|
|
|
|
this->RelativePathTopBinary.resize(this->RelativePathTopBinary.size() + 1);
|
2015-04-11 19:38:16 +03:00
|
|
|
return cmState::Snapshot(this, pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
cmState::Snapshot::Snapshot(cmState* state, PositionType position)
|
|
|
|
: State(state),
|
|
|
|
Position(position)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2015-04-28 08:50:31 +03:00
|
|
|
|
|
|
|
const char* cmState::Snapshot::GetCurrentSourceDirectory() const
|
|
|
|
{
|
|
|
|
return this->State->Locations[this->Position].c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::Snapshot::SetCurrentSourceDirectory(std::string const& dir)
|
|
|
|
{
|
2015-05-24 14:00:20 +03:00
|
|
|
assert(this->State);
|
2015-04-28 08:50:31 +03:00
|
|
|
assert(this->State->Locations.size() > this->Position);
|
|
|
|
this->State->Locations[this->Position] = dir;
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(
|
|
|
|
this->State->Locations[this->Position]);
|
|
|
|
this->State->Locations[this->Position] =
|
|
|
|
cmSystemTools::CollapseFullPath(this->State->Locations[this->Position]);
|
2015-05-05 00:08:19 +03:00
|
|
|
|
|
|
|
cmSystemTools::SplitPath(
|
|
|
|
this->State->Locations[this->Position],
|
|
|
|
this->State->CurrentSourceDirectoryComponents[this->Position]);
|
2015-05-05 00:30:29 +03:00
|
|
|
this->ComputeRelativePathTopSource();
|
2015-04-28 08:50:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* cmState::Snapshot::GetCurrentBinaryDirectory() const
|
|
|
|
{
|
|
|
|
return this->State->OutputLocations[this->Position].c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::Snapshot::SetCurrentBinaryDirectory(std::string const& dir)
|
|
|
|
{
|
|
|
|
assert(this->State->OutputLocations.size() > this->Position);
|
|
|
|
this->State->OutputLocations[this->Position] = dir;
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(
|
|
|
|
this->State->OutputLocations[this->Position]);
|
|
|
|
this->State->OutputLocations[this->Position] =
|
|
|
|
cmSystemTools::CollapseFullPath(
|
|
|
|
this->State->OutputLocations[this->Position]);
|
2015-05-05 00:08:19 +03:00
|
|
|
|
|
|
|
cmSystemTools::SplitPath(
|
|
|
|
this->State->OutputLocations[this->Position],
|
|
|
|
this->State->CurrentBinaryDirectoryComponents[this->Position]);
|
2015-05-05 00:30:29 +03:00
|
|
|
this->ComputeRelativePathTopBinary();
|
2015-05-05 00:08:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> const&
|
|
|
|
cmState::Snapshot::GetCurrentSourceDirectoryComponents()
|
|
|
|
{
|
|
|
|
return this->State->CurrentSourceDirectoryComponents[this->Position];
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> const&
|
|
|
|
cmState::Snapshot::GetCurrentBinaryDirectoryComponents()
|
|
|
|
{
|
|
|
|
return this->State->CurrentBinaryDirectoryComponents[this->Position];
|
2015-04-28 08:50:31 +03:00
|
|
|
}
|
2015-05-04 23:38:37 +03:00
|
|
|
|
2015-05-05 00:30:29 +03:00
|
|
|
const char* cmState::Snapshot::GetRelativePathTopSource() const
|
|
|
|
{
|
|
|
|
return this->State->RelativePathTopSource[this->Position].c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* cmState::Snapshot::GetRelativePathTopBinary() const
|
|
|
|
{
|
|
|
|
return this->State->RelativePathTopBinary[this->Position].c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::Snapshot::SetRelativePathTopSource(const char* dir)
|
|
|
|
{
|
|
|
|
this->State->RelativePathTopSource[this->Position] = dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmState::Snapshot::SetRelativePathTopBinary(const char* dir)
|
|
|
|
{
|
|
|
|
this->State->RelativePathTopBinary[this->Position] = dir;
|
|
|
|
}
|
|
|
|
|
2015-05-04 23:38:37 +03:00
|
|
|
bool cmState::Snapshot::IsValid() const
|
|
|
|
{
|
|
|
|
return this->State ? true : false;
|
|
|
|
}
|
|
|
|
|
2015-05-23 09:02:54 +03:00
|
|
|
cmState::Snapshot cmState::Snapshot::GetBuildsystemDirectoryParent() const
|
2015-05-04 23:38:37 +03:00
|
|
|
{
|
|
|
|
Snapshot snapshot;
|
2015-05-24 14:00:20 +03:00
|
|
|
if (!this->State || this->Position == 0)
|
2015-05-04 23:38:37 +03:00
|
|
|
{
|
|
|
|
return snapshot;
|
|
|
|
}
|
2015-05-23 10:54:07 +03:00
|
|
|
PositionType parentPos =
|
|
|
|
this->State->SnapshotData[this->Position].DirectoryParent;
|
2015-05-24 14:00:20 +03:00
|
|
|
snapshot = Snapshot(this->State, parentPos);
|
2015-05-04 23:38:37 +03:00
|
|
|
|
|
|
|
return snapshot;
|
|
|
|
}
|