[OpenMP][CMake] Fix an issue when there is space in the argument LIBOMPTARGET_LIT_ARGS

D106236 added a new CMake argument for `libomptarget` test, but when user's
input contains white spaces, CMake will add escape char to the final lit command,
which leads to an error. This patch converts the user's input `LIBOMPTARGET_LIT_ARGS`
into a local array, and then passes the array to the function.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D106247
This commit is contained in:
Shilei Tian 2021-07-18 21:54:05 -04:00
parent 0ce9acf61d
commit 4504e1134c
1 changed files with 6 additions and 2 deletions

View File

@ -12,6 +12,10 @@ else()
set(LIBOMPTARGET_DEBUG False)
endif()
# Replace the space from user's input with ";" in case that CMake add escape
# char into the lit command.
string(REPLACE " " ";" LIBOMPTARGET_LIT_ARG_LIST "${LIBOMPTARGET_LIT_ARGS}")
string(REGEX MATCHALL "([^\ ]+\ |[^\ ]+$)" SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS}")
foreach(CURRENT_TARGET IN LISTS SYSTEM_TARGETS)
string(STRIP "${CURRENT_TARGET}" CURRENT_TARGET)
@ -19,7 +23,7 @@ foreach(CURRENT_TARGET IN LISTS SYSTEM_TARGETS)
"Running libomptarget tests"
${CMAKE_CURRENT_BINARY_DIR}/${CURRENT_TARGET}
DEPENDS omptarget omp ${LIBOMPTARGET_TESTED_PLUGINS}
ARGS ${LIBOMPTARGET_LIT_ARGS})
ARGS ${LIBOMPTARGET_LIT_ARG_LIST})
list(APPEND LIBOMPTARGET_LIT_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CURRENT_TARGET})
# Configure the lit.site.cfg.in file
@ -33,4 +37,4 @@ add_openmp_testsuite(check-libomptarget
${LIBOMPTARGET_LIT_TESTSUITES}
EXCLUDE_FROM_CHECK_ALL
DEPENDS omptarget omp ${LIBOMPTARGET_TESTED_PLUGINS}
ARGS ${LIBOMPTARGET_LIT_ARGS})
ARGS ${LIBOMPTARGET_LIT_ARG_LIST})