1330d8983SJohannes Doerfert# CMakeLists.txt file for unit testing OpenMP offloading runtime library. 2330d8983SJohannes Doerfertif(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR 3330d8983SJohannes Doerfert CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0.0) 4770d9283SJoseph Huber message(STATUS "Can only test with Clang compiler in version 6.0.0 or later.") 59adf8118SWÁNG Xuěruì message(WARNING "The check-offload target will not be available!") 6330d8983SJohannes Doerfert return() 7330d8983SJohannes Doerfertendif() 8330d8983SJohannes Doerfert 9330d8983SJohannes Doerfertif(LIBOMPTARGET_ENABLE_DEBUG) 10330d8983SJohannes Doerfert set(LIBOMPTARGET_DEBUG True) 11330d8983SJohannes Doerfertelse() 12330d8983SJohannes Doerfert set(LIBOMPTARGET_DEBUG False) 13330d8983SJohannes Doerfertendif() 14330d8983SJohannes Doerfert 15fde2d23eSEthan Luis McDonoughif (NOT OPENMP_STANDALONE_BUILD AND "compiler-rt" IN_LIST LLVM_ENABLE_RUNTIMES) 16fde2d23eSEthan Luis McDonough set(LIBOMPTARGET_TEST_GPU_PGO True) 17fde2d23eSEthan Luis McDonoughelse() 18fde2d23eSEthan Luis McDonough set(LIBOMPTARGET_TEST_GPU_PGO False) 19fde2d23eSEthan Luis McDonoughendif() 20fde2d23eSEthan Luis McDonough 21330d8983SJohannes Doerfert# Replace the space from user's input with ";" in case that CMake add escape 22330d8983SJohannes Doerfert# char into the lit command. 23330d8983SJohannes Doerfertstring(REPLACE " " ";" LIBOMPTARGET_LIT_ARG_LIST "${LIBOMPTARGET_LIT_ARGS}") 24330d8983SJohannes Doerfert 253de162feSJoseph Huberfind_package(CUDAToolkit QUIET) 263de162feSJoseph Huberif(CUDAToolkit_FOUND) 273de162feSJoseph Huber get_filename_component(CUDA_ROOT "${CUDAToolkit_BIN_DIR}" DIRECTORY ABSOLUTE) 283de162feSJoseph Huber get_filename_component(CUDA_LIBDIR "${CUDA_cudart_static_LIBRARY}" DIRECTORY) 293de162feSJoseph Huberendif() 303de162feSJoseph Huber 31*04b26f0eSMichał Górnyset(OMP_DEPEND) 32*04b26f0eSMichał Górnyif(TARGET omp) 33*04b26f0eSMichał Górny set(OMP_DEPEND omp) 34*04b26f0eSMichał Górnyendif() 35*04b26f0eSMichał Górny 36330d8983SJohannes Doerfertstring(REGEX MATCHALL "([^\ ]+\ |[^\ ]+$)" SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS}") 37330d8983SJohannes Doerfertforeach(CURRENT_TARGET IN LISTS SYSTEM_TARGETS) 38330d8983SJohannes Doerfert string(STRIP "${CURRENT_TARGET}" CURRENT_TARGET) 39330d8983SJohannes Doerfert 40330d8983SJohannes Doerfert add_offload_testsuite(check-libomptarget-${CURRENT_TARGET} 41330d8983SJohannes Doerfert "Running libomptarget tests" 42330d8983SJohannes Doerfert ${CMAKE_CURRENT_BINARY_DIR}/${CURRENT_TARGET} 43*04b26f0eSMichał Górny DEPENDS omptarget ${OMP_DEPEND} ${LIBOMPTARGET_TESTED_PLUGINS} 44330d8983SJohannes Doerfert ARGS ${LIBOMPTARGET_LIT_ARG_LIST}) 45330d8983SJohannes Doerfert list(APPEND LIBOMPTARGET_LIT_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CURRENT_TARGET}) 46330d8983SJohannes Doerfert 47330d8983SJohannes Doerfert # Configure the lit.site.cfg.in file 48330d8983SJohannes Doerfert set(AUTO_GEN_COMMENT "## Autogenerated by libomptarget configuration.\n# Do not edit!") 49330d8983SJohannes Doerfert configure_file(lit.site.cfg.in ${CURRENT_TARGET}/lit.site.cfg @ONLY) 50330d8983SJohannes Doerfertendforeach() 51330d8983SJohannes Doerfert 52330d8983SJohannes Doerfert 53330d8983SJohannes Doerfertadd_offload_testsuite(check-libomptarget 54330d8983SJohannes Doerfert "Running libomptarget tests" 55330d8983SJohannes Doerfert ${LIBOMPTARGET_LIT_TESTSUITES} 56330d8983SJohannes Doerfert EXCLUDE_FROM_CHECK_ALL 57*04b26f0eSMichał Górny DEPENDS llvm-offload-device-info omptarget ${OMP_DEPEND} ${LIBOMPTARGET_TESTED_PLUGINS} 58330d8983SJohannes Doerfert ARGS ${LIBOMPTARGET_LIT_ARG_LIST}) 59330d8983SJohannes Doerfert 60330d8983SJohannes Doerfertadd_offload_testsuite(check-offload 61330d8983SJohannes Doerfert "Running libomptarget tests" 62330d8983SJohannes Doerfert ${LIBOMPTARGET_LIT_TESTSUITES} 63330d8983SJohannes Doerfert EXCLUDE_FROM_CHECK_ALL 64*04b26f0eSMichał Górny DEPENDS llvm-offload-device-info omptarget ${OMP_DEPEND} ${LIBOMPTARGET_TESTED_PLUGINS} 65330d8983SJohannes Doerfert ARGS ${LIBOMPTARGET_LIT_ARG_LIST}) 66