|
|
@@ -18,6 +18,18 @@
|
|
|
#include "cmValue.h"
|
|
|
#include "cmake.h"
|
|
|
|
|
|
+#ifndef CMAKE_BOOTSTRAP
|
|
|
+# include <deque>
|
|
|
+# include <iterator>
|
|
|
+
|
|
|
+# include <cm/optional>
|
|
|
+# include <cm/string_view>
|
|
|
+# include <cmext/string_view>
|
|
|
+
|
|
|
+# include "cmConfigureLog.h"
|
|
|
+# include "cmRange.h"
|
|
|
+#endif
|
|
|
+
|
|
|
cmFindCommon::PathGroup cmFindCommon::PathGroup::All("ALL");
|
|
|
cmFindCommon::PathLabel cmFindCommon::PathLabel::PackageRoot(
|
|
|
"PackageName_ROOT");
|
|
|
@@ -514,6 +526,114 @@ void cmFindCommonDebugState::Write()
|
|
|
this->WriteDebug();
|
|
|
}
|
|
|
|
|
|
+#ifndef CMAKE_BOOTSTRAP
|
|
|
+void cmFindCommonDebugState::WriteSearchVariables(cmConfigureLog& log,
|
|
|
+ cmMakefile const& mf) const
|
|
|
+{
|
|
|
+ auto WriteString = [&log, &mf](std::string const& name) {
|
|
|
+ if (cmValue value = mf.GetDefinition(name)) {
|
|
|
+ log.WriteValue(name, *value);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ auto WriteCMakeList = [&log, &mf](std::string const& name) {
|
|
|
+ if (cmValue value = mf.GetDefinition(name)) {
|
|
|
+ cmList values{ *value };
|
|
|
+ if (!values.empty()) {
|
|
|
+ log.WriteValue(name, values);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ auto WriteEnvList = [&log](std::string const& name) {
|
|
|
+ if (auto value = cmSystemTools::GetEnvVar(name)) {
|
|
|
+ auto values = cmSystemTools::SplitEnvPath(*value);
|
|
|
+ if (!values.empty()) {
|
|
|
+ log.WriteValue(cmStrCat("ENV{", name, '}'), values);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ auto const* fc = this->FindCommand;
|
|
|
+ log.BeginObject("search_context"_s);
|
|
|
+ auto const& packageRootStack = mf.FindPackageRootPathStack;
|
|
|
+ if (!packageRootStack.empty()) {
|
|
|
+ bool havePaths =
|
|
|
+ std::any_of(packageRootStack.begin(), packageRootStack.end(),
|
|
|
+ [](std::vector<std::string> const& entry) -> bool {
|
|
|
+ return !entry.empty();
|
|
|
+ });
|
|
|
+ if (havePaths) {
|
|
|
+ log.BeginObject("package_stack");
|
|
|
+ log.BeginArray();
|
|
|
+ for (auto const& pkgPaths : cmReverseRange(packageRootStack)) {
|
|
|
+ if (!pkgPaths.empty()) {
|
|
|
+ log.NextArrayElement();
|
|
|
+ log.WriteValue("package_paths", pkgPaths);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.EndArray();
|
|
|
+ log.EndObject();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ auto cmakePathVar = cmStrCat("CMAKE_", fc->CMakePathName, "_PATH");
|
|
|
+ WriteCMakeList(cmakePathVar);
|
|
|
+ WriteCMakeList("CMAKE_PREFIX_PATH");
|
|
|
+ if (fc->CMakePathName == "PROGRAM"_s) {
|
|
|
+ WriteCMakeList("CMAKE_APPBUNDLE_PATH");
|
|
|
+ } else {
|
|
|
+ WriteCMakeList("CMAKE_FRAMEWORK_PATH");
|
|
|
+ }
|
|
|
+ // Same as above, but ask the environment instead.
|
|
|
+ WriteEnvList(cmakePathVar);
|
|
|
+ WriteEnvList("CMAKE_PREFIX_PATH");
|
|
|
+ if (fc->CMakePathName == "PROGRAM"_s) {
|
|
|
+ WriteEnvList("CMAKE_APPBUNDLE_PATH");
|
|
|
+ } else {
|
|
|
+ WriteEnvList("CMAKE_FRAMEWORK_PATH");
|
|
|
+ }
|
|
|
+ WriteEnvList("PATH");
|
|
|
+ WriteString("CMAKE_INSTALL_PREFIX");
|
|
|
+ WriteString("CMAKE_STAGING_PREFIX");
|
|
|
+ WriteCMakeList("CMAKE_SYSTEM_PREFIX_PATH");
|
|
|
+ auto systemPathVar = cmStrCat("CMAKE_SYSTEM_", fc->CMakePathName, "_PATH");
|
|
|
+ WriteCMakeList(systemPathVar);
|
|
|
+ // Sysroot paths.
|
|
|
+ WriteString("CMAKE_SYSROOT");
|
|
|
+ WriteString("CMAKE_SYSROOT_COMPILE");
|
|
|
+ WriteString("CMAKE_SYSROOT_LINK");
|
|
|
+ WriteString("CMAKE_FIND_ROOT_PATH");
|
|
|
+ // Write out paths which are ignored.
|
|
|
+ WriteCMakeList("CMAKE_IGNORE_PATH");
|
|
|
+ WriteCMakeList("CMAKE_IGNORE_PREFIX_PATH");
|
|
|
+ WriteCMakeList("CMAKE_SYSTEM_IGNORE_PATH");
|
|
|
+ WriteCMakeList("CMAKE_SYSTEM_IGNORE_PREFIX_PATH");
|
|
|
+ if (fc->CMakePathName == "PROGRAM"_s) {
|
|
|
+ WriteCMakeList("CMAKE_SYSTEM_APPBUNDLE_PATH");
|
|
|
+ } else {
|
|
|
+ WriteCMakeList("CMAKE_SYSTEM_FRAMEWORK_PATH");
|
|
|
+ }
|
|
|
+ for (auto const& extraVar : this->ExtraSearchVariables()) {
|
|
|
+ switch (extraVar.first) {
|
|
|
+ case VariableSource::String:
|
|
|
+ WriteString(extraVar.second);
|
|
|
+ break;
|
|
|
+ case VariableSource::PathList:
|
|
|
+ WriteCMakeList(extraVar.second);
|
|
|
+ break;
|
|
|
+ case VariableSource::EnvironmentList:
|
|
|
+ WriteEnvList(extraVar.second);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.EndObject();
|
|
|
+}
|
|
|
+
|
|
|
+std::vector<std::pair<cmFindCommonDebugState::VariableSource, std::string>>
|
|
|
+cmFindCommonDebugState::ExtraSearchVariables() const
|
|
|
+{
|
|
|
+ return {};
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
bool cmFindCommonDebugState::TrackSearchProgress() const
|
|
|
{
|
|
|
// Track search progress if debugging or logging the configure.
|