diff options
author | Brad King <brad.king@kitware.com> | 2023-02-09 14:57:58 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-02-09 14:58:14 (GMT) |
commit | 29476e275bb576d52aa88cd76e86d7381c00e0bf (patch) | |
tree | d8df9cc029efe0ad5563875f3229a559633993ae | |
parent | 4829abf4f39fbbddca1b9d97eeff2080588eecfa (diff) | |
parent | f9e8a067c254c711d8628356c23c402882557058 (diff) | |
download | CMake-29476e275bb576d52aa88cd76e86d7381c00e0bf.zip CMake-29476e275bb576d52aa88cd76e86d7381c00e0bf.tar.gz CMake-29476e275bb576d52aa88cd76e86d7381c00e0bf.tar.bz2 |
Merge topic 'stop_parsing_after_first_script_arg'
f9e8a067c2 cmake: Stop parsing after `--` when detecting script mode
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8186
-rw-r--r-- | Source/cmakemain.cxx | 12 | ||||
-rw-r--r-- | Tests/RunCMake/CommandLine/P_P_in_arbitrary_args_2-stdout.txt | 10 | ||||
-rw-r--r-- | Tests/RunCMake/CommandLine/RunCMakeTest.cmake | 1 |
3 files changed, 18 insertions, 5 deletions
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 1e02412..f4e602b 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -303,6 +303,13 @@ int do_cmake(int ac, char const* const* av) for (decltype(inputArgs.size()) i = 0; i < inputArgs.size(); ++i) { std::string const& arg = inputArgs[i]; bool matched = false; + + // Only in script mode do we stop parsing instead + // of preferring the last mode flag provided + if (arg == "--" && workingMode == cmake::SCRIPT_MODE) { + parsedArgs = inputArgs; + break; + } for (auto const& m : arguments) { if (m.matches(arg)) { matched = true; @@ -311,11 +318,6 @@ 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_2-stdout.txt b/Tests/RunCMake/CommandLine/P_P_in_arbitrary_args_2-stdout.txt new file mode 100644 index 0000000..ad386bd --- /dev/null +++ b/Tests/RunCMake/CommandLine/P_P_in_arbitrary_args_2-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='-o' +-- CMAKE_ARGV6='' +-- CMAKE_ARGV7='' +-- CMAKE_ARGV8='' +-- CMAKE_ARGV9=''$ diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index f48e845..943be24 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -56,6 +56,7 @@ 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_P_in_arbitrary_args_2 ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -P -o) run_cmake_command(P_fresh ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_fresh.cmake" --fresh) run_cmake_command(build-no-dir |