diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2021-05-02 12:20:56 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2021-05-11 16:16:08 (GMT) |
commit | b1729200c318dab23daac8643da5f9fdc673a5ef (patch) | |
tree | 46da1a315c6cc75fb22e63d07b667f31c9254de8 /Source/cmFindPathCommand.cxx | |
parent | ee87e53d3732a6482841c01c16e89f2822137d0e (diff) | |
download | CMake-b1729200c318dab23daac8643da5f9fdc673a5ef.zip CMake-b1729200c318dab23daac8643da5f9fdc673a5ef.tar.gz CMake-b1729200c318dab23daac8643da5f9fdc673a5ef.tar.bz2 |
find_*: refactor cache variable handling
Diffstat (limited to 'Source/cmFindPathCommand.cxx')
-rw-r--r-- | Source/cmFindPathCommand.cxx | 49 |
1 files changed, 16 insertions, 33 deletions
diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index 3fb0826..126cc2f 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -2,70 +2,53 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFindPathCommand.h" +#include <utility> + #include "cmsys/Glob.hxx" -#include "cmMakefile.h" -#include "cmMessageType.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" class cmExecutionStatus; -cmFindPathCommand::cmFindPathCommand(cmExecutionStatus& status) - : cmFindBase(status) +cmFindPathCommand::cmFindPathCommand(std::string findCommandName, + cmExecutionStatus& status) + : cmFindBase(std::move(findCommandName), status) { this->EnvironmentPath = "INCLUDE"; this->IncludeFileInPath = false; + this->VariableDocumentation = "Path to a file."; + this->VariableType = cmStateEnums::PATH; +} +cmFindPathCommand::cmFindPathCommand(cmExecutionStatus& status) + : cmFindPathCommand("find_path", status) +{ } // cmFindPathCommand bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn) { this->DebugMode = this->ComputeIfDebugModeWanted(); - this->VariableDocumentation = "Path to a file."; this->CMakePathName = "INCLUDE"; + if (!this->ParseArguments(argsIn)) { return false; } + if (this->AlreadyInCache) { - // If the user specifies the entry on the command line without a - // type we should add the type and docstring but keep the original - // value. - if (this->AlreadyInCacheWithoutMetaInfo) { - this->Makefile->AddCacheDefinition( - this->VariableName, "", this->VariableDocumentation.c_str(), - (this->IncludeFileInPath ? cmStateEnums::FILEPATH - : cmStateEnums::PATH)); - } + this->NormalizeFindResult(); return true; } std::string result = this->FindHeader(); - if (!result.empty()) { - this->Makefile->AddCacheDefinition( - this->VariableName, result, this->VariableDocumentation.c_str(), - (this->IncludeFileInPath) ? cmStateEnums::FILEPATH : cmStateEnums::PATH); - return true; - } - this->Makefile->AddCacheDefinition( - this->VariableName, this->VariableName + "-NOTFOUND", - this->VariableDocumentation.c_str(), - (this->IncludeFileInPath) ? cmStateEnums::FILEPATH : cmStateEnums::PATH); - if (this->Required) { - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - "Could not find " + this->VariableName + - " using the following files: " + cmJoin(this->Names, ", ")); - cmSystemTools::SetFatalErrorOccured(); - } + this->StoreFindResult(result); return true; } std::string cmFindPathCommand::FindHeader() { - std::string debug_name = this->IncludeFileInPath ? "find_file" : "find_path"; - cmFindBaseDebugState debug(debug_name, this); + cmFindBaseDebugState debug(this->FindCommandName, this); std::string header; if (this->SearchFrameworkFirst || this->SearchFrameworkOnly) { header = this->FindFrameworkHeader(debug); |