1# 2# Copyright (c) 2018 Mateusz Loskot <mateusz at loskot dot net> 3# 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) 7# 8 9# List headers in order: concepts, core, io, extensions 10file(GLOB_RECURSE _hpp_concepts RELATIVE 11 "${CMAKE_SOURCE_DIR}/include/boost/gil" 12 "${CMAKE_SOURCE_DIR}/include/boost/gil/concepts/*.hpp") 13list(APPEND _headers ${_hpp_concepts}) 14 15file(GLOB _hpp_core RELATIVE 16 "${CMAKE_SOURCE_DIR}/include/boost/gil" 17 "${CMAKE_SOURCE_DIR}/include/boost/gil/*.hpp") 18list(APPEND _headers ${_hpp_core}) 19 20list(APPEND _ext_dirs extension/dynamic_image/) 21if(BOOST_GIL_ENABLE_EXT_NUMERIC) 22 list(APPEND _ext_dirs extension/numeric) 23endif() 24if(BOOST_GIL_ENABLE_EXT_TOOLBOX) 25 list(APPEND _ext_dirs extension/toolbox) 26endif() 27if(BOOST_GIL_ENABLE_EXT_IO) 28 list(APPEND _ext_dirs io) 29 list(APPEND _ext_dirs extension/io) 30endif() 31 32foreach(_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}) 37endforeach() 38 39if(NOT BOOST_GIL_ENABLE_EXT_IO_RAW) 40 list(FILTER _headers EXCLUDE REGEX "\\/raw[\\.\\/]") 41endif() 42 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#----------------------------------------------------------------------------- 48message(STATUS "Boost.GIL: Configuring self-contained header tests for all headers") 49add_custom_target(test_headers_self_contained) 50 51file(READ ${CMAKE_CURRENT_LIST_DIR}/main.cpp _main_content) 52 53foreach(_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}) 58 59 string(REPLACE "BOOST_GIL_TEST_HEADER" "${_header}" _content "${_main_content}") 60 file(WRITE ${_cpp} "${_content}") 61 unset(_content) 62 63 add_executable(${_target}) 64 65 target_sources(${_target} 66 PRIVATE 67 ${_cpp} 68 ${CMAKE_SOURCE_DIR}/include/boost/gil/${_header}) 69 unset(_cpp) 70 71 target_link_libraries(${_target} 72 PRIVATE 73 gil_compile_options 74 gil_include_directories 75 gil_dependencies) 76 77 add_dependencies(test_headers_self_contained ${_target}) 78 79 unset(_target) 80endforeach() 81 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#----------------------------------------------------------------------------- 87message(STATUS "Boost.GIL: Configuring all-in-one headers test for all headers") 88 89set(_cpp ${CMAKE_BINARY_DIR}/test/headers/test_headers_all_in_one.cpp) 90file(WRITE ${_cpp} "// All headers included in one translation unit\n") 91foreach(_header ${_headers}) 92 file(APPEND ${_cpp} "#include <boost/gil/${_header}>\n") 93endforeach() 94unset(_headers) 95file(APPEND ${_cpp} "int main() { return 0; }\n") 96 97add_executable(test_headers_all_in_one) 98 99target_sources(test_headers_all_in_one PRIVATE ${_cpp}) 100unset(_cpp) 101 102target_link_libraries(test_headers_all_in_one 103 PRIVATE 104 gil_compile_options 105 gil_include_directories 106 gil_dependencies) 107