mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 02:39:48 -06:00
Tests: Avoid unnecessary copy of cmake in RunCMake.separate_arguments
The `cmake` binary can be quite large in debug builds. Inspired-by: Rolf Eike Beer <eb@emlix.com>
This commit is contained in:
@@ -4,12 +4,11 @@ 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)
|
||||
get_filename_component(cmake_command "${CMAKE_COMMAND}" ABSOLUTE)
|
||||
cmake_path (GET cmake_command FILENAME cmake_exe)
|
||||
cmake_path (GET cmake_command PARENT_PATH cmake_dir)
|
||||
|
||||
set (ENV{PATH} "${TEST_EXE_DIR}")
|
||||
set (ENV{PATH} "${cmake_dir}")
|
||||
|
||||
|
||||
separate_arguments (out UNIX_COMMAND PROGRAM "${cmake_exe}")
|
||||
@@ -22,8 +21,8 @@ if (NOT length EQUAL 2)
|
||||
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}'")
|
||||
if (NOT cmake STREQUAL "${cmake_dir}/${cmake_exe}")
|
||||
message (SEND_ERROR "bad path for program: '${cmake}' instead of '${cmake_dir}/${cmake_exe}'")
|
||||
endif()
|
||||
if (NOT args STREQUAL "")
|
||||
message (SEND_ERROR "bad value for args: '${args}' instead of ''")
|
||||
@@ -40,8 +39,8 @@ if (NOT length EQUAL 2)
|
||||
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}'")
|
||||
if (NOT cmake STREQUAL "${cmake_dir}/${cmake_exe}")
|
||||
message (SEND_ERROR "bad path for program: '${cmake}' instead of '${cmake_dir}/${cmake_exe}'")
|
||||
endif()
|
||||
if (NOT args STREQUAL " a b c")
|
||||
message (SEND_ERROR "bad value for args: '${args}' instead of ' a b c'")
|
||||
|
||||
@@ -4,12 +4,11 @@ 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)
|
||||
get_filename_component(cmake_command "${CMAKE_COMMAND}" ABSOLUTE)
|
||||
cmake_path (GET cmake_command FILENAME cmake_exe)
|
||||
cmake_path (GET cmake_command PARENT_PATH cmake_dir)
|
||||
|
||||
set (ENV{PATH} "${TEST_EXE_DIR}")
|
||||
set (ENV{PATH} "${cmake_dir}")
|
||||
|
||||
separate_arguments (out UNIX_COMMAND PROGRAM SEPARATE_ARGS "${cmake_exe} a b c")
|
||||
list (LENGTH out length)
|
||||
@@ -20,8 +19,8 @@ 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}'")
|
||||
if (NOT cmake STREQUAL "${cmake_dir}/${cmake_exe}")
|
||||
message (SEND_ERROR "bad path for program: '${cmake}' instead of '${cmake_dir}/${cmake_exe}'")
|
||||
endif()
|
||||
if (NOT out STREQUAL "a;b;c")
|
||||
message (SEND_ERROR "bad path for args: '${out}' instead of 'a;b;c'")
|
||||
|
||||
Reference in New Issue
Block a user