diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2020-09-22 14:31:29 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2020-09-22 14:32:34 (GMT) |
commit | d832c1cc7d717623b2eb07a940c85ca427a8084e (patch) | |
tree | b6df341db1b3a8b8e323efb5676cb9ba50711cff /Tests/RunCMake/separate_arguments/ProgramCommandWithSeparateArgs.cmake | |
parent | f4c21d4953afe1c638226a0e8db2f0a887665f38 (diff) | |
download | CMake-d832c1cc7d717623b2eb07a940c85ca427a8084e.zip CMake-d832c1cc7d717623b2eb07a940c85ca427a8084e.tar.gz CMake-d832c1cc7d717623b2eb07a940c85ca427a8084e.tar.bz2 |
separate_arguments: add option PROGRAM
Fixes: #21217
Diffstat (limited to 'Tests/RunCMake/separate_arguments/ProgramCommandWithSeparateArgs.cmake')
-rw-r--r-- | Tests/RunCMake/separate_arguments/ProgramCommandWithSeparateArgs.cmake | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Tests/RunCMake/separate_arguments/ProgramCommandWithSeparateArgs.cmake b/Tests/RunCMake/separate_arguments/ProgramCommandWithSeparateArgs.cmake new file mode 100644 index 0000000..2826cc9 --- /dev/null +++ b/Tests/RunCMake/separate_arguments/ProgramCommandWithSeparateArgs.cmake @@ -0,0 +1,28 @@ + +separate_arguments (out UNIX_COMMAND PROGRAM SEPARATE_ARGS "xx a b c") +if (out) + message (SEND_ERROR "unexpected result with nonexistent program") +endif() + +set (TEST_EXE_DIR "${CMAKE_CURRENT_BINARY_DIR}/TestExe") +file(MAKE_DIRECTORY "${TEST_EXE_DIR}") +file(COPY "${CMAKE_COMMAND}" DESTINATION "${TEST_EXE_DIR}") +cmake_path (GET CMAKE_COMMAND FILENAME cmake_exe) + +set (ENV{PATH} "${TEST_EXE_DIR}") + +separate_arguments (out UNIX_COMMAND PROGRAM SEPARATE_ARGS "${cmake_exe} a b c") +list (LENGTH out length) +if (length EQUAL 0) + message(FATAL_ERROR "existent program not found") +endif() +if (NOT length EQUAL 4) + message(FATAL_ERROR "unexpected arguments") +endif() +list(POP_FRONT out cmake) +if (NOT cmake STREQUAL "${TEST_EXE_DIR}/${cmake_exe}") + message (SEND_ERROR "bad path for program: '${cmake}' instead of '${TEST_EXE_DIR}/${cmake_exe}'") +endif() +if (NOT out STREQUAL "a;b;c") + message (SEND_ERROR "bad path for args: '${out}' instead of 'a;b;c'") +endif() |