summaryrefslogtreecommitdiff
path: root/Source/cmFindLibraryCommand.cxx
diff options
context:
space:
mode:
authorSylvain Joubert <joubert.sy@gmail.com>2020-03-06 14:30:01 +0100
committerSylvain Joubert <joubert.sy@gmail.com>2020-03-06 16:40:26 +0100
commitdc008095961fe4c2478d575931e8caf6c9bff92d (patch)
treed468b514eca32bf28351b91f41628ab8be64ca36 /Source/cmFindLibraryCommand.cxx
parentcc070e66cd9bd0d4e0ce56ad9dd307dbb854e61f (diff)
downloadcmake-dc008095961fe4c2478d575931e8caf6c9bff92d.tar.gz
find_*: Add support for REQUIRED keyword
In the same spirit as the REQUIRED keyword on find_package, this will stop cmake execution with an error on a failed find_program, find_file, find_path or find_library.
Diffstat (limited to 'Source/cmFindLibraryCommand.cxx')
-rw-r--r--Source/cmFindLibraryCommand.cxx8
1 files changed, 8 insertions, 0 deletions
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index d5a4bde97e..6f9f7a2f81 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;
}