Imported Upstream version 1.64.0
[platform/upstream/boost.git] / libs / hana / example / CMakeLists.txt
1 # Copyright Louis Dionne 2013-2017
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 ##############################################################################
10 # Caveats: Take note of examples that are not supported.
11 ##############################################################################
12 if (NOT Boost_FOUND)
13     list(APPEND EXCLUDED_EXAMPLES
14         "ext/boost/*.cpp"
15         "tutorial/appendix_mpl.cpp"
16         "tutorial/ext/fusion_to_hana.cpp"
17         "tutorial/ext/mpl_vector.cpp"
18         "tutorial/integral.cpp"
19         "tutorial/introduction.cpp"
20         "tutorial/mpl_cheatsheet.cpp"
21         "tutorial/quadrants.cpp"
22         "tutorial/quickstart.switchAny.cpp"
23         "tutorial/rationale.container.cpp"
24         "tutorial/type.cpp"
25         "type/basic_type.cpp"
26     )
27 endif()
28
29
30 ##############################################################################
31 # Add all the examples
32 ##############################################################################
33 file(GLOB_RECURSE EXAMPLES "*.cpp")
34 file(GLOB_RECURSE EXCLUDED_EXAMPLES ${EXCLUDED_EXAMPLES})
35 list(REMOVE_ITEM EXAMPLES "" ${EXCLUDED_EXAMPLES})
36
37 # Several examples have unused parameters because the name of the parameters
38 # are useful for illustration, even if the implementation is not actually
39 # presented. We don't want to generate warnings for that or need to comment
40 # out all unused parameter names.
41 include(CheckCXXCompilerFlag)
42 check_cxx_compiler_flag(-Wno-unused-parameter BOOST_HANA_HAS_WNO_UNUSED_PARAMETER)
43
44 foreach(_file IN LISTS EXAMPLES)
45     boost_hana_target_name_for(_target "${_file}")
46     add_executable(${_target} EXCLUDE_FROM_ALL "${_file}")
47     add_test(${_target} ${CMAKE_CURRENT_BINARY_DIR}/${_target})
48     boost_hana_set_test_properties(${_target})
49     if (BOOST_HANA_HAS_WNO_UNUSED_PARAMETER)
50         target_compile_options(${_target} PRIVATE -Wno-unused-parameter)
51     endif()
52     add_dependencies(examples ${_target})
53 endforeach()