summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMatthew Woehlke <matthew.woehlke@kitware.com>2022-09-15 17:34:30 (GMT)
committerMatthew Woehlke <matthew.woehlke@kitware.com>2022-09-15 17:34:30 (GMT)
commitf976800577ce6db799894318cc1f7df2843f20ce (patch)
tree1795d57f4306fd9e991cbaa677b10e587851440d /Source
parent01a25d72c69b0a9a60c1a62939d6a2c543448118 (diff)
downloadCMake-f976800577ce6db799894318cc1f7df2843f20ce.zip
CMake-f976800577ce6db799894318cc1f7df2843f20ce.tar.gz
CMake-f976800577ce6db799894318cc1f7df2843f20ce.tar.bz2
try_compile: More useful error if insufficient arguments
Tweak try_compile and try_run to give a more informative error (rather than "unknown error") when given an insufficient number of arguments.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmTryCompileCommand.cxx7
-rw-r--r--Source/cmTryRunCommand.cxx6
2 files changed, 9 insertions, 4 deletions
diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx
index b59c225..a2c4ce1 100644
--- a/Source/cmTryCompileCommand.cxx
+++ b/Source/cmTryCompileCommand.cxx
@@ -16,12 +16,15 @@
bool cmTryCompileCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
+ cmMakefile& mf = status.GetMakefile();
+
if (args.size() < 3) {
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
+ "The try_compile() command requires at least 3 arguments.");
return false;
}
- cmMakefile& mf = status.GetMakefile();
-
if (mf.GetCMakeInstance()->GetWorkingMode() == cmake::FIND_PACKAGE_MODE) {
mf.IssueMessage(
MessageType::FATAL_ERROR,
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index 7a29521..70c7cf1 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -469,12 +469,14 @@ void TryRunCommandImpl::DoNotRunExecutable(
bool cmTryRunCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
+ cmMakefile& mf = status.GetMakefile();
+
if (args.size() < 4) {
+ mf.IssueMessage(MessageType::FATAL_ERROR,
+ "The try_run() command requires at least 4 arguments.");
return false;
}
- cmMakefile& mf = status.GetMakefile();
-
if (mf.GetCMakeInstance()->GetWorkingMode() == cmake::FIND_PACKAGE_MODE) {
mf.IssueMessage(
MessageType::FATAL_ERROR,