summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-12-07 13:17:05 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-12-07 13:17:14 (GMT)
commite544f2427da922bc3021b80ab2391da8ede526ec (patch)
tree0a7b84dce2eb28fff59b2ff791880c5603313597
parent602c24f778f68892ba983ddc3c7de891d9c56e52 (diff)
parent08aa516880c9b170195be2b0a00563249ce2bb82 (diff)
downloadCMake-e544f2427da922bc3021b80ab2391da8ede526ec.zip
CMake-e544f2427da922bc3021b80ab2391da8ede526ec.tar.gz
CMake-e544f2427da922bc3021b80ab2391da8ede526ec.tar.bz2
Merge topic 'stop_parsing_after_first_script_arg'
08aa516880 cmake: Stop parsing after `--` when detecting script mode Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !7992
-rw-r--r--Source/cmakemain.cxx5
-rw-r--r--Tests/RunCMake/CommandLine/P_P_in_arbitrary_args-stdout.txt10
-rw-r--r--Tests/RunCMake/CommandLine/RunCMakeTest.cmake1
3 files changed, 16 insertions, 0 deletions
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index a155787..1e02412 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -311,6 +311,11 @@ int do_cmake(int ac, char const* const* av)
}
return 1; // failed to parse
}
+ // Only in script mode do we stop parsing instead
+ // of preferring the last mode flag provided
+ if (arg == "--" && workingMode == cmake::SCRIPT_MODE) {
+ break;
+ }
}
if (!matched) {
parsedArgs.emplace_back(av[i]);
diff --git a/Tests/RunCMake/CommandLine/P_P_in_arbitrary_args-stdout.txt b/Tests/RunCMake/CommandLine/P_P_in_arbitrary_args-stdout.txt
new file mode 100644
index 0000000..95304ab
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/P_P_in_arbitrary_args-stdout.txt
@@ -0,0 +1,10 @@
+^-- CMAKE_ARGC='6'
+-- CMAKE_ARGV1='-P'
+-- CMAKE_ARGV2='[^']*/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake'
+-- CMAKE_ARGV3='--'
+-- CMAKE_ARGV4='-P'
+-- CMAKE_ARGV5='[^']*/Tests/RunCMake/CommandLine/non_existing.cmake'
+-- CMAKE_ARGV6=''
+-- CMAKE_ARGV7=''
+-- CMAKE_ARGV8=''
+-- CMAKE_ARGV9=''$
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index 08c5a49..44ddddf 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -54,6 +54,7 @@ run_cmake_command(P_no-arg ${CMAKE_COMMAND} -P)
run_cmake_command(P_no-file ${CMAKE_COMMAND} -P nosuchscriptfile.cmake)
run_cmake_command(P_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_args.cmake" relative/path "${RunCMake_SOURCE_DIR}")
run_cmake_command(P_arbitrary_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -DFOO -S -B --fresh --version)
+run_cmake_command(P_P_in_arbitrary_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -P "${RunCMake_SOURCE_DIR}/non_existing.cmake")
run_cmake_command(P_fresh ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_fresh.cmake" --fresh)
run_cmake_command(build-no-dir