Louis Dionne | 5e334b5 | 2018-12-21 15:59:04 | [diff] [blame] | 1 | #===-- CMakeLists.txt ----------------------------------------------------===## |
| 2 | # |
Chandler Carruth | 57b08b0 | 2019-01-19 10:56:40 | [diff] [blame] | 3 | # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | # See https://llvm.org/LICENSE.txt for license information. |
| 5 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Louis Dionne | 5e334b5 | 2018-12-21 15:59:04 | [diff] [blame] | 6 | # |
| 7 | #===----------------------------------------------------------------------===## |
| 8 | |
| 9 | # TODO(ldionne): This CMake testing infrastructure should be replaced with a |
| 10 | # llvm-lit test suite. |
| 11 | |
| 12 | add_custom_target(pstl-build-tests |
| 13 | COMMENT "Build all the pstl tests.") |
| 14 | |
| 15 | add_custom_target(check-pstl |
| 16 | COMMAND "${CMAKE_CTEST_COMMAND}" --output-on-failure |
| 17 | USES_TERMINAL |
| 18 | DEPENDS pstl-build-tests |
| 19 | COMMENT "Build and run all the unit tests.") |
| 20 | |
Louis Dionne | 4d88b17 | 2019-04-16 14:38:08 | [diff] [blame] | 21 | add_library(test_stdlib INTERFACE) |
| 22 | target_include_directories(test_stdlib INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/support/stdlib") |
| 23 | target_link_libraries(test_stdlib INTERFACE pstl::ParallelSTL) |
Louis Dionne | 5c4c443 | 2019-05-30 20:46:31 | [diff] [blame] | 24 | target_compile_options(test_stdlib INTERFACE -Wno-gnu-include-next) |
Louis Dionne | 4d88b17 | 2019-04-16 14:38:08 | [diff] [blame] | 25 | |
Louis Dionne | 3b62047 | 2019-03-27 21:28:24 | [diff] [blame] | 26 | file(GLOB_RECURSE UNIT_TESTS "*.pass.cpp") |
Louis Dionne | 5e334b5 | 2018-12-21 15:59:04 | [diff] [blame] | 27 | foreach(_file IN LISTS UNIT_TESTS) |
| 28 | file(RELATIVE_PATH _target "${CMAKE_CURRENT_SOURCE_DIR}" "${_file}") |
| 29 | string(REPLACE ".cpp" "" _target "${_target}") |
Louis Dionne | 3b62047 | 2019-03-27 21:28:24 | [diff] [blame] | 30 | string(REPLACE "/" "-" _target "${_target}") |
Louis Dionne | 5e334b5 | 2018-12-21 15:59:04 | [diff] [blame] | 31 | set(_target "pstl-${_target}") |
| 32 | |
| 33 | add_executable(${_target} EXCLUDE_FROM_ALL "${_file}") |
Louis Dionne | 3b62047 | 2019-03-27 21:28:24 | [diff] [blame] | 34 | target_include_directories(${_target} PRIVATE "${CMAKE_CURRENT_LIST_DIR}") |
Louis Dionne | 5c4c443 | 2019-05-30 20:46:31 | [diff] [blame] | 35 | target_compile_options(${_target} PRIVATE -Wno-unused-local-typedef -Wno-unused-variable) |
Louis Dionne | 4d88b17 | 2019-04-16 14:38:08 | [diff] [blame] | 36 | target_link_libraries(${_target} PRIVATE test_stdlib) |
Louis Dionne | 5e334b5 | 2018-12-21 15:59:04 | [diff] [blame] | 37 | set_target_properties(${_target} PROPERTIES CXX_EXTENSIONS NO |
| 38 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") |
| 39 | add_test(${_target} "${CMAKE_CURRENT_BINARY_DIR}/${_target}") |
| 40 | add_dependencies(pstl-build-tests ${_target}) |
| 41 | endforeach() |