diff options
author | Brad King <brad.king@kitware.com> | 2022-09-19 14:16:51 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-09-19 14:17:02 (GMT) |
commit | 33f314764db8d70cc0d562065582adc81f536e56 (patch) | |
tree | dbf10c8f15c354cebd3c79427cad444b82fef7ba | |
parent | 40af69a1069abfff1e3bd63683ac55d4943f24bd (diff) | |
parent | f976800577ce6db799894318cc1f7df2843f20ce (diff) | |
download | CMake-33f314764db8d70cc0d562065582adc81f536e56.zip CMake-33f314764db8d70cc0d562065582adc81f536e56.tar.gz CMake-33f314764db8d70cc0d562065582adc81f536e56.tar.bz2 |
Merge topic 'improve-try_compile-arg-error'
f976800577 try_compile: More useful error if insufficient arguments
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !7682
-rw-r--r-- | Source/cmTryCompileCommand.cxx | 7 | ||||
-rw-r--r-- | Source/cmTryRunCommand.cxx | 6 | ||||
-rw-r--r-- | Tests/RunCMake/try_compile/NoArgs-stderr.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/try_compile/OneArg-stderr.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/try_compile/TwoArgs-stderr.txt | 2 |
5 files changed, 12 insertions, 7 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, diff --git a/Tests/RunCMake/try_compile/NoArgs-stderr.txt b/Tests/RunCMake/try_compile/NoArgs-stderr.txt index 72a697e..4228580 100644 --- a/Tests/RunCMake/try_compile/NoArgs-stderr.txt +++ b/Tests/RunCMake/try_compile/NoArgs-stderr.txt @@ -1,4 +1,4 @@ CMake Error at NoArgs.cmake:[0-9]+ \(try_compile\): - try_compile unknown error. + The try_compile\(\) command requires at least 3 arguments. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/OneArg-stderr.txt b/Tests/RunCMake/try_compile/OneArg-stderr.txt index bb0239e..a2e983e 100644 --- a/Tests/RunCMake/try_compile/OneArg-stderr.txt +++ b/Tests/RunCMake/try_compile/OneArg-stderr.txt @@ -1,4 +1,4 @@ CMake Error at OneArg.cmake:[0-9]+ \(try_compile\): - try_compile unknown error. + The try_compile\(\) command requires at least 3 arguments. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/TwoArgs-stderr.txt b/Tests/RunCMake/try_compile/TwoArgs-stderr.txt index 38f1d75..b68e78e 100644 --- a/Tests/RunCMake/try_compile/TwoArgs-stderr.txt +++ b/Tests/RunCMake/try_compile/TwoArgs-stderr.txt @@ -1,4 +1,4 @@ CMake Error at TwoArgs.cmake:[0-9]+ \(try_compile\): - try_compile unknown error. + The try_compile\(\) command requires at least 3 arguments. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) |