summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/get_filename_component
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-09-11 15:05:20 (GMT)
committerBrad King <brad.king@kitware.com>2017-09-13 14:47:04 (GMT)
commit31f73eb12dd0888efc61c0333539d1354c7268ce (patch)
tree11eddb116df6844f7e534a03f213b7ce07a56fba /Tests/RunCMake/get_filename_component
parent3f8c6cab4bb4a9f68708c11a38e4487dad363e38 (diff)
downloadCMake-31f73eb12dd0888efc61c0333539d1354c7268ce.zip
CMake-31f73eb12dd0888efc61c0333539d1354c7268ce.tar.gz
CMake-31f73eb12dd0888efc61c0333539d1354c7268ce.tar.bz2
get_filename_component: Revise PROGRAM/PROGRAM_ARGS split semantics
The KWSys `SystemTools::SplitProgramFromArgs` implementation goes into an infinite loop when the value is just " " (a space). Since the "program path with unquoted spaces plus command-line arguments" operation it is trying to provide is poorly defined (string parsing should not depend on filesystem content), just stop using it. Instead consider the main two use cases the old approach tried to handle: * The value is the name or absolute path of a program with no quoting or escaping, but also no command-line arguments. In this case we can use the value as given with no parsing, and assume no arguments. * The value is a command-line string containing the program name/path plus arguments. In this case we now assume that the command line is properly quoted or escaped. Fixes: #17262
Diffstat (limited to 'Tests/RunCMake/get_filename_component')
-rw-r--r--Tests/RunCMake/get_filename_component/KnownComponents.cmake11
1 files changed, 11 insertions, 0 deletions
diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake
index 7dfb55d..ac77ac3 100644
--- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake
+++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake
@@ -80,6 +80,17 @@ get_filename_component(test_program_name "/ arg1 arg2" PROGRAM
check("PROGRAM with args output: name" "${test_program_name}" "/")
check("PROGRAM with args output: args" "${test_program_args}" " arg1 arg2")
+get_filename_component(test_program_name " " PROGRAM)
+check("PROGRAM with just a space" "${test_program_name}" "")
+
+get_filename_component(test_program_name "${CMAKE_CURRENT_LIST_FILE}" PROGRAM)
+check("PROGRAM specified explicitly without quoting" "${test_program_name}" "${CMAKE_CURRENT_LIST_FILE}")
+
+get_filename_component(test_program_name "\"${CMAKE_CURRENT_LIST_FILE}\" arg1 arg2" PROGRAM
+ PROGRAM_ARGS test_program_args)
+check("PROGRAM specified explicitly with arguments: name" "${test_program_name}" "${CMAKE_CURRENT_LIST_FILE}")
+check("PROGRAM specified explicitly with arguments: args" "${test_program_args}" " arg1 arg2")
+
list(APPEND non_cache_vars test_program_name)
list(APPEND non_cache_vars test_program_args)