CMakeLists.txt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. # List headers in order: concepts, core, io, extensions
  9. file(GLOB_RECURSE _hpp_concepts RELATIVE
  10. "${CMAKE_SOURCE_DIR}/include/boost/gil"
  11. "${CMAKE_SOURCE_DIR}/include/boost/gil/concepts/*.hpp")
  12. list(APPEND _headers ${_hpp_concepts})
  13. file(GLOB _hpp_core RELATIVE
  14. "${CMAKE_SOURCE_DIR}/include/boost/gil"
  15. "${CMAKE_SOURCE_DIR}/include/boost/gil/*.hpp")
  16. list(APPEND _headers ${_hpp_core})
  17. list(APPEND _ext_dirs extension/dynamic_image/)
  18. if(GIL_ENABLE_EXT_NUMERIC)
  19. list(APPEND _ext_dirs extension/numeric)
  20. endif()
  21. if(GIL_ENABLE_EXT_TOOLBOX)
  22. list(APPEND _ext_dirs extension/toolbox)
  23. endif()
  24. if(GIL_ENABLE_EXT_IO)
  25. list(APPEND _ext_dirs io)
  26. list(APPEND _ext_dirs extension/io)
  27. endif()
  28. foreach(_dir ${_ext_dirs})
  29. file(GLOB_RECURSE _hpp RELATIVE
  30. "${CMAKE_SOURCE_DIR}/include/boost/gil"
  31. "${CMAKE_SOURCE_DIR}/include/boost/gil/${_dir}/*.hpp")
  32. list(APPEND _headers ${_hpp})
  33. endforeach()
  34. if(NOT GIL_ENABLE_EXT_IO_RAW)
  35. list(FILTER _headers EXCLUDE REGEX "\\/raw[\\.\\/]")
  36. endif()
  37. #-----------------------------------------------------------------------------
  38. # Target: test_headers_self_contained
  39. # Bundles all targets of self-contained header tests,
  40. # functional equivalent to self-contained header tests defined in Jamfile.
  41. #-----------------------------------------------------------------------------
  42. message(STATUS "Boost.GIL: Configuring self-contained header tests for all headers")
  43. add_custom_target(test_headers_self_contained)
  44. file(READ ${CMAKE_CURRENT_LIST_DIR}/main.cpp _main_content)
  45. foreach(_header ${_headers})
  46. string(REPLACE ".hpp" "" _target ${_header})
  47. string(REPLACE "/" "-" _target ${_target})
  48. set(_cpp ${CMAKE_BINARY_DIR}/test/headers/${_target}.cpp)
  49. set(_target test_header_${_target})
  50. string(REPLACE "BOOST_GIL_TEST_HEADER" "${_header}" _content "${_main_content}")
  51. file(WRITE ${_cpp} "${_content}")
  52. unset(_content)
  53. add_executable(${_target})
  54. target_sources(${_target}
  55. PRIVATE
  56. ${_cpp}
  57. ${CMAKE_SOURCE_DIR}/include/boost/gil/${_header})
  58. unset(_cpp)
  59. target_link_libraries(${_target}
  60. PRIVATE
  61. gil_compile_options
  62. gil_include_directories
  63. gil_dependencies)
  64. add_dependencies(test_headers_self_contained ${_target})
  65. unset(_target)
  66. endforeach()
  67. #-----------------------------------------------------------------------------
  68. # Target: test_headers_all_in_one
  69. # Verifies compilation of all headers included in one translation unit.
  70. # An extra advantage is that such translation unit can be analysed with clang-tidy, etc.
  71. #-----------------------------------------------------------------------------
  72. message(STATUS "Boost.GIL: Configuring all-in-one headers test for all headers")
  73. set(_cpp ${CMAKE_BINARY_DIR}/test/headers/test_headers_all_in_one.cpp)
  74. file(WRITE ${_cpp} "// All headers included in one translation unit\n")
  75. foreach(_header ${_headers})
  76. file(APPEND ${_cpp} "#include <boost/gil/${_header}>\n")
  77. endforeach()
  78. unset(_headers)
  79. file(APPEND ${_cpp} "int main() { return 0; }\n")
  80. add_executable(test_headers_all_in_one)
  81. target_sources(test_headers_all_in_one PRIVATE ${_cpp})
  82. unset(_cpp)
  83. target_link_libraries(test_headers_all_in_one
  84. PRIVATE
  85. gil_compile_options
  86. gil_include_directories
  87. gil_dependencies)