Merge topic 'set-CACHE-diagnostics'

20c23518d9 set: Improve diagnostics for CACHE mode

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8679
This commit is contained in:
Brad King
2023-08-07 15:53:28 +00:00
committed by Kitware Robot
5 changed files with 37 additions and 4 deletions
+12 -4
View File
@@ -115,10 +115,18 @@ bool cmSetCommand(std::vector<std::string> const& args,
// we should be nice and try to catch some simple screwups if the last or
// next to last args are CACHE then they screwed up. If they used FORCE
// without CACHE they screwed up
if ((args.back() == "CACHE") ||
(args.size() > 1 && args[args.size() - 2] == "CACHE") ||
(force && !cache)) {
status.SetError("given invalid arguments for CACHE mode.");
if (args.back() == "CACHE") {
status.SetError(
"given invalid arguments for CACHE mode: missing type and docstring");
return false;
}
if (args.size() > 1 && args[args.size() - 2] == "CACHE") {
status.SetError(
"given invalid arguments for CACHE mode: missing type or docstring");
return false;
}
if (force && !cache) {
status.SetError("given invalid arguments: FORCE specified without CACHE");
return false;
}
@@ -0,0 +1 @@
1
+19
View File
@@ -0,0 +1,19 @@
^CMake Error at CacheErrors\.cmake:1 \(set\):
set given invalid arguments for CACHE mode: missing type and docstring
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
+
CMake Error at CacheErrors\.cmake:2 \(set\):
set given invalid arguments for CACHE mode: missing type or docstring
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
+
CMake Error at CacheErrors\.cmake:3 \(set\):
set given invalid arguments for CACHE mode: missing type or docstring
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
+
CMake Error at CacheErrors\.cmake:4 \(set\):
set given invalid arguments: FORCE specified without CACHE
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)$
+4
View File
@@ -0,0 +1,4 @@
set (var val CACHE)
set (var val CACHE STRING)
set (var val CACHE "")
set (var val CACH3 STRING "" FORCE)
+1
View File
@@ -1,5 +1,6 @@
include(RunCMake)
run_cmake(CacheErrors)
run_cmake(ParentScope)
run_cmake(ParentPulling)
run_cmake(ParentPullingRecursive)