|
| 1 | +cmake_minimum_required(VERSION 3.15) |
| 2 | + |
| 3 | +message("Configuring SYCL End-to-End Tests") |
| 4 | + |
| 5 | +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) |
| 6 | + project(sycl-e2e-test-suite C CXX) |
| 7 | + set(SYCL_TEST_E2E_STANDALONE TRUE) |
| 8 | +endif() |
| 9 | + |
| 10 | +if(SYCL_TEST_E2E_STANDALONE) |
| 11 | + if( NOT OpenCL_LIBRARY ) |
| 12 | + find_package(OpenCL) |
| 13 | + endif() |
| 14 | +endif() # Standalone. |
| 15 | + |
| 16 | +if(SYCL_TEST_E2E_STANDALONE) |
| 17 | + set(SYCL_CXX_COMPILER ${CMAKE_CXX_COMPILER}) |
| 18 | +else() |
| 19 | + set(SYCL_CXX_COMPILER "${LLVM_BINARY_DIR}/bin/clang++") |
| 20 | +endif() # Standalone. |
| 21 | + |
| 22 | +find_package(Threads REQUIRED) |
| 23 | +set(SYCL_THREADS_LIB ${CMAKE_THREAD_LIBS_INIT}) |
| 24 | + |
| 25 | +if(NOT LLVM_LIT) |
| 26 | + find_program(LLVM_LIT |
| 27 | + NAMES llvm-lit lit.py lit |
| 28 | + PATHS "${LLVM_MAIN_SRC_DIR}/utils/lit" |
| 29 | + DOC "Path to lit.py") |
| 30 | +endif() |
| 31 | + |
| 32 | +set(SYCL_E2E_TESTS_LIT_FLAGS "-sv" CACHE STRING "Flags used when running lit") |
| 33 | + |
| 34 | +find_package(Python3 REQUIRED COMPONENTS Interpreter) |
| 35 | + |
| 36 | +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in" |
| 37 | + "${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg") |
| 38 | + |
| 39 | +if(SYCL_TEST_E2E_TARGETS) |
| 40 | + message("Configure iterative execution on multiple backends") |
| 41 | + add_custom_target(check-sycl-e2e) |
| 42 | + foreach(TARGET_STR ${SYCL_TEST_E2E_TARGETS}) |
| 43 | + string(REPLACE ":" ";" TARGET_LIST ${TARGET_STR}) |
| 44 | + list (GET TARGET_LIST 0 TARGET_BE) |
| 45 | + list (GET TARGET_LIST 1 TARGET_DEVICES) |
| 46 | + |
| 47 | + if ("${TARGET_BE}" STREQUAL "") |
| 48 | + message(FATAL_ERROR |
| 49 | + "invalid empty target backend specification in SYCL_TEST_E2E_TARGETS") |
| 50 | + elseif("${TARGET_DEVICES}" STREQUAL "") |
| 51 | + message(FATAL_ERROR |
| 52 | + "invalid empty target device specification in SYCL_TEST_E2E_TARGETS") |
| 53 | + endif() |
| 54 | + message("Run on ${TARGET_DEVICES} for ${TARGET_BE}") |
| 55 | + |
| 56 | + string(REPLACE "," "_" TARGET check-sycl-e2e-${TARGET_BE}-${TARGET_DEVICES}) |
| 57 | + |
| 58 | + add_custom_target(${TARGET} |
| 59 | + COMMAND ${Python3_EXECUTABLE} ${LLVM_LIT} ${SYCL_E2E_TESTS_LIT_FLAGS} --param sycl_be=${TARGET_BE} --param target_devices=${TARGET_DEVICES} . |
| 60 | + COMMENT "Running the SYCL tests for ${TARGET} backend" |
| 61 | + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 62 | + USES_TERMINAL |
| 63 | + ) |
| 64 | + set_target_properties(${TARGET} PROPERTIES FOLDER "SYCL Level Zero tests") |
| 65 | + add_dependencies(check-sycl-e2e ${TARGET}) |
| 66 | + |
| 67 | + endforeach() |
| 68 | +endif(SYCL_TEST_E2E_TARGETS) |
| 69 | + |
| 70 | +# TODO: Re-enable when moving the entire intel/llvm-test-suite back in-tree. |
| 71 | +# add_subdirectory(External) |
| 72 | +# add_subdirectory(ExtraTests) |
0 commit comments