1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
5 #include "cmConfigure.h" // IWYU pragma: keep
13 #include "cmListFileCache.h"
17 /** \class cmGlobVerificationManager
18 * \brief Class for expressing build-time dependencies on glob expressions.
20 * Generates a CMake script which verifies glob outputs during prebuild.
23 class cmGlobVerificationManager
26 //! Save verification script for given makefile.
27 //! Saves to output <path>/<CMakeFilesDirectory>/VerifyGlobs.cmake
28 bool SaveVerificationScript(const std::string& path, cmMessenger* messenger);
30 //! Add an entry into the glob cache
31 void AddCacheEntry(bool recurse, bool listDirectories, bool followSymlinks,
32 const std::string& relative,
33 const std::string& expression,
34 const std::vector<std::string>& files,
35 const std::string& variable,
36 const cmListFileBacktrace& bt, cmMessenger* messenger);
38 //! Clear the glob cache for state reset.
41 //! Check targets should be written in generated build system.
42 bool DoWriteVerifyTarget() const;
44 //! Get the paths to the generated script and stamp files
45 std::string const& GetVerifyScript() const { return this->VerifyScript; }
46 std::string const& GetVerifyStamp() const { return this->VerifyStamp; }
52 const bool ListDirectories;
53 const bool FollowSymlinks;
54 const std::string Relative;
55 const std::string Expression;
56 CacheEntryKey(const bool rec, const bool l, const bool s, std::string rel,
61 , Relative(std::move(rel))
62 , Expression(std::move(e))
65 bool operator<(const CacheEntryKey& r) const;
66 void PrintGlobCommand(std::ostream& out, const std::string& cmdVar);
69 struct CacheEntryValue
71 bool Initialized = false;
72 std::vector<std::string> Files;
73 std::vector<std::pair<std::string, cmListFileBacktrace>> Backtraces;
76 using CacheEntryMap = std::map<CacheEntryKey, CacheEntryValue>;
78 std::string VerifyScript;
79 std::string VerifyStamp;
81 // Only cmState should be able to add cache values.
82 // cmGlobVerificationManager should never be used directly.
83 friend class cmState; // allow access to add cache values