|
|
@@ -9,6 +9,8 @@
|
|
|
|
|
|
#include "cmStack.h"
|
|
|
|
|
|
+class cmMakefile;
|
|
|
+
|
|
|
/**
|
|
|
* Represents one call to find_package.
|
|
|
*/
|
|
|
@@ -19,16 +21,48 @@ public:
|
|
|
unsigned int Index;
|
|
|
};
|
|
|
|
|
|
+/**
|
|
|
+ * RAII type to manage the find_package call stack.
|
|
|
+ */
|
|
|
+// Note: implemented in cmMakefile.cxx
|
|
|
+class cmFindPackageStackRAII
|
|
|
+{
|
|
|
+ cmMakefile* Makefile;
|
|
|
+ cmFindPackageCall** Value = nullptr;
|
|
|
+
|
|
|
+public:
|
|
|
+ cmFindPackageStackRAII(cmMakefile* mf, std::string const& pkg);
|
|
|
+ ~cmFindPackageStackRAII();
|
|
|
+
|
|
|
+ cmFindPackageStackRAII(cmFindPackageStackRAII const&) = delete;
|
|
|
+ cmFindPackageStackRAII& operator=(cmFindPackageStackRAII const&) = delete;
|
|
|
+
|
|
|
+ /** Get a mutable pointer to the top of the stack.
|
|
|
+ The pointer is invalidated if BindTop is called again or when the
|
|
|
+ cmFindPackageStackRAII goes out of scope. */
|
|
|
+ void BindTop(cmFindPackageCall*& value);
|
|
|
+};
|
|
|
+
|
|
|
/**
|
|
|
* Represents a stack of find_package calls with efficient value semantics.
|
|
|
*/
|
|
|
class cmFindPackageStack
|
|
|
- : public cmConstStack<cmFindPackageCall, cmFindPackageStack>
|
|
|
+ : protected cmStack<cmFindPackageCall, cmFindPackageStack>
|
|
|
{
|
|
|
using cmStack::cmStack;
|
|
|
friend cmFindPackageStack::Base;
|
|
|
+ friend class cmFindPackageStackRAII;
|
|
|
+
|
|
|
+public:
|
|
|
+ using cmStack::Push;
|
|
|
+ using cmStack::Pop;
|
|
|
+ using cmStack::Empty;
|
|
|
+
|
|
|
+ cmFindPackageCall const& Top() const;
|
|
|
};
|
|
|
#ifndef cmFindPackageStack_cxx
|
|
|
-extern template class cmStack<cmFindPackageCall const, cmFindPackageStack,
|
|
|
- cmStackType::Const>;
|
|
|
+extern template class cmStack<cmFindPackageCall, cmFindPackageStack>;
|
|
|
+
|
|
|
+extern template cmFindPackageCall&
|
|
|
+cmStack<cmFindPackageCall, cmFindPackageStack>::Top<true>();
|
|
|
#endif
|