find_*: Add debug logging infrastructure

Enable debug messages a new `--find-debug` command-line option or via
the `CMAKE_FIND_DEBUG_MODE` variable.

This work was started by Chris Wilson, continued by Ray Donnelly, and
then refactored by Robert Maynard to collect information into a single
message per find query.

Co-Author: Ray Donnelly <mingw.android@gmail.com>
Co-Author: Chris Wilson <chris+github@qwirx.com>
This commit is contained in:
Robert Maynard
2019-10-04 17:18:26 -04:00
parent 3289322e4f
commit a7ea20649d
11 changed files with 193 additions and 43 deletions

View File

@@ -6,6 +6,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <utility>
#include <vector>
#include "cmFindCommon.h"
@@ -31,7 +32,7 @@ public:
virtual bool ParseArguments(std::vector<std::string> const& args);
protected:
void PrintFindStuff();
friend class cmFindBaseDebugState;
void ExpandPaths();
// see if the VariableName is already set in the cache,
@@ -63,4 +64,33 @@ private:
void FillUserGuessPath();
};
class cmFindBaseDebugState
{
public:
explicit cmFindBaseDebugState(std::string name, cmFindBase const* findBase);
~cmFindBaseDebugState();
void FoundAt(std::string const& path, std::string regexName = std::string());
void FailedAt(std::string const& path,
std::string regexName = std::string());
private:
struct DebugLibState
{
DebugLibState() = default;
DebugLibState(std::string&& n, std::string p)
: regexName(n)
, path(std::move(p))
{
}
std::string regexName;
std::string path;
};
cmFindBase const* FindCommand;
std::string CommandName;
std::vector<DebugLibState> FailedSearchLocations;
DebugLibState FoundSearchLocation;
};
#endif