summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CommandLine
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-03-17 17:50:12 (GMT)
committerBrad King <brad.king@kitware.com>2022-03-17 17:50:12 (GMT)
commit36056ff5a38e72f2edf7f042d594d0356301bb9e (patch)
tree4d3524841fb026742a2e642079f4e7b695c010a5 /Tests/RunCMake/CommandLine
parente91c23402ea8d260339533a0ca2895bddc8a3c22 (diff)
downloadCMake-36056ff5a38e72f2edf7f042d594d0356301bb9e.zip
CMake-36056ff5a38e72f2edf7f042d594d0356301bb9e.tar.gz
CMake-36056ff5a38e72f2edf7f042d594d0356301bb9e.tar.bz2
cmake: Improve acceptance of arbitrary arguments in -P script mode
The fix in commit e4f1b301fe (cmake: Allow arbitrary args passed to CMake script, 2020-05-04, v3.18.0-rc1~211^2) only applied to "cache" arguments like `-DFOO`. Extend the fix to allow arbitrary arguments that collide with other CMake arguments like `-S` and `-B`.
Diffstat (limited to 'Tests/RunCMake/CommandLine')
-rw-r--r--Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt8
-rw-r--r--Tests/RunCMake/CommandLine/P_arbitrary_args.cmake11
-rw-r--r--Tests/RunCMake/CommandLine/RunCMakeTest.cmake2
3 files changed, 17 insertions, 4 deletions
diff --git a/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt b/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt
new file mode 100644
index 0000000..c0f96f3
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt
@@ -0,0 +1,8 @@
+^-- CMAKE_ARGC='7'
+-- CMAKE_ARGV1='-P'
+-- CMAKE_ARGV2='[^']*/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake'
+-- CMAKE_ARGV3='--'
+-- CMAKE_ARGV4='-DFOO'
+-- CMAKE_ARGV5='-S'
+-- CMAKE_ARGV6='-B'
+-- CMAKE_ARGV7=''$
diff --git a/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake b/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake
index 29faae3..d0a4859 100644
--- a/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake
+++ b/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake
@@ -1,3 +1,8 @@
-if(NOT ("${CMAKE_ARGV3}" STREQUAL "--" AND "${CMAKE_ARGV4}" STREQUAL "-DFOO"))
- message(FATAL_ERROR "`-DFOO` shouldn't trigger an error after `--`")
-endif()
+message(STATUS "CMAKE_ARGC='${CMAKE_ARGC}'")
+message(STATUS "CMAKE_ARGV1='${CMAKE_ARGV1}'")
+message(STATUS "CMAKE_ARGV2='${CMAKE_ARGV2}'")
+message(STATUS "CMAKE_ARGV3='${CMAKE_ARGV3}'")
+message(STATUS "CMAKE_ARGV4='${CMAKE_ARGV4}'")
+message(STATUS "CMAKE_ARGV5='${CMAKE_ARGV5}'")
+message(STATUS "CMAKE_ARGV6='${CMAKE_ARGV6}'")
+message(STATUS "CMAKE_ARGV7='${CMAKE_ARGV7}'")
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index 5b8c715..38ce9f2 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -52,7 +52,7 @@ run_cmake_command(G_no-arg ${CMAKE_COMMAND} -B DummyBuildDir -G)
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_arbitrary_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -DFOO)
+run_cmake_command(P_arbitrary_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -DFOO -S -B)
run_cmake_command(build-no-dir
${CMAKE_COMMAND} --build)