diff --git a/CMakeLists.txt b/CMakeLists.txt index fd94577e8..dae5c5823 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,8 +60,13 @@ option(BOOST_GIL_ENABLE_EXT_RASTERIZATION "Enable Rasterization extension and te option(BOOST_GIL_ENABLE_EXT_IMAGE_PROCESSING "Enable Image Processing extension (!) and tests" ON) option(BOOST_GIL_USE_CONAN "Use Conan to install dependencies" OFF) option(BOOST_GIL_USE_CLANG_TIDY "Set CMAKE_CXX_CLANG_TIDY property on targets to enable clang-tidy linting" OFF) +option(BOOST_GIL_USE_BOOST_FILESYSTEM "Use boost::filesystem, disabling requires CMAKE_CXX_STANDARD >= 17" ON) set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard version to use (default is 14)") +if (NOT BOOST_GIL_USE_BOOST_FILESYSTEM AND CMAKE_CXX_STANDARD LESS 17) + message(FATAL_ERROR "Using std::filesystem requires CMAKE_CXX_STANDARD >= 17") +endif() + #----------------------------------------------------------------------------- # Project #----------------------------------------------------------------------------- @@ -105,13 +110,20 @@ target_compile_options(gil_compile_options $<$,$>:-fstrict-aliasing> $<$,$>,$>>:-Wall -Wconversion -Wextra -Wfloat-equal -Wshadow -Wsign-promo -Wstrict-aliasing -Wunused-parameter -pedantic>) + +if (BOOST_GIL_USE_BOOST_FILESYSTEM) + set(filesystem_definition "BOOST_GIL_USE_BOOST_FILESYSTEM") +else() + set(filesystem_definition "BOOST_GIL_IO_USE_STD_FILESYSTEM") +endif() target_compile_definitions(gil_compile_options INTERFACE $<$:_CRT_NONSTDC_NO_DEPRECATE> $<$:_SCL_SECURE_NO_DEPRECATE> $<$:_CRT_SECURE_NO_WARNINGS> $<$:NOMINMAX> - $<$:BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE>) + $<$:BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE> + ${filesystem_definition}) #----------------------------------------------------------------------------- # Dependency target @@ -140,12 +152,18 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(Boost_USE_STATIC_RUNTIME OFF) endif() -find_package(Boost 1.80.0 REQUIRED COMPONENTS filesystem) +set(Boost_required_components headers) +if (BOOST_GIL_USE_BOOST_FILESYSTEM) + list(APPEND Boost_required_components filesystem) +endif() +find_package(Boost 1.80.0 REQUIRED COMPONENTS ${Boost_required_components}) message(STATUS "Boost.GIL: Using Boost_INCLUDE_DIRS=${Boost_INCLUDE_DIRS}") message(STATUS "Boost.GIL: Using Boost_LIBRARY_DIRS=${Boost_LIBRARY_DIRS}") -target_link_libraries(gil_dependencies INTERFACE Boost::filesystem) - +target_link_libraries(gil_dependencies INTERFACE Boost::headers) +if (BOOST_GIL_USE_BOOST_FILESYSTEM) + target_link_libraries(gil_dependencies INTERFACE Boost::filesystem) +endif() if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") target_link_libraries(gil_dependencies INTERFACE Boost::disable_autolinking) endif()