summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.h
diff options
context:
space:
mode:
authorJohn Parent <john.parent@kitware.com>2022-03-10 17:43:50 (GMT)
committerJohn Parent <john.parent@kitware.com>2022-03-10 17:44:36 (GMT)
commit2f1ffa003c07d5fe7ca10c4ee06e81dd55f5e415 (patch)
treeeb92cb82fda9a3bcd1ad58cf6b1d2654a2527c35 /Source/cmMakefile.h
parent3a37fda6a2b4f28fdd7efe58f4a0b7570404a7d4 (diff)
downloadCMake-2f1ffa003c07d5fe7ca10c4ee06e81dd55f5e415.zip
CMake-2f1ffa003c07d5fe7ca10c4ee06e81dd55f5e415.tar.gz
CMake-2f1ffa003c07d5fe7ca10c4ee06e81dd55f5e415.tar.bz2
find_package: Add support for default GLOBAL imported targets
Allow find package to promote scope of imported targets by specifying an argument to `find_package` or by specifying a CMake variable. * Add support for CMAKE_GLOBAL_IMPORT_SCOPE variable * Add support for GLOBAL argument to find_package Additionally add testing for above features.
Diffstat (limited to 'Source/cmMakefile.h')
-rw-r--r--Source/cmMakefile.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index ad8a014..99cc89f 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -860,6 +860,44 @@ public:
void PushLoopBlockBarrier();
void PopLoopBlockBarrier();
+ bool IsImportedTargetGlobalScope() const;
+
+ enum class ImportedTargetScope
+ {
+ Local,
+ Global,
+ };
+
+ /** Helper class to manage whether imported packages
+ * should be globally scoped based off the find package command
+ */
+ class SetGlobalTargetImportScope
+ {
+ public:
+ SetGlobalTargetImportScope(cmMakefile* mk, ImportedTargetScope const scope)
+ : Makefile(mk)
+ {
+ if (scope == ImportedTargetScope::Global &&
+ !this->Makefile->IsImportedTargetGlobalScope()) {
+ this->Makefile->CurrentImportedTargetScope = scope;
+ this->Set = true;
+ } else {
+ this->Set = false;
+ }
+ }
+ ~SetGlobalTargetImportScope()
+ {
+ if (this->Set) {
+ this->Makefile->CurrentImportedTargetScope =
+ ImportedTargetScope::Local;
+ }
+ }
+
+ private:
+ cmMakefile* Makefile;
+ bool Set;
+ };
+
/** Helper class to push and pop scopes automatically. */
class ScopePushPop
{
@@ -1124,4 +1162,5 @@ private:
std::set<std::string> WarnedCMP0074;
bool IsSourceFileTryCompile;
mutable bool SuppressSideEffects;
+ ImportedTargetScope CurrentImportedTargetScope;
};