From d7b18895bcc707ed58beed9e17434341e60a6060 Mon Sep 17 00:00:00 2001 From: John Parent Date: Tue, 7 Dec 2021 14:43:30 -0500 Subject: cmake: Add filtered debug-find options Add a `--debug-find-pkg=` option to debug find calls for specific packages. Add a `--debug-find-var=` option to debug find calls for specific return variables. Fixes: #21880 --- Help/manual/cmake.1.rst | 14 ++++++ Help/release/dev/filter-debug-find.rst | 10 +++++ Source/cmFindCommon.cxx | 6 +++ Source/cmFindCommon.h | 3 +- Source/cmFindLibraryCommand.cxx | 3 +- Source/cmFindPackageCommand.cxx | 14 ++++-- Source/cmFindPackageCommand.h | 2 + Source/cmFindPathCommand.cxx | 3 +- Source/cmFindProgramCommand.cxx | 3 +- Source/cmake.cxx | 51 +++++++++++++++++++++- Source/cmake.h | 9 +++- Source/cmakemain.cxx | 4 ++ .../find_file/FromPATHEnvDebugVar-stderr.txt | 25 +++++++++++ .../FromPATHEnvDebugVar-stdout-cygwin.txt | 9 ++++ .../find_file/FromPATHEnvDebugVar-stdout-msys.txt | 9 ++++ .../FromPATHEnvDebugVar-stdout-windows.txt | 9 ++++ .../find_file/FromPATHEnvDebugVar-stdout.txt | 9 ++++ Tests/RunCMake/find_file/FromPATHEnvDebugVar.cmake | 24 ++++++++++ Tests/RunCMake/find_file/RunCMakeTest.cmake | 2 + .../find_library/FromPATHEnvDebugVar-stderr.txt | 28 ++++++++++++ .../FromPATHEnvDebugVar-stdout-cygwin.txt | 6 +++ .../FromPATHEnvDebugVar-stdout-msys.txt | 6 +++ .../FromPATHEnvDebugVar-stdout-windows.txt | 6 +++ .../find_library/FromPATHEnvDebugVar-stdout.txt | 6 +++ .../find_library/FromPATHEnvDebugVar.cmake | 35 +++++++++++++++ Tests/RunCMake/find_library/RunCMakeTest.cmake | 2 + .../find_package/FromPATHEnvDebugPkg-stderr.txt | 21 +++++++++ .../find_package/FromPATHEnvDebugPkg-stdout.txt | 9 ++++ .../find_package/FromPATHEnvDebugPkg.cmake | 31 +++++++++++++ .../find_package/MissingConfigDebugPkg-stderr.txt | 20 +++++++++ .../find_package/MissingConfigDebugPkg.cmake | 2 + Tests/RunCMake/find_package/RunCMakeTest.cmake | 3 ++ .../find_path/FromPATHEnvDebugVar-stderr.txt | 27 ++++++++++++ .../FromPATHEnvDebugVar-stdout-cygwin.txt | 9 ++++ .../find_path/FromPATHEnvDebugVar-stdout-msys.txt | 9 ++++ .../FromPATHEnvDebugVar-stdout-windows.txt | 9 ++++ .../find_path/FromPATHEnvDebugVar-stdout.txt | 9 ++++ Tests/RunCMake/find_path/FromPATHEnvDebugVar.cmake | 35 +++++++++++++++ Tests/RunCMake/find_path/RunCMakeTest.cmake | 2 + .../find_program/EnvAndHintsDebugVar-stderr.txt | 28 ++++++++++++ .../find_program/EnvAndHintsDebugVar-stdout.txt | 4 ++ .../find_program/EnvAndHintsDebugVar.cmake | 31 +++++++++++++ Tests/RunCMake/find_program/RunCMakeTest.cmake | 2 + 43 files changed, 539 insertions(+), 10 deletions(-) create mode 100644 Help/release/dev/filter-debug-find.rst create mode 100644 Tests/RunCMake/find_file/FromPATHEnvDebugVar-stderr.txt create mode 100644 Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-cygwin.txt create mode 100644 Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-msys.txt create mode 100644 Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-windows.txt create mode 100644 Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout.txt create mode 100644 Tests/RunCMake/find_file/FromPATHEnvDebugVar.cmake create mode 100644 Tests/RunCMake/find_library/FromPATHEnvDebugVar-stderr.txt create mode 100644 Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-cygwin.txt create mode 100644 Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-msys.txt create mode 100644 Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-windows.txt create mode 100644 Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout.txt create mode 100644 Tests/RunCMake/find_library/FromPATHEnvDebugVar.cmake create mode 100644 Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt create mode 100644 Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stdout.txt create mode 100644 Tests/RunCMake/find_package/FromPATHEnvDebugPkg.cmake create mode 100644 Tests/RunCMake/find_package/MissingConfigDebugPkg-stderr.txt create mode 100644 Tests/RunCMake/find_package/MissingConfigDebugPkg.cmake create mode 100644 Tests/RunCMake/find_path/FromPATHEnvDebugVar-stderr.txt create mode 100644 Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-cygwin.txt create mode 100644 Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-msys.txt create mode 100644 Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-windows.txt create mode 100644 Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout.txt create mode 100644 Tests/RunCMake/find_path/FromPATHEnvDebugVar.cmake create mode 100644 Tests/RunCMake/find_program/EnvAndHintsDebugVar-stderr.txt create mode 100644 Tests/RunCMake/find_program/EnvAndHintsDebugVar-stdout.txt create mode 100644 Tests/RunCMake/find_program/EnvAndHintsDebugVar.cmake diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index e23ddd8..04e2eda 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -250,6 +250,20 @@ Options See also the :variable:`CMAKE_FIND_DEBUG_MODE` variable for debugging a more local part of the project. +``--debug-find=[,...]`` + Put cmake find commands in a debug mode when running under calls + to ``find_package()``, where ```` is an entry in the given + comma-separated list of case-sensitive package names. + + Like ``--debug-find``, but limiting scope to the specified packages. + +``--debug-find-var=[,...]`` + Put cmake find commands in a debug mode when called with ```` + as the return variable, where ```` is an entry in the given + comma-separated list. + + Like ``--debug-find``, but limiting scope to the specified variable names. + ``--trace`` Put cmake in trace mode. diff --git a/Help/release/dev/filter-debug-find.rst b/Help/release/dev/filter-debug-find.rst new file mode 100644 index 0000000..8bdb61e --- /dev/null +++ b/Help/release/dev/filter-debug-find.rst @@ -0,0 +1,10 @@ +filter-debug-find +----------------- + +* The :manual:`cmake(1)` command line tool's gained a + ``--debug-find-pkg=`` option to enable debug messages under specific + :command:`find_package` calls. + +* The :manual:`cmake(1)` command line tool gained a ``--debug-find-var=`` + option to enable debug messages for ``find_*`` calls that use specific + result variables. diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 70d59c2..7631583 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -77,6 +77,12 @@ bool cmFindCommon::ComputeIfDebugModeWanted() this->Makefile->GetCMakeInstance()->GetDebugFindOutput(); } +bool cmFindCommon::ComputeIfDebugModeWanted(std::string const& var) +{ + return this->ComputeIfDebugModeWanted() || + this->Makefile->GetCMakeInstance()->GetDebugFindOutput(var); +} + void cmFindCommon::InitializeSearchPathGroups() { std::vector* labels; diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h index f84242e..1a49aff 100644 --- a/Source/cmFindCommon.h +++ b/Source/cmFindCommon.h @@ -99,8 +99,9 @@ protected: void SelectDefaultSearchModes(); /** The `InitialPass` functions of the child classes should set - this->DebugMode to the result of this. */ + this->DebugMode to the result of these. */ bool ComputeIfDebugModeWanted(); + bool ComputeIfDebugModeWanted(std::string const& var); // Path arguments prior to path manipulation routines std::vector UserHintsArgs; diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index ff04bab..1c4039b 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -32,13 +32,14 @@ cmFindLibraryCommand::cmFindLibraryCommand(cmExecutionStatus& status) // cmFindLibraryCommand bool cmFindLibraryCommand::InitialPass(std::vector const& argsIn) { - this->DebugMode = this->ComputeIfDebugModeWanted(); this->CMakePathName = "LIBRARY"; if (!this->ParseArguments(argsIn)) { return false; } + this->DebugMode = this->ComputeIfDebugModeWanted(this->VariableName); + if (this->AlreadyDefined) { this->NormalizeFindResult(); return true; diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 694eb0f..6d788e4 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -33,6 +33,7 @@ #include "cmSystemTools.h" #include "cmValue.h" #include "cmVersion.h" +#include "cmake.h" #if defined(__HAIKU__) # include @@ -144,9 +145,6 @@ bool cmFindPackageCommand::InitialPass(std::vector const& args) this->RequiredCMakeVersion = CMake_VERSION_ENCODE(v[0], v[1], v[2]); } - this->DebugMode = this->ComputeIfDebugModeWanted(); - this->DebugBuffer.clear(); - // Lookup target architecture, if any. if (cmValue arch = this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE")) { @@ -236,6 +234,10 @@ bool cmFindPackageCommand::InitialPass(std::vector const& args) // Always search directly in a generated path. this->SearchPathSuffixes.emplace_back(); + // Process debug mode + this->DebugMode = this->ComputeIfDebugModeWanted(this->Name); + this->DebugBuffer.clear(); + // Parse the arguments. enum Doing { @@ -619,6 +621,12 @@ bool cmFindPackageCommand::InitialPass(std::vector const& args) return loadedPackage; } +bool cmFindPackageCommand::ComputeIfDebugModeWanted(std::string const& var) +{ + return this->ComputeIfDebugModeWanted() || + this->Makefile->GetCMakeInstance()->GetDebugFindPkgOutput(var); +} + bool cmFindPackageCommand::FindPackageUsingModuleMode() { bool foundModule = false; diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index edf32d4..9d6eddf 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -40,6 +40,7 @@ class cmSearchPath; class cmFindPackageCommand : public cmFindCommon { public: + using cmFindCommon::ComputeIfDebugModeWanted; /*! A sorting order strategy to be applied to recovered package folders (see * FIND_PACKAGE_SORT_ORDER)*/ enum /*class*/ SortOrderType @@ -120,6 +121,7 @@ private: bool ReadListFile(const std::string& f, PolicyScopeRule psr); void StoreVersionFound(); + bool ComputeIfDebugModeWanted(std::string const& var); void ComputePrefixes(); void FillPrefixesPackageRoot(); void FillPrefixesCMakeEnvironment(); diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index 3d21167..a0a8570 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -29,13 +29,14 @@ cmFindPathCommand::cmFindPathCommand(cmExecutionStatus& status) // cmFindPathCommand bool cmFindPathCommand::InitialPass(std::vector const& argsIn) { - this->DebugMode = this->ComputeIfDebugModeWanted(); this->CMakePathName = "INCLUDE"; if (!this->ParseArguments(argsIn)) { return false; } + this->DebugMode = this->ComputeIfDebugModeWanted(this->VariableName); + if (this->AlreadyDefined) { this->NormalizeFindResult(); return true; diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index 9a4b063..780b256 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -177,13 +177,14 @@ cmFindProgramCommand::cmFindProgramCommand(cmExecutionStatus& status) // cmFindProgramCommand bool cmFindProgramCommand::InitialPass(std::vector const& argsIn) { - this->DebugMode = this->ComputeIfDebugModeWanted(); + this->CMakePathName = "PROGRAM"; // call cmFindBase::ParseArguments if (!this->ParseArguments(argsIn)) { return false; } + this->DebugMode = this->ComputeIfDebugModeWanted(this->VariableName); if (this->AlreadyDefined) { this->NormalizeFindResult(); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 9efdb54..2a3ef9b 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -968,7 +968,34 @@ void cmake::SetArgs(const std::vector& args) "--debug-find", CommandArgument::Values::Zero, [](std::string const&, cmake* state) -> bool { std::cout << "Running with debug output on for the `find` commands.\n"; - state->SetDebugFindOutputOn(true); + state->SetDebugFindOutput(true); + return true; + } }, + CommandArgument{ + "--debug-find-pkg", "Provide a package argument for --debug-find-pkg", + CommandArgument::Values::One, CommandArgument::RequiresSeparator::Yes, + [](std::string const& value, cmake* state) -> bool { + std::vector find_pkgs(cmTokenize(value, ",")); + std::cout << "Running with debug output on for the 'find' commands " + "for package(s)"; + for (auto const& v : find_pkgs) { + std::cout << " " << v; + state->SetDebugFindOutputPkgs(v); + } + std::cout << ".\n"; + return true; + } }, + CommandArgument{ + "--debug-find-var", CommandArgument::Values::One, + CommandArgument::RequiresSeparator::Yes, + [](std::string const& value, cmake* state) -> bool { + std::vector find_vars(cmTokenize(value, ",")); + std::cout << "Running with debug output on for the variable(s)"; + for (auto const& v : find_vars) { + std::cout << " " << v; + state->SetDebugFindOutputVars(v); + } + std::cout << ".\n"; return true; } }, CommandArgument{ "--trace-expand", CommandArgument::Values::Zero, @@ -1325,7 +1352,7 @@ void cmake::SetArgs(const std::vector& args) this->DebugTryCompileOn(); } if (expandedPreset->DebugFind == true) { - this->SetDebugFindOutputOn(true); + this->SetDebugFindOutput(true); } } #endif @@ -3619,6 +3646,26 @@ void cmake::SetDeprecatedWarningsAsErrors(bool b) cmStateEnums::INTERNAL); } +void cmake::SetDebugFindOutputPkgs(std::string const& args) +{ + this->DebugFindPkgs.emplace(args); +} + +void cmake::SetDebugFindOutputVars(std::string const& args) +{ + this->DebugFindVars.emplace(args); +} + +bool cmake::GetDebugFindOutput(std::string const& var) const +{ + return this->DebugFindVars.count(var); +} + +bool cmake::GetDebugFindPkgOutput(std::string const& pkg) const +{ + return this->DebugFindPkgs.count(pkg); +} + #if !defined(CMAKE_BOOTSTRAP) cmMakefileProfilingData& cmake::GetProfilingOutput() { diff --git a/Source/cmake.h b/Source/cmake.h index 3f2b2ed..a356e65 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -486,7 +486,11 @@ public: //! Do we want debug output from the find commands during the cmake run. bool GetDebugFindOutput() const { return this->DebugFindOutput; } - void SetDebugFindOutputOn(bool b) { this->DebugFindOutput = b; } + bool GetDebugFindOutput(std::string const& var) const; + bool GetDebugFindPkgOutput(std::string const& var) const; + void SetDebugFindOutput(bool b) { this->DebugFindOutput = b; } + void SetDebugFindOutputPkgs(std::string const& args); + void SetDebugFindOutputVars(std::string const& args); //! Do we want trace output during the cmake run. bool GetTrace() const { return this->Trace; } @@ -704,6 +708,9 @@ private: std::vector TraceOnlyThisSources; + std::set DebugFindPkgs; + std::set DebugFindVars; + LogLevel MessageLogLevel = LogLevel::LOG_STATUS; bool LogLevelWasSetViaCLI = false; bool LogContext = false; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 61d4ae4..00aafdc 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -90,6 +90,10 @@ const char* cmDocumentationOptions[][2] = { "useful on one try_compile at a time." }, { "--debug-output", "Put cmake in a debug mode." }, { "--debug-find", "Put cmake find in a debug mode." }, + { "--debug-find-pkg=[,...]", + "Limit cmake debug-find to the comma-separated list of packages" }, + { "--debug-find-var=[,...]", + "Limit cmake debug-find to the comma-separated list of result variables" }, { "--trace", "Put cmake in trace mode." }, { "--trace-expand", "Put cmake in trace mode with variable expansion." }, { "--trace-format=", "Set the output format of the trace." }, diff --git a/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stderr.txt b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stderr.txt new file mode 100644 index 0000000..38ed98c --- /dev/null +++ b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stderr.txt @@ -0,0 +1,25 @@ + find_file called with the following settings:.* + VAR: PrefixInPATH_File + NAMES: "PrefixInPATH.h" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + + find_file considered the following locations:.* + The item was not found.* + find_file called with the following settings:.* + VAR: PrefixInPATH_File + NAMES: "PrefixInPATH.h" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + + find_file considered the following locations:.* diff --git a/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-cygwin.txt b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-cygwin.txt new file mode 100644 index 0000000..6912bdf --- /dev/null +++ b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-cygwin.txt @@ -0,0 +1,9 @@ +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' +-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' diff --git a/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-msys.txt b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-msys.txt new file mode 100644 index 0000000..6912bdf --- /dev/null +++ b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-msys.txt @@ -0,0 +1,9 @@ +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' +-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' diff --git a/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-windows.txt b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-windows.txt new file mode 100644 index 0000000..6912bdf --- /dev/null +++ b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-windows.txt @@ -0,0 +1,9 @@ +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' +-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' diff --git a/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout.txt b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout.txt new file mode 100644 index 0000000..27a83ad --- /dev/null +++ b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout.txt @@ -0,0 +1,9 @@ +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' +-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND' diff --git a/Tests/RunCMake/find_file/FromPATHEnvDebugVar.cmake b/Tests/RunCMake/find_file/FromPATHEnvDebugVar.cmake new file mode 100644 index 0000000..9f058dd --- /dev/null +++ b/Tests/RunCMake/find_file/FromPATHEnvDebugVar.cmake @@ -0,0 +1,24 @@ +set(ENV_PATH "$ENV{PATH}") +foreach(path "/does_not_exist" "/include" "") + unset(PrefixInPATH_File CACHE) + set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}") + find_file(PrefixInPATH_File NAMES PrefixInPATH.h) + message(STATUS "PrefixInPATH_File='${PrefixInPATH_File}'") +endforeach() + +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF) +foreach(path "/does_not_exist" "/include" "") + unset(PrefixInPATH_File CACHE) + set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}") + find_file(PrefixInPATH_File NAMES PrefixInPATH.h) + message(STATUS "PrefixInPATH_File='${PrefixInPATH_File}'") +endforeach() + +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON) +foreach(path "/does_not_exist" "/include" "") + unset(PrefixInPATH_File CACHE) + set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}") + find_file(PrefixInPATH_File NAMES PrefixInPATH.h NO_SYSTEM_ENVIRONMENT_PATH) + message(STATUS "PrefixInPATH_File='${PrefixInPATH_File}'") +endforeach() +set(ENV{PATH} "${ENV_PATH}") diff --git a/Tests/RunCMake/find_file/RunCMakeTest.cmake b/Tests/RunCMake/find_file/RunCMakeTest.cmake index 95f55a5..c5cd5fa 100644 --- a/Tests/RunCMake/find_file/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_file/RunCMakeTest.cmake @@ -5,3 +5,5 @@ run_cmake(FromPrefixPath) run_cmake(PrefixInPATH) run_cmake(Required) run_cmake(NO_CACHE) + +run_cmake_with_options(FromPATHEnvDebugVar --debug-find-var=PrefixInPATH_File) diff --git a/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stderr.txt b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stderr.txt new file mode 100644 index 0000000..a690eec --- /dev/null +++ b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stderr.txt @@ -0,0 +1,28 @@ + find_library called with the following settings:.* + VAR: CREATED_LIBRARY + NAMES: \"created\" + \"created_no_exist\" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + + find_library considered the following locations:.* + The item was not found.* + find_library called with the following settings:.* + VAR: CREATED_LIBRARY + NAMES: \"created\" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + + find_library considered the following locations:.* + The item was found at.* +.*lib/libcreated.a diff --git a/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-cygwin.txt b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-cygwin.txt new file mode 100644 index 0000000..48f36cc --- /dev/null +++ b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-cygwin.txt @@ -0,0 +1,6 @@ +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' +-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a' +-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a' +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' diff --git a/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-msys.txt b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-msys.txt new file mode 100644 index 0000000..48f36cc --- /dev/null +++ b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-msys.txt @@ -0,0 +1,6 @@ +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' +-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a' +-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a' +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' diff --git a/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-windows.txt b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-windows.txt new file mode 100644 index 0000000..48f36cc --- /dev/null +++ b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-windows.txt @@ -0,0 +1,6 @@ +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' +-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a' +-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a' +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' diff --git a/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout.txt b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout.txt new file mode 100644 index 0000000..d6d13fb --- /dev/null +++ b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout.txt @@ -0,0 +1,6 @@ +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' +-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a' +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' diff --git a/Tests/RunCMake/find_library/FromPATHEnvDebugVar.cmake b/Tests/RunCMake/find_library/FromPATHEnvDebugVar.cmake new file mode 100644 index 0000000..c24e640 --- /dev/null +++ b/Tests/RunCMake/find_library/FromPATHEnvDebugVar.cmake @@ -0,0 +1,35 @@ +list(APPEND CMAKE_FIND_LIBRARY_PREFIXES lib) +list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .a) +set(ENV_PATH "$ENV{PATH}") +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/lib/libcreated.a" "created") + +set(CMAKE_FIND_DEBUG_MODE 1) +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF) + +set(ENV{PATH} "${CMAKE_CURRENT_BINARY_DIR}/lib") +find_library(CREATED_LIBRARY NAMES created created_no_exist) + +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON) + +set(ENV{PATH} "${CMAKE_CURRENT_BINARY_DIR}/lib") +find_library(CREATED_LIBRARY NAMES created) +set(CMAKE_FIND_DEBUG_MODE 0) + + +foreach(path "/does_not_exist" "/lib" "") + unset(CREATED_LIBRARY CACHE) + set(ENV{PATH} "${CMAKE_CURRENT_BINARY_DIR}${path}") + find_library(CREATED_LIBRARY NAMES created) + message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'") +endforeach() + +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF) +foreach(path "/does_not_exist" "/lib" "") + unset(CREATED_LIBRARY CACHE) + set(ENV{PATH} "${CMAKE_CURRENT_BINARY_DIR}${path}") + find_library(CREATED_LIBRARY NAMES created) + message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'") +endforeach() +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON) +set(ENV{PATH} "${ENV_PATH}") diff --git a/Tests/RunCMake/find_library/RunCMakeTest.cmake b/Tests/RunCMake/find_library/RunCMakeTest.cmake index ad02c82..eaaecf0 100644 --- a/Tests/RunCMake/find_library/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_library/RunCMakeTest.cmake @@ -12,3 +12,5 @@ run_cmake(Required) run_cmake(NO_CACHE) run_cmake_script(FromScriptMode "-DTEMP_DIR=${RunCMake_BINARY_DIR}/FromScriptMode-temp") + +run_cmake_with_options(FromPATHEnvDebugVar --debug-find-var=CREATED_LIBRARY) diff --git a/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt new file mode 100644 index 0000000..94ed178 --- /dev/null +++ b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt @@ -0,0 +1,21 @@ +CMake Debug Log at FromPATHEnvDebugPkg.cmake:4 \(find_package\): + find_package considered the following paths for Resolved.cmake.* +.*/Modules/FindResolved.cmake.* + The file was not found.* + _ROOT CMake variable.* + CMAKE_PREFIX_PATH variable.* + CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables.* + Env variable Resolved_DIR.* + CMAKE_PREFIX_PATH env variable.* + CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env variables.* + Paths specified by the find_package HINTS option.* + Standard system environment variables.* +.*Tests/RunCMake/find_package/PackageRoot.* + CMake User Package Registry.* + CMake variables defined in the Platform file.* + CMake System Package Registry.* + Paths specified by the find_package PATHS option.* + find_package considered the following locations for the Config module:.* +.*Tests/RunCMake/find_package/PackageRoot/ResolvedConfig\.cmake.* + The file was found at.* +.*Tests/RunCMake/find_package/PackageRoot/ResolvedConfig\.cmake diff --git a/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stdout.txt b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stdout.txt new file mode 100644 index 0000000..31e4dd2 --- /dev/null +++ b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stdout.txt @@ -0,0 +1,9 @@ +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' diff --git a/Tests/RunCMake/find_package/FromPATHEnvDebugPkg.cmake b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg.cmake new file mode 100644 index 0000000..0ed8a12 --- /dev/null +++ b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg.cmake @@ -0,0 +1,31 @@ +set(ENV_PATH "$ENV{PATH}") + +set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot") +find_package(Resolved QUIET) + +foreach(path "/does_not_exist" "/PackageRoot" "") + unset(ResolvedA_FOUND CACHE) + set(ResolvedA_DIR "") + set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}") + find_package(ResolvedA QUIET) + message(STATUS "Resolved_FOUND='${ResolvedA_FOUND}'") +endforeach() + +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF) +foreach(path "/does_not_exist" "/PackageRoot" "") + unset(Resolved_FOUND CACHE) + set(Resolved_DIR "") + set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}") + find_package(ResolvedB QUIET) + message(STATUS "Resolved_FOUND='${ResolvedB_FOUND}'") +endforeach() + +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON) +foreach(path "/does_not_exist" "/PackageRoot" "") + unset(Resolved_FOUND CACHE) + set(Resolved_DIR "") + set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}") + find_package(ResolvedC NO_SYSTEM_ENVIRONMENT_PATH QUIET) + message(STATUS "Resolved_FOUND='${ResolvedC_FOUND}'") +endforeach() +set(ENV{PATH} "${ENV_PATH}") diff --git a/Tests/RunCMake/find_package/MissingConfigDebugPkg-stderr.txt b/Tests/RunCMake/find_package/MissingConfigDebugPkg-stderr.txt new file mode 100644 index 0000000..54cf14b --- /dev/null +++ b/Tests/RunCMake/find_package/MissingConfigDebugPkg-stderr.txt @@ -0,0 +1,20 @@ + _ROOT CMake variable.* + CMAKE_PREFIX_PATH variable.* + CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables.* + Env variable NotHere_DIR.* + CMAKE_PREFIX_PATH env variable.* + CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env variables.* + Paths specified by the find_package HINTS option.* + Standard system environment variables.* + CMake User Package Registry.* + CMake variables defined in the Platform file.* + CMake System Package Registry.* + Paths specified by the find_package PATHS option.* +.* + .*NotHereConfig.cmake + .*nothere-config.cmake +.* +CMake Warning at MissingConfigDebugPkg.cmake:2 \(message\): + This warning must be reachable. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/find_package/MissingConfigDebugPkg.cmake b/Tests/RunCMake/find_package/MissingConfigDebugPkg.cmake new file mode 100644 index 0000000..238e7e4 --- /dev/null +++ b/Tests/RunCMake/find_package/MissingConfigDebugPkg.cmake @@ -0,0 +1,2 @@ +find_package(NotHere CONFIG) +message(WARNING "This warning must be reachable.") diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake index ad9757d..2bace98 100644 --- a/Tests/RunCMake/find_package/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake @@ -49,3 +49,6 @@ if(UNIX ) run_cmake(SetFoundResolved) endif() + +run_cmake_with_options(MissingConfigDebugPkg --debug-find-pkg=NotHere) +run_cmake_with_options(FromPATHEnvDebugPkg --debug-find-pkg=Resolved) diff --git a/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stderr.txt b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stderr.txt new file mode 100644 index 0000000..088efd5 --- /dev/null +++ b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stderr.txt @@ -0,0 +1,27 @@ + find_path called with the following settings:.* + VAR: PATH_IN_ENV_PATH + NAMES: \"PrefixInPATH\.h\" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + + find_path considered the following locations:.* + The item was not found.* + find_path called with the following settings:.* + VAR: PATH_IN_ENV_PATH + NAMES: \"PrefixInPATH\.h\" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + + find_path considered the following locations:.* + The item was found at.* +.*include/PrefixInPATH.* diff --git a/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-cygwin.txt b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-cygwin.txt new file mode 100644 index 0000000..a502d78 --- /dev/null +++ b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-cygwin.txt @@ -0,0 +1,9 @@ +-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' +-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' +-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' +-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' +-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' +-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' +-- PATH_IN_ENV_PATH='' +-- PATH_IN_ENV_PATH='' +-- PATH_IN_ENV_PATH='' diff --git a/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-msys.txt b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-msys.txt new file mode 100644 index 0000000..a502d78 --- /dev/null +++ b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-msys.txt @@ -0,0 +1,9 @@ +-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' +-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' +-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' +-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' +-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' +-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' +-- PATH_IN_ENV_PATH='' +-- PATH_IN_ENV_PATH='' +-- PATH_IN_ENV_PATH='' diff --git a/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-windows.txt b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-windows.txt new file mode 100644 index 0000000..a502d78 --- /dev/null +++ b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-windows.txt @@ -0,0 +1,9 @@ +-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' +-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' +-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' +-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' +-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' +-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' +-- PATH_IN_ENV_PATH='' +-- PATH_IN_ENV_PATH='' +-- PATH_IN_ENV_PATH='' diff --git a/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout.txt b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout.txt new file mode 100644 index 0000000..0d2389d --- /dev/null +++ b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout.txt @@ -0,0 +1,9 @@ +-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' +-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include' +-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' +-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' +-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' +-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND' +-- PATH_IN_ENV_PATH='' +-- PATH_IN_ENV_PATH='' +-- PATH_IN_ENV_PATH='' diff --git a/Tests/RunCMake/find_path/FromPATHEnvDebugVar.cmake b/Tests/RunCMake/find_path/FromPATHEnvDebugVar.cmake new file mode 100644 index 0000000..4c83151 --- /dev/null +++ b/Tests/RunCMake/find_path/FromPATHEnvDebugVar.cmake @@ -0,0 +1,35 @@ +set(ENV_PATH "$ENV{PATH}") + +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF) + +set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}/include") +find_path(PATH_IN_ENV_PATH NAMES PrefixInPATH.h) + +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON) +find_path(PATH_IN_ENV_PATH NAMES PrefixInPATH.h) + + +foreach(path "/does_not_exist" "/include" "") + unset(PATH_IN_ENV_PATH_A CACHE) + set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}") + find_path(PATH_IN_ENV_PATH_A NAMES PrefixInPATH.h) + message(STATUS "PATH_IN_ENV_PATH='${PATH_IN_ENV_PATH_A}'") +endforeach() + +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF) +foreach(path "/does_not_exist" "/include" "") + unset(PATH_IN_ENV_PATH_A CACHE) + set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}") + find_path(PATH_IN_ENV_PATH_A NAMES PrefixInPATH.h) + message(STATUS "PATH_IN_ENV_PATH='${PATH_IN_ENV_PATH_A}'") +endforeach() + +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON) +foreach(path "/does_not_exist" "/include" "") + unset(PATH_IN_ENV_PATH_A CACHE) + set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}") + find_path(PATH_IN_ENV_PAT_H_A NAMES PrefixInPATH.h NO_SYSTEM_ENVIRONMENT_PATH) + message(STATUS "PATH_IN_ENV_PATH='${PATH_IN_ENV_PATH_A}'") +endforeach() + +set(ENV{PATH} "${ENV_PATH}") diff --git a/Tests/RunCMake/find_path/RunCMakeTest.cmake b/Tests/RunCMake/find_path/RunCMakeTest.cmake index 90ee768..5b52f90 100644 --- a/Tests/RunCMake/find_path/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_path/RunCMakeTest.cmake @@ -9,3 +9,5 @@ run_cmake(NO_CACHE) if(APPLE) run_cmake(FrameworksWithSubdirs) endif() + +run_cmake_with_options(FromPATHEnvDebugVar --debug-find-var=PATH_IN_ENV_PATH) diff --git a/Tests/RunCMake/find_program/EnvAndHintsDebugVar-stderr.txt b/Tests/RunCMake/find_program/EnvAndHintsDebugVar-stderr.txt new file mode 100644 index 0000000..8951345 --- /dev/null +++ b/Tests/RunCMake/find_program/EnvAndHintsDebugVar-stderr.txt @@ -0,0 +1,28 @@ + find_program called with the following settings:.* + VAR: PROG + NAMES: \"testAandB\" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + + find_program considered the following locations:.* + The item was found at.* +.*testAandB +.* + find_program called with the following settings:.* + VAR: PROG + NAMES: \"testAandB\" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + + find_program considered the following locations:.* + The item was not found.* diff --git a/Tests/RunCMake/find_program/EnvAndHintsDebugVar-stdout.txt b/Tests/RunCMake/find_program/EnvAndHintsDebugVar-stdout.txt new file mode 100644 index 0000000..0051636 --- /dev/null +++ b/Tests/RunCMake/find_program/EnvAndHintsDebugVar-stdout.txt @@ -0,0 +1,4 @@ +-- PROG='[^']*/Tests/RunCMake/find_program/A/testAandB' +-- PROG='PROG-NOTFOUND' +-- PROG='[^']*/Tests/RunCMake/find_program/B/testAandB' +-- PROG='[^']*/Tests/RunCMake/find_program/A/testAandB' diff --git a/Tests/RunCMake/find_program/EnvAndHintsDebugVar.cmake b/Tests/RunCMake/find_program/EnvAndHintsDebugVar.cmake new file mode 100644 index 0000000..2978fea --- /dev/null +++ b/Tests/RunCMake/find_program/EnvAndHintsDebugVar.cmake @@ -0,0 +1,31 @@ + +set(ENV_PATH "$ENV{PATH}") +set(ENV{PATH} ${CMAKE_CURRENT_SOURCE_DIR}/A) +find_program(PROG + NAMES testAandB + ) +message(STATUS "PROG='${PROG}'") +unset(PROG CACHE) + +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF) +find_program(PROG + NAMES testAandB + ) +message(STATUS "PROG='${PROG}'") +unset(PROG CACHE) + +find_program(PROG_A + NAMES testAandB + HINTS ${CMAKE_CURRENT_SOURCE_DIR}/B ${CMAKE_CURRENT_SOURCE_DIR}/A + ) +message(STATUS "PROG='${PROG_A}'") +unset(PROG_A CACHE) +set(ENV{PATH} "${ENV_PATH}") + +find_program(PROG_A + NAMES testAandB + HINTS ${CMAKE_CURRENT_SOURCE_DIR}/A ${CMAKE_CURRENT_SOURCE_DIR}/B + ) +message(STATUS "PROG='${PROG_A}'") +unset(PROG_A CACHE) +set(ENV{PATH} "${ENV_PATH}") diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake index 34edc19..2a1dae4 100644 --- a/Tests/RunCMake/find_program/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake @@ -27,3 +27,5 @@ endif() if(APPLE) run_cmake(BundleSpaceInName) endif() + +run_cmake_with_options(EnvAndHintsDebugVar --debug-find-var=PROG) -- cgit v0.12