2 # Copyright (c) 2018 Mateusz Loskot <mateusz at loskot dot net>
4 # Distributed under the Boost Software License, Version 1.0.
5 # (See accompanying file LICENSE_1_0.txt or copy at
6 # http://www.boost.org/LICENSE_1_0.txt)
9 # List headers in order: concepts, core, io, extensions
10 file(GLOB_RECURSE _hpp_concepts RELATIVE
11 "${CMAKE_SOURCE_DIR}/include/boost/gil"
12 "${CMAKE_SOURCE_DIR}/include/boost/gil/concepts/*.hpp")
13 list(APPEND _headers ${_hpp_concepts})
15 file(GLOB _hpp_core RELATIVE
16 "${CMAKE_SOURCE_DIR}/include/boost/gil"
17 "${CMAKE_SOURCE_DIR}/include/boost/gil/*.hpp")
18 list(APPEND _headers ${_hpp_core})
20 list(APPEND _ext_dirs extension/dynamic_image/)
21 if(GIL_ENABLE_EXT_NUMERIC)
22 list(APPEND _ext_dirs extension/numeric)
24 if(GIL_ENABLE_EXT_TOOLBOX)
25 list(APPEND _ext_dirs extension/toolbox)
28 list(APPEND _ext_dirs io)
29 list(APPEND _ext_dirs extension/io)
32 foreach(_dir ${_ext_dirs})
33 file(GLOB_RECURSE _hpp RELATIVE
34 "${CMAKE_SOURCE_DIR}/include/boost/gil"
35 "${CMAKE_SOURCE_DIR}/include/boost/gil/${_dir}/*.hpp")
36 list(APPEND _headers ${_hpp})
39 if(NOT GIL_ENABLE_EXT_IO_RAW)
40 list(FILTER _headers EXCLUDE REGEX "\\/raw[\\.\\/]")
43 #-----------------------------------------------------------------------------
44 # Target: test_headers_self_contained
45 # Bundles all targets of self-contained header tests,
46 # functional equivalent to self-contained header tests defined in Jamfile.
47 #-----------------------------------------------------------------------------
48 message(STATUS "Boost.GIL: Configuring self-contained header tests for all headers")
49 add_custom_target(test_headers_self_contained)
51 file(READ ${CMAKE_CURRENT_LIST_DIR}/main.cpp _main_content)
53 foreach(_header ${_headers})
54 string(REPLACE ".hpp" "" _target ${_header})
55 string(REPLACE "/" "-" _target ${_target})
56 set(_cpp ${CMAKE_BINARY_DIR}/test/headers/${_target}.cpp)
57 set(_target test_header_${_target})
59 string(REPLACE "BOOST_GIL_TEST_HEADER" "${_header}" _content "${_main_content}")
60 file(WRITE ${_cpp} "${_content}")
63 add_executable(${_target})
65 target_sources(${_target}
68 ${CMAKE_SOURCE_DIR}/include/boost/gil/${_header})
71 target_link_libraries(${_target}
74 gil_include_directories
77 add_dependencies(test_headers_self_contained ${_target})
82 #-----------------------------------------------------------------------------
83 # Target: test_headers_all_in_one
84 # Verifies compilation of all headers included in one translation unit.
85 # An extra advantage is that such translation unit can be analysed with clang-tidy, etc.
86 #-----------------------------------------------------------------------------
87 message(STATUS "Boost.GIL: Configuring all-in-one headers test for all headers")
89 set(_cpp ${CMAKE_BINARY_DIR}/test/headers/test_headers_all_in_one.cpp)
90 file(WRITE ${_cpp} "// All headers included in one translation unit\n")
91 foreach(_header ${_headers})
92 file(APPEND ${_cpp} "#include <boost/gil/${_header}>\n")
95 file(APPEND ${_cpp} "int main() { return 0; }\n")
97 add_executable(test_headers_all_in_one)
99 target_sources(test_headers_all_in_one PRIVATE ${_cpp})
102 target_link_libraries(test_headers_all_in_one
105 gil_include_directories