summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGenerator.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2016-10-06 16:01:36 (GMT)
committerStephen Kelly <steveire@gmail.com>2016-10-06 16:41:06 (GMT)
commitf59e87792943904dcb11e16380883e87395d115f (patch)
treeb8dd2aae7520a03e9b6486fa863252bd43a8eee8 /Source/cmGlobalGenerator.cxx
parentb99bbfe88d1bb02dc903507f3e1bbe716ac04c12 (diff)
downloadCMake-f59e87792943904dcb11e16380883e87395d115f.zip
CMake-f59e87792943904dcb11e16380883e87395d115f.tar.gz
CMake-f59e87792943904dcb11e16380883e87395d115f.tar.bz2
cmGlobalGenerator: Add API to get settings from top-level cmMakefile
At generate-time, definitions are sometimes read from a nearby cmMakefile, making the value directory-specific because they are read once per directory. Often however, the intention is more often to create a 'global' setting, such that the user writes for example: set(CMAKE_IMPORT_LIBRARY_SUFFIX something) once at the top level of their project. Many of these are also set by internal platform files, such as CMAKE_EXTRA_LINK_EXTENSIONS. The set() definitions are not really suitable for 'global' settings because they can be different for each directory, and code consuming the settings must assume they are different for each directory, and read it freshly each time with new allocations. CMake has other variable types which are global in scope, such as global properties, and cache variables. These are less convenient to populate for users, so establish a convention and API using the value as it is at the end of the top-level CMakeLists file.
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r--Source/cmGlobalGenerator.cxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index a446862..7132ade 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1007,6 +1007,25 @@ void cmGlobalGenerator::FillExtensionToLanguageMap(const std::string& l,
}
}
+const char* cmGlobalGenerator::GetGlobalSetting(std::string const& name) const
+{
+ assert(!this->Makefiles.empty());
+ return this->Makefiles[0]->GetDefinition(name);
+}
+
+bool cmGlobalGenerator::GlobalSettingIsOn(std::string const& name) const
+{
+ assert(!this->Makefiles.empty());
+ return this->Makefiles[0]->IsOn(name);
+}
+
+const char* cmGlobalGenerator::GetSafeGlobalSetting(
+ std::string const& name) const
+{
+ assert(!this->Makefiles.empty());
+ return this->Makefiles[0]->GetSafeDefinition(name);
+}
+
bool cmGlobalGenerator::IgnoreFile(const char* ext) const
{
if (!this->GetLanguageFromExtension(ext).empty()) {