diff options
author | Brad King <brad.king@kitware.com> | 2020-03-09 13:15:32 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-03-09 13:15:38 (GMT) |
commit | efa30023b4056a4c17e80d7a86bc2506660c68a7 (patch) | |
tree | dd8aafeadf768e72dcbf3baf66b8ad2732ec954f /Source | |
parent | bb9dc34800765fe8b572bf127b9460c03c99dbd1 (diff) | |
parent | dc008095961fe4c2478d575931e8caf6c9bff92d (diff) | |
download | CMake-efa30023b4056a4c17e80d7a86bc2506660c68a7.zip CMake-efa30023b4056a4c17e80d7a86bc2506660c68a7.tar.gz CMake-efa30023b4056a4c17e80d7a86bc2506660c68a7.tar.bz2 |
Merge topic 'required_find_commands'
dc00809596 find_*: Add support for REQUIRED keyword
cc070e66cd cmFindBase: Use in-class member initialization
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4435
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmFindBase.cxx | 8 | ||||
-rw-r--r-- | Source/cmFindBase.h | 10 | ||||
-rw-r--r-- | Source/cmFindLibraryCommand.cxx | 8 | ||||
-rw-r--r-- | Source/cmFindPathCommand.cxx | 8 | ||||
-rw-r--r-- | Source/cmFindProgramCommand.cxx | 8 |
5 files changed, 34 insertions, 8 deletions
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index bec99bb..fb09b33 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -22,10 +22,6 @@ class cmExecutionStatus; cmFindBase::cmFindBase(cmExecutionStatus& status) : cmFindCommon(status) { - this->AlreadyInCache = false; - this->AlreadyInCacheWithoutMetaInfo = false; - this->NamesPerDir = false; - this->NamesPerDirAllowed = false; } bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) @@ -115,6 +111,10 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) } else if (args[j] == "NO_SYSTEM_PATH") { doing = DoingNone; this->NoDefaultPath = true; + } else if (args[j] == "REQUIRED") { + doing = DoingNone; + this->Required = true; + newStyle = true; } else if (this->CheckCommonArgument(args[j])) { doing = DoingNone; } else { diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h index fce0b11..4cbf09e 100644 --- a/Source/cmFindBase.h +++ b/Source/cmFindBase.h @@ -44,14 +44,16 @@ protected: std::string VariableDocumentation; std::string VariableName; std::vector<std::string> Names; - bool NamesPerDir; - bool NamesPerDirAllowed; + bool NamesPerDir = false; + bool NamesPerDirAllowed = false; // CMAKE_*_PATH CMAKE_SYSTEM_*_PATH FRAMEWORK|LIBRARY|INCLUDE|PROGRAM std::string EnvironmentPath; // LIB,INCLUDE - bool AlreadyInCache; - bool AlreadyInCacheWithoutMetaInfo; + bool AlreadyInCache = false; + bool AlreadyInCacheWithoutMetaInfo = false; + + bool Required = false; private: // Add pieces of the search. diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index d5a4bde..6f9f7a2 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -12,6 +12,7 @@ #include "cmGlobalGenerator.h" #include "cmMakefile.h" +#include "cmMessageType.h" #include "cmState.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" @@ -84,6 +85,13 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn) this->Makefile->AddCacheDefinition(this->VariableName, notfound.c_str(), this->VariableDocumentation.c_str(), cmStateEnums::FILEPATH); + if (this->Required) { + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + "Could not find " + this->VariableName + + " using the following names: " + cmJoin(this->Names, ", ")); + cmSystemTools::SetFatalErrorOccured(); + } return true; } diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index 908f0c1..f5b52c2 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -5,6 +5,7 @@ #include "cmsys/Glob.hxx" #include "cmMakefile.h" +#include "cmMessageType.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -51,6 +52,13 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn) this->VariableName, (this->VariableName + "-NOTFOUND").c_str(), 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(); + } return true; } diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index 3e49172..cbc3c78 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -3,6 +3,7 @@ #include "cmFindProgramCommand.h" #include "cmMakefile.h" +#include "cmMessageType.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -136,6 +137,13 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string> const& argsIn) this->Makefile->AddCacheDefinition( this->VariableName, (this->VariableName + "-NOTFOUND").c_str(), this->VariableDocumentation.c_str(), cmStateEnums::FILEPATH); + if (this->Required) { + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + "Could not find " + this->VariableName + + " using the following names: " + cmJoin(this->Names, ", ")); + cmSystemTools::SetFatalErrorOccured(); + } return true; } |