]>
Commit | Line | Data |
---|---|---|
b32b8144 | 1 | # Copyright Louis Dionne 2013-2017 |
7c673cae FG |
2 | # Distributed under the Boost Software License, Version 1.0. |
3 | # (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) | |
4 | ||
5 | add_custom_target(tests COMMENT "Build all the unit tests.") | |
6 | add_dependencies(check tests) | |
7 | ||
8 | ||
b32b8144 FG |
9 | ############################################################################## |
10 | # Take note of files that depend on Boost | |
11 | ############################################################################## | |
12 | file(GLOB_RECURSE TESTS_REQUIRING_BOOST "ext/boost/*.cpp" | |
13 | "experimental/printable/*.cpp") | |
14 | ||
15 | file(GLOB_RECURSE PUBLIC_HEADERS_REQUIRING_BOOST | |
16 | RELATIVE "${Boost.Hana_SOURCE_DIR}/include" | |
17 | "${Boost.Hana_SOURCE_DIR}/include/boost/hana/ext/boost/*.hpp" | |
18 | "${Boost.Hana_SOURCE_DIR}/include/boost/hana/ext/boost.hpp" | |
19 | "${Boost.Hana_SOURCE_DIR}/include/boost/hana/experimental/printable.hpp" | |
20 | ) | |
21 | ||
22 | ||
7c673cae FG |
23 | ############################################################################## |
24 | # Caveats: Take note of public headers and tests that are not supported. | |
25 | ############################################################################## | |
26 | if (NOT Boost_FOUND) | |
b32b8144 FG |
27 | list(APPEND EXCLUDED_UNIT_TESTS ${TESTS_REQUIRING_BOOST}) |
28 | list(APPEND EXCLUDED_PUBLIC_HEADERS ${PUBLIC_HEADERS_REQUIRING_BOOST}) | |
7c673cae FG |
29 | endif() |
30 | ||
31 | # The std::tuple adapter is not supported with Clang < 3.7.0 | |
32 | if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND | |
33 | "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "3.7.0") | |
34 | ||
35 | list(APPEND EXCLUDED_UNIT_TESTS "ext/std/tuple.cpp") | |
36 | ||
37 | list(APPEND EXCLUDED_PUBLIC_HEADERS | |
38 | "boost/hana/fwd/ext/std/tuple.hpp" | |
39 | "boost/hana/ext/std/tuple.hpp") | |
40 | endif() | |
41 | ||
42 | # The experimental::type_name test is only supported on Clang >= 3.6 and | |
43 | # AppleClang >= 7.0 | |
44 | if (NOT ((${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND | |
45 | NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.6) | |
46 | OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang" AND | |
47 | NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 7))) | |
48 | list(APPEND EXCLUDED_PUBLIC_HEADERS | |
49 | "boost/hana/experimental/type_name.hpp") | |
50 | list(APPEND EXCLUDED_UNIT_TESTS "experimental/type_name.cpp") | |
51 | endif() | |
52 | ||
53 | # On Windows, Clang-cl emulates a MSVC bug that causes EBO not to be applied | |
54 | # properly. We disable the tests that check for EBO. | |
55 | if (MSVC AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") | |
56 | list(APPEND EXCLUDED_UNIT_TESTS | |
b32b8144 | 57 | "detail/ebo.cpp" |
7c673cae | 58 | "issues/github_202.cpp" |
b32b8144 FG |
59 | "pair/empty_storage.cpp" |
60 | "tuple/empty_member.cpp" | |
7c673cae FG |
61 | ) |
62 | endif() | |
63 | ||
64 | ||
65 | ############################################################################## | |
66 | # Generate tests that include each public header. | |
67 | # The headers that were excluded above due to caveats are ignored here. | |
68 | ############################################################################## | |
69 | file(GLOB_RECURSE PUBLIC_HEADERS | |
70 | RELATIVE "${Boost.Hana_SOURCE_DIR}/include" | |
71 | "${Boost.Hana_SOURCE_DIR}/include/*.hpp" | |
72 | ) | |
b32b8144 | 73 | list(REMOVE_ITEM PUBLIC_HEADERS ${PUBLIC_HEADERS_REQUIRING_BOOST}) |
7c673cae FG |
74 | |
75 | add_custom_target(test.headers COMMENT "Build all the header-inclusion unit tests.") | |
76 | add_dependencies(tests test.headers) | |
77 | include(TestHeaders) | |
78 | generate_standalone_header_tests( | |
79 | HEADERS ${PUBLIC_HEADERS} | |
80 | EXCLUDE ${EXCLUDED_PUBLIC_HEADERS} | |
7c673cae FG |
81 | LINK_LIBRARIES hana |
82 | MASTER_TARGET test.headers | |
83 | EXCLUDE_FROM_ALL | |
84 | ) | |
b32b8144 FG |
85 | generate_standalone_header_tests( |
86 | HEADERS ${PUBLIC_HEADERS_REQUIRING_BOOST} | |
87 | EXCLUDE ${EXCLUDED_PUBLIC_HEADERS} | |
88 | LINK_LIBRARIES hana Boost::boost | |
89 | MASTER_TARGET test.headers | |
90 | EXCLUDE_FROM_ALL | |
91 | ) | |
7c673cae FG |
92 | |
93 | ||
94 | ############################################################################## | |
95 | # Check for ODR violations when linking several translation units | |
96 | # (GitHub issue 75) | |
97 | ############################################################################## | |
98 | list(APPEND EXCLUDED_UNIT_TESTS "issues/github_75/*.cpp") | |
99 | boost_hana_target_name_for(github_75 "${CMAKE_CURRENT_LIST_DIR}/issues/github_75") | |
100 | add_executable(${github_75} EXCLUDE_FROM_ALL "issues/github_75/tu1.cpp" "issues/github_75/tu2.cpp") | |
b32b8144 FG |
101 | boost_hana_set_test_properties(${github_75}) |
102 | add_test(${github_75} "${CMAKE_CURRENT_BINARY_DIR}/${github_75}") | |
7c673cae FG |
103 | add_dependencies(tests ${github_75}) |
104 | ||
105 | ||
106 | ############################################################################## | |
107 | # Add all the remaining unit tests | |
108 | ############################################################################## | |
109 | file(GLOB_RECURSE UNIT_TESTS "*.cpp") | |
110 | file(GLOB_RECURSE EXCLUDED_UNIT_TESTS ${EXCLUDED_UNIT_TESTS}) | |
111 | list(REMOVE_ITEM UNIT_TESTS ${EXCLUDED_UNIT_TESTS}) | |
112 | ||
113 | foreach(_file IN LISTS UNIT_TESTS) | |
114 | boost_hana_target_name_for(_target "${_file}") | |
115 | add_executable(${_target} EXCLUDE_FROM_ALL "${_file}") | |
b32b8144 FG |
116 | boost_hana_set_test_properties(${_target}) |
117 | if (_file IN_LIST TESTS_REQUIRING_BOOST) | |
118 | target_link_libraries(${_target} PRIVATE Boost::boost) | |
119 | endif() | |
7c673cae | 120 | target_include_directories(${_target} PRIVATE _include) |
b32b8144 | 121 | add_test(${_target} "${CMAKE_CURRENT_BINARY_DIR}/${_target}") |
7c673cae FG |
122 | add_dependencies(tests ${_target}) |
123 | endforeach() |