cmake: Simplify add_lit_testsuites

cmake 3.4 introduced LIST_DIRECTORIES to glob recurse, which can be
used to simplify this code greatly.

llvm-svn: 272217
This commit is contained in:
Justin Bogner 2016-06-08 22:36:37 +00:00
parent 79e7c2c9b4
commit 3adaa8cf4a
1 changed files with 13 additions and 21 deletions

View File

@ -1122,32 +1122,24 @@ function(add_lit_testsuites project directory)
# Search recursively for test directories by assuming anything not
# in a directory called Inputs contains tests.
set(lit_suites)
file(GLOB to_process ${directory}/*)
while(to_process)
set(cur_to_process ${to_process})
set(to_process)
foreach(lit_suite ${cur_to_process})
if(IS_DIRECTORY ${lit_suite})
string(FIND ${lit_suite} Inputs is_inputs)
if (is_inputs EQUAL -1)
list(APPEND lit_suites "${lit_suite}")
file(GLOB subdirs ${lit_suite}/*)
list(APPEND to_process ${subdirs})
endif()
endif()
endforeach()
endwhile()
file(GLOB_RECURSE to_process LIST_DIRECTORIES true ${directory}/*)
foreach(lit_suite ${to_process})
if(NOT IS_DIRECTORY ${lit_suite})
continue()
endif()
string(FIND ${lit_suite} Inputs is_inputs)
if (NOT is_inputs EQUAL -1)
continue()
endif()
# Now create a check- target for each test directory.
foreach(dir ${lit_suites})
string(REPLACE ${directory} "" name_slash ${dir})
# Create a check- target for the directory.
string(REPLACE ${directory} "" name_slash ${lit_suite})
if (name_slash)
string(REPLACE "/" "-" name_slash ${name_slash})
string(REPLACE "\\" "-" name_dashes ${name_slash})
string(TOLOWER "${project}${name_dashes}" name_var)
add_lit_target("check-${name_var}" "Running lit suite ${dir}"
${dir}
add_lit_target("check-${name_var}" "Running lit suite ${lit_suite}"
${lit_suite}
PARAMS ${ARG_PARAMS}
DEPENDS ${ARG_DEPENDS}
ARGS ${ARG_ARGS}