From 14a0e750cb33f09faf01134c420483d358d0fae8 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 21 Jul 2022 09:52:28 -0400 Subject: cmake: In -P mode ignore flags like `--version` after `--` Fixes: #21031 --- Source/cmakemain.cxx | 2 +- Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt | 5 +++-- Tests/RunCMake/CommandLine/P_arbitrary_args.cmake | 1 + Tests/RunCMake/CommandLine/RunCMakeTest.cmake | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 97c275e..f931e9d 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -207,7 +207,7 @@ int do_cmake(int ac, char const* const* av) #ifndef CMAKE_BOOTSTRAP cmDocumentation doc; doc.addCMakeStandardDocSections(); - if (doc.CheckOptions(ac, av)) { + if (doc.CheckOptions(ac, av, "--")) { // Construct and print requested documentation. cmake hcm(cmake::RoleInternal, cmState::Unknown); hcm.SetHomeDirectory(""); diff --git a/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt b/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt index c94c19d..cde76f7 100644 --- a/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt +++ b/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt @@ -1,4 +1,4 @@ -^-- CMAKE_ARGC='8' +^-- CMAKE_ARGC='9' -- CMAKE_ARGV1='-P' -- CMAKE_ARGV2='[^']*/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake' -- CMAKE_ARGV3='--' @@ -6,4 +6,5 @@ -- CMAKE_ARGV5='-S' -- CMAKE_ARGV6='-B' -- CMAKE_ARGV7='--fresh' --- CMAKE_ARGV8=''$ +-- CMAKE_ARGV8='--version' +-- CMAKE_ARGV9=''$ diff --git a/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake b/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake index 8dca990..7d79af5 100644 --- a/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake +++ b/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake @@ -7,3 +7,4 @@ message(STATUS "CMAKE_ARGV5='${CMAKE_ARGV5}'") message(STATUS "CMAKE_ARGV6='${CMAKE_ARGV6}'") message(STATUS "CMAKE_ARGV7='${CMAKE_ARGV7}'") message(STATUS "CMAKE_ARGV8='${CMAKE_ARGV8}'") +message(STATUS "CMAKE_ARGV9='${CMAKE_ARGV9}'") diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 1663fa8..fc05b2d 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -53,7 +53,7 @@ run_cmake_command(G_bad-arg ${CMAKE_COMMAND} -B DummyBuildDir -G NoSuchGenerator 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) +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_fresh ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_fresh.cmake" --fresh) run_cmake_command(build-no-dir -- cgit v0.12