]>
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(examples COMMENT "Build all the examples.") | |
6 | add_dependencies(check examples) | |
7 | ||
8 | ||
9 | ############################################################################## | |
b32b8144 | 10 | # Take note of files that depend on Boost |
7c673cae | 11 | ############################################################################## |
b32b8144 | 12 | list(APPEND EXAMPLES_REQUIRING_BOOST |
7c673cae FG |
13 | "ext/boost/*.cpp" |
14 | "tutorial/appendix_mpl.cpp" | |
15 | "tutorial/ext/fusion_to_hana.cpp" | |
16 | "tutorial/ext/mpl_vector.cpp" | |
17 | "tutorial/integral.cpp" | |
18 | "tutorial/introduction.cpp" | |
19 | "tutorial/mpl_cheatsheet.cpp" | |
20 | "tutorial/quadrants.cpp" | |
21 | "tutorial/quickstart.switchAny.cpp" | |
22 | "tutorial/rationale.container.cpp" | |
23 | "tutorial/type.cpp" | |
b32b8144 FG |
24 | "type/basic_type.cpp") |
25 | file(GLOB_RECURSE EXAMPLES_REQUIRING_BOOST ${EXAMPLES_REQUIRING_BOOST}) | |
26 | ||
27 | ||
28 | ############################################################################## | |
29 | # Caveats: Take note of examples that are not supported. | |
30 | ############################################################################## | |
31 | if (NOT Boost_FOUND) | |
32 | list(APPEND EXCLUDED_EXAMPLES ${EXAMPLES_REQUIRING_BOOST}) | |
7c673cae FG |
33 | endif() |
34 | ||
b32b8144 FG |
35 | list(APPEND EXCLUDED_EXAMPLES "cmake_integration/main.cpp") |
36 | ||
7c673cae FG |
37 | |
38 | ############################################################################## | |
39 | # Add all the examples | |
40 | ############################################################################## | |
41 | file(GLOB_RECURSE EXAMPLES "*.cpp") | |
42 | file(GLOB_RECURSE EXCLUDED_EXAMPLES ${EXCLUDED_EXAMPLES}) | |
43 | list(REMOVE_ITEM EXAMPLES "" ${EXCLUDED_EXAMPLES}) | |
44 | ||
45 | # Several examples have unused parameters because the name of the parameters | |
46 | # are useful for illustration, even if the implementation is not actually | |
47 | # presented. We don't want to generate warnings for that or need to comment | |
48 | # out all unused parameter names. | |
b32b8144 FG |
49 | include(CheckCXXCompilerFlag) |
50 | check_cxx_compiler_flag(-Wno-unused-parameter BOOST_HANA_HAS_WNO_UNUSED_PARAMETER) | |
7c673cae FG |
51 | |
52 | foreach(_file IN LISTS EXAMPLES) | |
53 | boost_hana_target_name_for(_target "${_file}") | |
54 | add_executable(${_target} EXCLUDE_FROM_ALL "${_file}") | |
b32b8144 FG |
55 | add_test(${_target} "${CMAKE_CURRENT_BINARY_DIR}/${_target}") |
56 | boost_hana_set_test_properties(${_target}) | |
57 | if (_file IN_LIST EXAMPLES_REQUIRING_BOOST) | |
58 | target_link_libraries(${_target} PRIVATE Boost::boost) | |
59 | endif() | |
60 | if (BOOST_HANA_HAS_WNO_UNUSED_PARAMETER) | |
61 | target_compile_options(${_target} PRIVATE -Wno-unused-parameter) | |
62 | endif() | |
7c673cae FG |
63 | add_dependencies(examples ${_target}) |
64 | endforeach() |