blob: bc027c30d085fb18c2da7dddd7cf7dacb28b599b [file] [log] [blame]
Louis Dionne5e334b52018-12-21 15:59:041#===-- CMakeLists.txt ----------------------------------------------------===##
2#
Chandler Carruth57b08b02019-01-19 10:56:403# 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 Dionne5e334b52018-12-21 15:59:046#
7#===----------------------------------------------------------------------===##
8
9# TODO(ldionne): This CMake testing infrastructure should be replaced with a
10# llvm-lit test suite.
11
12add_custom_target(pstl-build-tests
13 COMMENT "Build all the pstl tests.")
14
15add_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 Dionne4d88b172019-04-16 14:38:0821add_library(test_stdlib INTERFACE)
22target_include_directories(test_stdlib INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/support/stdlib")
23target_link_libraries(test_stdlib INTERFACE pstl::ParallelSTL)
Louis Dionne5c4c4432019-05-30 20:46:3124target_compile_options(test_stdlib INTERFACE -Wno-gnu-include-next)
Louis Dionne4d88b172019-04-16 14:38:0825
Louis Dionne3b620472019-03-27 21:28:2426file(GLOB_RECURSE UNIT_TESTS "*.pass.cpp")
Louis Dionne5e334b52018-12-21 15:59:0427foreach(_file IN LISTS UNIT_TESTS)
28 file(RELATIVE_PATH _target "${CMAKE_CURRENT_SOURCE_DIR}" "${_file}")
29 string(REPLACE ".cpp" "" _target "${_target}")
Louis Dionne3b620472019-03-27 21:28:2430 string(REPLACE "/" "-" _target "${_target}")
Louis Dionne5e334b52018-12-21 15:59:0431 set(_target "pstl-${_target}")
32
33 add_executable(${_target} EXCLUDE_FROM_ALL "${_file}")
Louis Dionne3b620472019-03-27 21:28:2434 target_include_directories(${_target} PRIVATE "${CMAKE_CURRENT_LIST_DIR}")
Louis Dionne5c4c4432019-05-30 20:46:3135 target_compile_options(${_target} PRIVATE -Wno-unused-local-typedef -Wno-unused-variable)
Louis Dionne4d88b172019-04-16 14:38:0836 target_link_libraries(${_target} PRIVATE test_stdlib)
Louis Dionne5e334b52018-12-21 15:59:0437 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})
41endforeach()