From f61768107e9d12ccb8d953585b4983e0bd345219 Mon Sep 17 00:00:00 2001 From: Vito Gamberini Date: Thu, 10 Jul 2025 12:42:55 -0400 Subject: [PATCH] find_package: Implement UNWIND_INCLUDE This implements a limited exception mechanism for find_package() via the UNWIND_INCLUDE keyword. When package discovery via find_package(UNWIND_INCLUDE) fails the StateSnapshot is updated to an UNWINDING state. In this state further calls to find_package() and include() are forbidden. While in the UNWINDING state, the include() command immediately calls SetReturnInvoked() whenever it is reached. The UNWINDING state is reset when a parent call to find_package() is reached. Fixes: #26897 --- Help/command/find_package.rst | 18 ++++++- .../dev/find-package-UNWIND_INCLUDE.rst | 6 +++ Source/cmFindPackageCommand.cxx | 50 ++++++++++++++++--- Source/cmFindPackageCommand.h | 1 + Source/cmIncludeCommand.cxx | 26 ++++++++++ Source/cmState.cxx | 1 + Source/cmStatePrivate.h | 2 + Source/cmStateSnapshot.cxx | 20 ++++++++ Source/cmStateSnapshot.h | 6 +++ Source/cmStateTypes.h | 12 +++++ .../RunCMake/find_package/RunCMakeTest.cmake | 8 +++ .../find_package/UnwindInclude/NoOp.cmake | 0 .../find_package/UnwindInclude/NoUnwind.cmake | 2 + .../UnwindInclude/PrimaryUnwindConfig.cmake | 2 + .../SecondarySuccessfulConfig.cmake | 1 + .../UnwindInclude/SecondaryUnwindConfig.cmake | 1 + .../UnwindInclude/UnwindBlock.cmake | 14 ++++++ .../UnwindInclude/UnwindFunction.cmake | 20 ++++++++ .../UnwindInvalidFindPackage.cmake | 2 + .../UnwindInclude/UnwindInvalidInclude.cmake | 2 + .../UnwindInclude/UnwindOnly.cmake | 2 + .../UnwindInclude/UnwindSecondary.cmake | 2 + .../UnwindIncludeBlock-stderr.txt | 30 +++++++++++ .../find_package/UnwindIncludeBlock.cmake | 5 ++ .../UnwindIncludeFunction-stderr.txt | 31 ++++++++++++ .../find_package/UnwindIncludeFunction.cmake | 5 ++ .../UnwindIncludeInvalidContext-result.txt | 1 + .../UnwindIncludeInvalidContext-stderr.txt | 4 ++ .../UnwindIncludeInvalidContext.cmake | 5 ++ ...UnwindIncludeInvalidFindPackage-result.txt | 1 + ...UnwindIncludeInvalidFindPackage-stderr.txt | 26 ++++++++++ .../UnwindIncludeInvalidFindPackage.cmake | 5 ++ .../UnwindIncludeInvalidInclude-result.txt | 1 + .../UnwindIncludeInvalidInclude-stderr.txt | 26 ++++++++++ .../UnwindIncludeInvalidInclude.cmake | 5 ++ .../find_package/UnwindIncludeNoUnwind.cmake | 5 ++ .../find_package/UnwindIncludeOnly-stderr.txt | 30 +++++++++++ .../find_package/UnwindIncludeOnly.cmake | 5 ++ .../UnwindIncludeSecondary-stderr.txt | 24 +++++++++ .../find_package/UnwindIncludeSecondary.cmake | 5 ++ 40 files changed, 404 insertions(+), 8 deletions(-) create mode 100644 Help/release/dev/find-package-UNWIND_INCLUDE.rst create mode 100644 Tests/RunCMake/find_package/UnwindInclude/NoOp.cmake create mode 100644 Tests/RunCMake/find_package/UnwindInclude/NoUnwind.cmake create mode 100644 Tests/RunCMake/find_package/UnwindInclude/PrimaryUnwindConfig.cmake create mode 100644 Tests/RunCMake/find_package/UnwindInclude/SecondarySuccessfulConfig.cmake create mode 100644 Tests/RunCMake/find_package/UnwindInclude/SecondaryUnwindConfig.cmake create mode 100644 Tests/RunCMake/find_package/UnwindInclude/UnwindBlock.cmake create mode 100644 Tests/RunCMake/find_package/UnwindInclude/UnwindFunction.cmake create mode 100644 Tests/RunCMake/find_package/UnwindInclude/UnwindInvalidFindPackage.cmake create mode 100644 Tests/RunCMake/find_package/UnwindInclude/UnwindInvalidInclude.cmake create mode 100644 Tests/RunCMake/find_package/UnwindInclude/UnwindOnly.cmake create mode 100644 Tests/RunCMake/find_package/UnwindInclude/UnwindSecondary.cmake create mode 100644 Tests/RunCMake/find_package/UnwindIncludeBlock-stderr.txt create mode 100644 Tests/RunCMake/find_package/UnwindIncludeBlock.cmake create mode 100644 Tests/RunCMake/find_package/UnwindIncludeFunction-stderr.txt create mode 100644 Tests/RunCMake/find_package/UnwindIncludeFunction.cmake create mode 100644 Tests/RunCMake/find_package/UnwindIncludeInvalidContext-result.txt create mode 100644 Tests/RunCMake/find_package/UnwindIncludeInvalidContext-stderr.txt create mode 100644 Tests/RunCMake/find_package/UnwindIncludeInvalidContext.cmake create mode 100644 Tests/RunCMake/find_package/UnwindIncludeInvalidFindPackage-result.txt create mode 100644 Tests/RunCMake/find_package/UnwindIncludeInvalidFindPackage-stderr.txt create mode 100644 Tests/RunCMake/find_package/UnwindIncludeInvalidFindPackage.cmake create mode 100644 Tests/RunCMake/find_package/UnwindIncludeInvalidInclude-result.txt create mode 100644 Tests/RunCMake/find_package/UnwindIncludeInvalidInclude-stderr.txt create mode 100644 Tests/RunCMake/find_package/UnwindIncludeInvalidInclude.cmake create mode 100644 Tests/RunCMake/find_package/UnwindIncludeNoUnwind.cmake create mode 100644 Tests/RunCMake/find_package/UnwindIncludeOnly-stderr.txt create mode 100644 Tests/RunCMake/find_package/UnwindIncludeOnly.cmake create mode 100644 Tests/RunCMake/find_package/UnwindIncludeSecondary-stderr.txt create mode 100644 Tests/RunCMake/find_package/UnwindIncludeSecondary.cmake diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst index 40733458f5..a3ceef2673 100644 --- a/Help/command/find_package.rst +++ b/Help/command/find_package.rst @@ -141,7 +141,8 @@ Basic Signature [REGISTRY_VIEW (64|32|64_32|32_64|HOST|TARGET|BOTH)] [GLOBAL] [NO_POLICY_SCOPE] - [BYPASS_PROVIDER]) + [BYPASS_PROVIDER] + [UNWIND_INCLUDE]) The basic signature is supported by both Module and Config modes. The ``MODULE`` keyword implies that only Module mode can be used to find @@ -249,6 +250,21 @@ of the ``NO_POLICY_SCOPE`` option. itself. Future versions of CMake may detect attempts to use this keyword from places other than a dependency provider and halt with a fatal error. +.. versionadded:: 4.2 + The ``UNWIND_INCLUDE`` keyword is only allowed when ``find_package()`` is + being called within a parent call to ``find_package()``. When a call to + ``find_package(UNWIND_INCLUDE)`` fails to find the desired package, it begins + an "unwind" state. In this state further calls to ``find_package()`` and + :command:`include()` are forbidden, and all parent :command:`include()` + commands will immediately invoke :command:`return()` when their scope is + reached. This "unwinding" will continue until the parent ``find_package()`` + is returned to. + + ``UNWIND_INCLUDE`` is only intended to be used by calls to ``find_package()`` + generated by :command:`install(EXPORT_PACKAGE_DEPENDENCIES)`, but may be + useful to those who wish to manually manage their dependencies in a similar + manner. + .. _`full signature`: Full Signature diff --git a/Help/release/dev/find-package-UNWIND_INCLUDE.rst b/Help/release/dev/find-package-UNWIND_INCLUDE.rst new file mode 100644 index 0000000000..8be5d9709a --- /dev/null +++ b/Help/release/dev/find-package-UNWIND_INCLUDE.rst @@ -0,0 +1,6 @@ +find-package-UNWIND_INCLUDE +--------------------------- + +* The :command:`find_package()` command gained a new ``UNWIND_INCLUDE`` option + to enable immediate :command:`return` from :command:`include()` commands + after a failure to discover a transitive dependency. diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 6201894fd1..24f713a7fa 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -630,6 +630,12 @@ bool cmFindPackageCommand::InitialPass(std::vector const& args) return false; } + if (this->Makefile->GetStateSnapshot().GetUnwindState() == + cmStateEnums::UNWINDING) { + this->SetError("called while already in an UNWIND state"); + return false; + } + // Lookup required version of CMake. if (cmValue const rv = this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION")) { @@ -839,6 +845,14 @@ bool cmFindPackageCommand::InitialPass(std::vector const& args) cmStrCat("given invalid value for REGISTRY_VIEW: ", args[i])); return false; } + } else if (args[i] == "UNWIND_INCLUDE") { + if (this->Makefile->GetStateSnapshot().GetUnwindType() != + cmStateEnums::CAN_UNWIND) { + this->SetError("called with UNWIND_INCLUDE in an invalid context"); + return false; + } + this->ScopeUnwind = true; + doing = DoingNone; } else if (this->CheckCommonArgument(args[i])) { configArgs.push_back(i); doing = DoingNone; @@ -1053,8 +1067,18 @@ bool cmFindPackageCommand::InitialPass(std::vector const& args) this->VersionMaxPatch, this->VersionMaxTweak); } - return this->FindPackage(this->BypassProvider ? std::vector{} - : args); + bool result = this->FindPackage( + this->BypassProvider ? std::vector{} : args); + + std::string const foundVar = cmStrCat(this->Name, "_FOUND"); + bool const isFound = this->Makefile->IsOn(foundVar) || + this->Makefile->IsOn(cmSystemTools::UpperCase(foundVar)); + + if (this->ScopeUnwind && (!result || !isFound)) { + this->Makefile->GetStateSnapshot().SetUnwindState(cmStateEnums::UNWINDING); + } + + return result; } bool cmFindPackageCommand::FindPackage( @@ -2047,12 +2071,24 @@ bool cmFindPackageCommand::ReadListFile(std::string const& f, ITScope scope = this->GlobalScope ? ITScope::Global : ITScope::Local; cmMakefile::SetGlobalTargetImportScope globScope(this->Makefile, scope); - if (this->Makefile->ReadDependentFile(f, noPolicyScope)) { - return true; + auto oldUnwind = this->Makefile->GetStateSnapshot().GetUnwindType(); + + // This allows child snapshots to inherit the CAN_UNWIND state from us, we'll + // reset it immediately after the dependent file is done + this->Makefile->GetStateSnapshot().SetUnwindType(cmStateEnums::CAN_UNWIND); + bool result = this->Makefile->ReadDependentFile(f, noPolicyScope); + + this->Makefile->GetStateSnapshot().SetUnwindType(oldUnwind); + this->Makefile->GetStateSnapshot().SetUnwindState( + cmStateEnums::NOT_UNWINDING); + + if (!result) { + std::string const e = + cmStrCat("Error reading CMake code from \"", f, "\"."); + this->SetError(e); } - std::string const e = cmStrCat("Error reading CMake code from \"", f, "\"."); - this->SetError(e); - return false; + + return result; } bool cmFindPackageCommand::ReadPackage() diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 4d5da755a7..d225fb9c32 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -276,6 +276,7 @@ private: bool PolicyScope = true; bool GlobalScope = false; bool RegistryViewDefined = false; + bool ScopeUnwind = false; std::string LibraryArchitecture; std::vector Names; std::set IgnoredPaths; diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx index 0a39824704..e9d9e1523e 100644 --- a/Source/cmIncludeCommand.cxx +++ b/Source/cmIncludeCommand.cxx @@ -10,6 +10,8 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" +#include "cmStateSnapshot.h" +#include "cmStateTypes.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -38,6 +40,13 @@ bool cmIncludeCommand(std::vector const& args, "include() only takes one file."); return false; } + + if (status.GetMakefile().GetStateSnapshot().GetUnwindState() == + cmStateEnums::UNWINDING) { + status.SetError("called while already in an UNWIND state"); + return false; + } + bool optional = false; bool noPolicyScope = false; std::string fname = args[0]; @@ -166,5 +175,22 @@ bool cmIncludeCommand(std::vector const& args, status.SetError(m); return false; } + + if (status.GetMakefile().GetStateSnapshot().GetUnwindState() == + cmStateEnums::UNWINDING) { + + if (status.GetMakefile().GetStateSnapshot().GetUnwindType() != + cmStateEnums::CAN_UNWIND) { + std::string m = cmStrCat("requested file is attempting to unwind the " + "stack in an invalid context:\n ", + fname); + status.SetError(m); + cmSystemTools::SetFatalErrorOccurred(); + return false; + } + + status.SetReturnInvoked(); + } + return true; } diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 81f53c2a5e..361b539987 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -1030,6 +1030,7 @@ cmStateSnapshot cmState::Pop(cmStateSnapshot const& originSnapshot) prevPos->LinkDirectoriesPosition = prevPos->BuildSystemDirectory->LinkDirectories.size(); prevPos->BuildSystemDirectory->CurrentScope = prevPos; + prevPos->UnwindState = pos->UnwindState; if (!pos->Keep && this->SnapshotData.IsLast(pos)) { if (pos->Vars != prevPos->Vars) { diff --git a/Source/cmStatePrivate.h b/Source/cmStatePrivate.h index afcf1fca95..2a8241424c 100644 --- a/Source/cmStatePrivate.h +++ b/Source/cmStatePrivate.h @@ -34,6 +34,8 @@ struct cmStateDetail::SnapshotDataType cmLinkedTree::iterator PolicyRoot; cmLinkedTree::iterator PolicyScope; cmStateEnums::SnapshotType SnapshotType; + cmStateEnums::SnapshotUnwindType UnwindType = cmStateEnums::NO_UNWIND; + cmStateEnums::SnapshotUnwindState UnwindState = cmStateEnums::NOT_UNWINDING; bool Keep; cmLinkedTree::iterator ExecutionListFile; cmLinkedTree::iterator diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index 3b35c4adb8..43d4f59347 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -50,6 +50,26 @@ cmStateEnums::SnapshotType cmStateSnapshot::GetType() const return this->Position->SnapshotType; } +cmStateEnums::SnapshotUnwindType cmStateSnapshot::GetUnwindType() const +{ + return this->Position->UnwindType; +} + +void cmStateSnapshot::SetUnwindType(cmStateEnums::SnapshotUnwindType type) +{ + this->Position->UnwindType = type; +} + +cmStateEnums::SnapshotUnwindState cmStateSnapshot::GetUnwindState() const +{ + return this->Position->UnwindState; +} + +void cmStateSnapshot::SetUnwindState(cmStateEnums::SnapshotUnwindState state) +{ + this->Position->UnwindState = state; +} + void cmStateSnapshot::SetListFile(std::string const& listfile) { *this->Position->ExecutionListFile = listfile; diff --git a/Source/cmStateSnapshot.h b/Source/cmStateSnapshot.h index 07071b1239..d181fadae0 100644 --- a/Source/cmStateSnapshot.h +++ b/Source/cmStateSnapshot.h @@ -44,6 +44,12 @@ public: cmStateSnapshot GetCallStackBottom() const; cmStateEnums::SnapshotType GetType() const; + cmStateEnums::SnapshotUnwindType GetUnwindType() const; + void SetUnwindType(cmStateEnums::SnapshotUnwindType type); + + cmStateEnums::SnapshotUnwindState GetUnwindState() const; + void SetUnwindState(cmStateEnums::SnapshotUnwindState state); + void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status); cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id, bool parent_scope = false) const; diff --git a/Source/cmStateTypes.h b/Source/cmStateTypes.h index b3fbc13d99..29a07ae62f 100644 --- a/Source/cmStateTypes.h +++ b/Source/cmStateTypes.h @@ -29,6 +29,18 @@ enum SnapshotType VariableScopeType }; +enum SnapshotUnwindType +{ + NO_UNWIND, + CAN_UNWIND +}; + +enum SnapshotUnwindState +{ + NOT_UNWINDING, + UNWINDING +}; + // There are multiple overlapping ranges represented here. Be aware that adding // a value to this enumeration may cause failures in numerous places which // assume details about the ordering. diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake index 10f3453514..2ecebc4e94 100644 --- a/Tests/RunCMake/find_package/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake @@ -48,6 +48,14 @@ run_cmake(RequiredVarOptional) run_cmake(RequiredVarNested) run_cmake(FindRootPathAndPrefixPathAreEqual) run_cmake(SetFoundFALSE) +run_cmake(UnwindIncludeBlock) +run_cmake(UnwindIncludeFunction) +run_cmake(UnwindIncludeInvalidContext) +run_cmake(UnwindIncludeInvalidFindPackage) +run_cmake(UnwindIncludeInvalidInclude) +run_cmake(UnwindIncludeNoUnwind) +run_cmake(UnwindIncludeOnly) +run_cmake(UnwindIncludeSecondary) run_cmake(WrongVersion) run_cmake(WrongVersionConfig) run_cmake(CMP0084-OLD) diff --git a/Tests/RunCMake/find_package/UnwindInclude/NoOp.cmake b/Tests/RunCMake/find_package/UnwindInclude/NoOp.cmake new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Tests/RunCMake/find_package/UnwindInclude/NoUnwind.cmake b/Tests/RunCMake/find_package/UnwindInclude/NoUnwind.cmake new file mode 100644 index 0000000000..5e8c11ff9a --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindInclude/NoUnwind.cmake @@ -0,0 +1,2 @@ +find_package(SecondarySuccessful UNWIND_INCLUDE) +include(${CMAKE_CURRENT_LIST_DIR}/NoOp.cmake) diff --git a/Tests/RunCMake/find_package/UnwindInclude/PrimaryUnwindConfig.cmake b/Tests/RunCMake/find_package/UnwindInclude/PrimaryUnwindConfig.cmake new file mode 100644 index 0000000000..59952ad87b --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindInclude/PrimaryUnwindConfig.cmake @@ -0,0 +1,2 @@ +include(${CMAKE_CURRENT_LIST_DIR}/${UNWIND_TARGET}.cmake) +set(PrimaryUnwind_FOUND true) diff --git a/Tests/RunCMake/find_package/UnwindInclude/SecondarySuccessfulConfig.cmake b/Tests/RunCMake/find_package/UnwindInclude/SecondarySuccessfulConfig.cmake new file mode 100644 index 0000000000..33efc407aa --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindInclude/SecondarySuccessfulConfig.cmake @@ -0,0 +1 @@ +set(SecondarySuccessful_FOUND true) diff --git a/Tests/RunCMake/find_package/UnwindInclude/SecondaryUnwindConfig.cmake b/Tests/RunCMake/find_package/UnwindInclude/SecondaryUnwindConfig.cmake new file mode 100644 index 0000000000..a172bdd0e1 --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindInclude/SecondaryUnwindConfig.cmake @@ -0,0 +1 @@ +set(SecondaryUnwind_FOUND false) diff --git a/Tests/RunCMake/find_package/UnwindInclude/UnwindBlock.cmake b/Tests/RunCMake/find_package/UnwindInclude/UnwindBlock.cmake new file mode 100644 index 0000000000..927a619221 --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindInclude/UnwindBlock.cmake @@ -0,0 +1,14 @@ +set(RunCMake_TEST_FAILED "Failed to observe side effects of block() scopes during unwind") + +block() + find_package(foo UNWIND_INCLUDE) +endblock() + +block(PROPAGATE BLOCK_RUN PrimaryUnwind_FOUND) + set(BLOCK_RUN true) + set(PrimaryUnwind_FOUND false) +endblock() + +if(BLOCK_RUN) + set(RunCMake_TEST_FAILED) +endif() diff --git a/Tests/RunCMake/find_package/UnwindInclude/UnwindFunction.cmake b/Tests/RunCMake/find_package/UnwindInclude/UnwindFunction.cmake new file mode 100644 index 0000000000..409a0d6a34 --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindInclude/UnwindFunction.cmake @@ -0,0 +1,20 @@ +cmake_policy(SET CMP0140 NEW) + +function(f) + find_package(foo UNWIND_INCLUDE) +endfunction() + +function(g) + set(FUNC_CALLED true) + set(PrimaryUnwind_FOUND false) + return(PROPAGATE func_called PrimaryUnwind_FOUND) +endfunction() + +set(RunCMake_TEST_FAILED "Failed to observe side effects of function() calls during unwind") + +f() +g() + +if(FUNC_CALLED) + set(RunCMake_TEST_FAILED) +endif() diff --git a/Tests/RunCMake/find_package/UnwindInclude/UnwindInvalidFindPackage.cmake b/Tests/RunCMake/find_package/UnwindInclude/UnwindInvalidFindPackage.cmake new file mode 100644 index 0000000000..d3b465737e --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindInclude/UnwindInvalidFindPackage.cmake @@ -0,0 +1,2 @@ +find_package(foo UNWIND_INCLUDE) +find_package(bar) diff --git a/Tests/RunCMake/find_package/UnwindInclude/UnwindInvalidInclude.cmake b/Tests/RunCMake/find_package/UnwindInclude/UnwindInvalidInclude.cmake new file mode 100644 index 0000000000..01bb8fe8e8 --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindInclude/UnwindInvalidInclude.cmake @@ -0,0 +1,2 @@ +find_package(foo UNWIND_INCLUDE) +include(${CMAKE_CURRENT_LIST_DIR}/NoOp.cmake) diff --git a/Tests/RunCMake/find_package/UnwindInclude/UnwindOnly.cmake b/Tests/RunCMake/find_package/UnwindInclude/UnwindOnly.cmake new file mode 100644 index 0000000000..4eecde2982 --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindInclude/UnwindOnly.cmake @@ -0,0 +1,2 @@ +find_package(foo UNWIND_INCLUDE) +set(PrimaryUnwind_FOUND false) diff --git a/Tests/RunCMake/find_package/UnwindInclude/UnwindSecondary.cmake b/Tests/RunCMake/find_package/UnwindInclude/UnwindSecondary.cmake new file mode 100644 index 0000000000..05c479e8b5 --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindInclude/UnwindSecondary.cmake @@ -0,0 +1,2 @@ +find_package(SecondaryUnwind UNWIND_INCLUDE) +set(PrimaryUnwind_FOUND false) diff --git a/Tests/RunCMake/find_package/UnwindIncludeBlock-stderr.txt b/Tests/RunCMake/find_package/UnwindIncludeBlock-stderr.txt new file mode 100644 index 0000000000..22df337c6f --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindIncludeBlock-stderr.txt @@ -0,0 +1,30 @@ +CMake Warning at UnwindInclude/UnwindBlock.cmake:4 \(find_package\): + By not providing "Findfoo.cmake" in CMAKE_MODULE_PATH this project has + asked CMake to find a package configuration file provided by "foo", but + CMake did not find one. + + Could not find a package configuration file provided by "foo" with any of + the following names: + + fooConfig.cmake + foo-config.cmake + + Add the installation prefix of "foo" to CMAKE_PREFIX_PATH or set "foo_DIR" + to a directory containing one of the above files. If "foo" provides a + separate development package or SDK, be sure it has been installed. +Call Stack \(most recent call first\): + UnwindInclude/PrimaryUnwindConfig.cmake:1 \(include\) + UnwindIncludeBlock.cmake:5 \(find_package\) + CMakeLists.txt:3 \(include\) + + +CMake Warning at UnwindIncludeBlock.cmake:5 \(find_package\): + Found package configuration file: + + [^ +]*/Tests/RunCMake/find_package/UnwindInclude/PrimaryUnwindConfig.cmake + + but it set PrimaryUnwind_FOUND to FALSE so package "PrimaryUnwind" is + considered to be NOT FOUND. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package/UnwindIncludeBlock.cmake b/Tests/RunCMake/find_package/UnwindIncludeBlock.cmake new file mode 100644 index 0000000000..c93ed0590c --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindIncludeBlock.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0074 NEW) +set(PrimaryUnwind_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/UnwindInclude) + +set(UNWIND_TARGET UnwindBlock) +find_package(PrimaryUnwind) diff --git a/Tests/RunCMake/find_package/UnwindIncludeFunction-stderr.txt b/Tests/RunCMake/find_package/UnwindIncludeFunction-stderr.txt new file mode 100644 index 0000000000..bd167795e6 --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindIncludeFunction-stderr.txt @@ -0,0 +1,31 @@ +CMake Warning at UnwindInclude/UnwindFunction.cmake:4 \(find_package\): + By not providing "Findfoo.cmake" in CMAKE_MODULE_PATH this project has + asked CMake to find a package configuration file provided by "foo", but + CMake did not find one. + + Could not find a package configuration file provided by "foo" with any of + the following names: + + fooConfig.cmake + foo-config.cmake + + Add the installation prefix of "foo" to CMAKE_PREFIX_PATH or set "foo_DIR" + to a directory containing one of the above files. If "foo" provides a + separate development package or SDK, be sure it has been installed. +Call Stack \(most recent call first\): + UnwindInclude/UnwindFunction.cmake:15 \(f\) + UnwindInclude/PrimaryUnwindConfig.cmake:1 \(include\) + UnwindIncludeFunction.cmake:5 \(find_package\) + CMakeLists.txt:3 \(include\) + + +CMake Warning at UnwindIncludeFunction.cmake:5 \(find_package\): + Found package configuration file: + + [^ +]*/Tests/RunCMake/find_package/UnwindInclude/PrimaryUnwindConfig.cmake + + but it set PrimaryUnwind_FOUND to FALSE so package "PrimaryUnwind" is + considered to be NOT FOUND. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package/UnwindIncludeFunction.cmake b/Tests/RunCMake/find_package/UnwindIncludeFunction.cmake new file mode 100644 index 0000000000..41c56b71f7 --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindIncludeFunction.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0074 NEW) +set(PrimaryUnwind_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/UnwindInclude) + +set(UNWIND_TARGET UnwindFunction) +find_package(PrimaryUnwind) diff --git a/Tests/RunCMake/find_package/UnwindIncludeInvalidContext-result.txt b/Tests/RunCMake/find_package/UnwindIncludeInvalidContext-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindIncludeInvalidContext-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package/UnwindIncludeInvalidContext-stderr.txt b/Tests/RunCMake/find_package/UnwindIncludeInvalidContext-stderr.txt new file mode 100644 index 0000000000..e2331d21c1 --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindIncludeInvalidContext-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at UnwindIncludeInvalidContext.cmake:5 \(find_package\): + find_package called with UNWIND_INCLUDE in an invalid context +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package/UnwindIncludeInvalidContext.cmake b/Tests/RunCMake/find_package/UnwindIncludeInvalidContext.cmake new file mode 100644 index 0000000000..e71e0eb862 --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindIncludeInvalidContext.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0074 NEW) +set(PrimaryUnwind_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/UnwindInclude) + +set(UNWIND_TARGET NoUnwind) +find_package(PrimaryUnwind UNWIND_INCLUDE) diff --git a/Tests/RunCMake/find_package/UnwindIncludeInvalidFindPackage-result.txt b/Tests/RunCMake/find_package/UnwindIncludeInvalidFindPackage-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindIncludeInvalidFindPackage-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package/UnwindIncludeInvalidFindPackage-stderr.txt b/Tests/RunCMake/find_package/UnwindIncludeInvalidFindPackage-stderr.txt new file mode 100644 index 0000000000..fa4c7a9afd --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindIncludeInvalidFindPackage-stderr.txt @@ -0,0 +1,26 @@ +CMake Warning at UnwindInclude/UnwindInvalidFindPackage.cmake:1 \(find_package\): + By not providing "Findfoo.cmake" in CMAKE_MODULE_PATH this project has + asked CMake to find a package configuration file provided by "foo", but + CMake did not find one. + + Could not find a package configuration file provided by "foo" with any of + the following names: + + fooConfig.cmake + foo-config.cmake + + Add the installation prefix of "foo" to CMAKE_PREFIX_PATH or set "foo_DIR" + to a directory containing one of the above files. If "foo" provides a + separate development package or SDK, be sure it has been installed. +Call Stack \(most recent call first\): + UnwindInclude/PrimaryUnwindConfig.cmake:1 \(include\) + UnwindIncludeInvalidFindPackage.cmake:5 \(find_package\) + CMakeLists.txt:3 \(include\) + + +CMake Error at UnwindInclude/UnwindInvalidFindPackage.cmake:2 \(find_package\): + find_package called while already in an UNWIND state +Call Stack \(most recent call first\): + UnwindInclude/PrimaryUnwindConfig.cmake:1 \(include\) + UnwindIncludeInvalidFindPackage.cmake:5 \(find_package\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package/UnwindIncludeInvalidFindPackage.cmake b/Tests/RunCMake/find_package/UnwindIncludeInvalidFindPackage.cmake new file mode 100644 index 0000000000..53feb67726 --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindIncludeInvalidFindPackage.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0074 NEW) +set(PrimaryUnwind_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/UnwindInclude) + +set(UNWIND_TARGET UnwindInvalidFindPackage) +find_package(PrimaryUnwind) diff --git a/Tests/RunCMake/find_package/UnwindIncludeInvalidInclude-result.txt b/Tests/RunCMake/find_package/UnwindIncludeInvalidInclude-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindIncludeInvalidInclude-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package/UnwindIncludeInvalidInclude-stderr.txt b/Tests/RunCMake/find_package/UnwindIncludeInvalidInclude-stderr.txt new file mode 100644 index 0000000000..5414997d86 --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindIncludeInvalidInclude-stderr.txt @@ -0,0 +1,26 @@ +CMake Warning at UnwindInclude/UnwindInvalidInclude.cmake:1 \(find_package\): + By not providing "Findfoo.cmake" in CMAKE_MODULE_PATH this project has + asked CMake to find a package configuration file provided by "foo", but + CMake did not find one. + + Could not find a package configuration file provided by "foo" with any of + the following names: + + fooConfig.cmake + foo-config.cmake + + Add the installation prefix of "foo" to CMAKE_PREFIX_PATH or set "foo_DIR" + to a directory containing one of the above files. If "foo" provides a + separate development package or SDK, be sure it has been installed. +Call Stack \(most recent call first\): + UnwindInclude/PrimaryUnwindConfig.cmake:1 \(include\) + UnwindIncludeInvalidInclude.cmake:5 \(find_package\) + CMakeLists.txt:3 \(include\) + + +CMake Error at UnwindInclude/UnwindInvalidInclude.cmake:2 \(include\): + include called while already in an UNWIND state +Call Stack \(most recent call first\): + UnwindInclude/PrimaryUnwindConfig.cmake:1 \(include\) + UnwindIncludeInvalidInclude.cmake:5 \(find_package\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package/UnwindIncludeInvalidInclude.cmake b/Tests/RunCMake/find_package/UnwindIncludeInvalidInclude.cmake new file mode 100644 index 0000000000..020dd60c79 --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindIncludeInvalidInclude.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0074 NEW) +set(PrimaryUnwind_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/UnwindInclude) + +set(UNWIND_TARGET UnwindInvalidInclude) +find_package(PrimaryUnwind) diff --git a/Tests/RunCMake/find_package/UnwindIncludeNoUnwind.cmake b/Tests/RunCMake/find_package/UnwindIncludeNoUnwind.cmake new file mode 100644 index 0000000000..3a3d82d7cd --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindIncludeNoUnwind.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0074 NEW) +set(PrimaryUnwind_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/UnwindInclude) + +set(UNWIND_TARGET NoUnwind) +find_package(PrimaryUnwind) diff --git a/Tests/RunCMake/find_package/UnwindIncludeOnly-stderr.txt b/Tests/RunCMake/find_package/UnwindIncludeOnly-stderr.txt new file mode 100644 index 0000000000..b5b98536d0 --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindIncludeOnly-stderr.txt @@ -0,0 +1,30 @@ +CMake Warning at UnwindInclude/UnwindOnly.cmake:1 \(find_package\): + By not providing "Findfoo.cmake" in CMAKE_MODULE_PATH this project has + asked CMake to find a package configuration file provided by "foo", but + CMake did not find one. + + Could not find a package configuration file provided by "foo" with any of + the following names: + + fooConfig.cmake + foo-config.cmake + + Add the installation prefix of "foo" to CMAKE_PREFIX_PATH or set "foo_DIR" + to a directory containing one of the above files. If "foo" provides a + separate development package or SDK, be sure it has been installed. +Call Stack \(most recent call first\): + UnwindInclude/PrimaryUnwindConfig.cmake:1 \(include\) + UnwindIncludeOnly.cmake:5 \(find_package\) + CMakeLists.txt:3 \(include\) + + +CMake Warning at UnwindIncludeOnly.cmake:5 \(find_package\): + Found package configuration file: + + [^ +]*/Tests/RunCMake/find_package/UnwindInclude/PrimaryUnwindConfig.cmake + + but it set PrimaryUnwind_FOUND to FALSE so package "PrimaryUnwind" is + considered to be NOT FOUND. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package/UnwindIncludeOnly.cmake b/Tests/RunCMake/find_package/UnwindIncludeOnly.cmake new file mode 100644 index 0000000000..4ed69d2488 --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindIncludeOnly.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0074 NEW) +set(PrimaryUnwind_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/UnwindInclude) + +set(UNWIND_TARGET UnwindOnly) +find_package(PrimaryUnwind) diff --git a/Tests/RunCMake/find_package/UnwindIncludeSecondary-stderr.txt b/Tests/RunCMake/find_package/UnwindIncludeSecondary-stderr.txt new file mode 100644 index 0000000000..441bda908a --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindIncludeSecondary-stderr.txt @@ -0,0 +1,24 @@ +CMake Warning at UnwindInclude/UnwindSecondary.cmake:1 \(find_package\): + Found package configuration file: + + [^ +]*/Tests/RunCMake/find_package/UnwindInclude/SecondaryUnwindConfig.cmake + + but it set SecondaryUnwind_FOUND to FALSE so package "SecondaryUnwind" is + considered to be NOT FOUND. +Call Stack \(most recent call first\): + UnwindInclude/PrimaryUnwindConfig.cmake:1 \(include\) + UnwindIncludeSecondary.cmake:5 \(find_package\) + CMakeLists.txt:3 \(include\) + + +CMake Warning at UnwindIncludeSecondary.cmake:5 \(find_package\): + Found package configuration file: + + [^ +]*/Tests/RunCMake/find_package/UnwindInclude/PrimaryUnwindConfig.cmake + + but it set PrimaryUnwind_FOUND to FALSE so package "PrimaryUnwind" is + considered to be NOT FOUND. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package/UnwindIncludeSecondary.cmake b/Tests/RunCMake/find_package/UnwindIncludeSecondary.cmake new file mode 100644 index 0000000000..18cb0b8b71 --- /dev/null +++ b/Tests/RunCMake/find_package/UnwindIncludeSecondary.cmake @@ -0,0 +1,5 @@ +cmake_policy(SET CMP0074 NEW) +set(PrimaryUnwind_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/UnwindInclude) + +set(UNWIND_TARGET UnwindSecondary) +find_package(PrimaryUnwind)