1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00
Files
CMake/Tests/RunCMake/separate_arguments/ProgramCommand.cmake
Marc Chevrier 1c912056a1 cmake_path: remove new command from 3.19
Defer adding this command until post-3.19 development so that it
has more time to mature before being included in a release.

Issue: #21385
2020-11-03 09:55:35 -05:00

49 lines
1.5 KiB
CMake

separate_arguments (out UNIX_COMMAND PROGRAM "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}")
get_filename_component (cmake_exe "${CMAKE_COMMAND}" NAME)
set (ENV{PATH} "${TEST_EXE_DIR}")
separate_arguments (out UNIX_COMMAND PROGRAM "${cmake_exe}")
list (LENGTH out length)
if (length EQUAL 0)
message(FATAL_ERROR "existent program not found")
endif()
if (NOT length EQUAL 2)
message(FATAL_ERROR "unexpected arguments")
endif()
list(GET out 0 cmake)
list(GET out 1 args)
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 args STREQUAL "")
message (SEND_ERROR "bad value for args: '${args}' instead of ''")
endif()
separate_arguments (out UNIX_COMMAND PROGRAM "${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 2)
message(FATAL_ERROR "unexpected arguments")
endif()
list(GET out 0 cmake)
list(GET out 1 args)
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 args STREQUAL " a b c")
message (SEND_ERROR "bad value for args: '${args}' instead of ' a b c'")
endif()