Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guard boost::filesystem usage #743

Merged
merged 1 commit into from
May 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -105,13 +110,20 @@ target_compile_options(gil_compile_options
$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>>:-fstrict-aliasing>
$<$<AND:$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>>,$<NOT:$<BOOL:${BOOST_GIL_BUILD_CI}>>>:-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
$<$<CXX_COMPILER_ID:MSVC>:_CRT_NONSTDC_NO_DEPRECATE>
$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_DEPRECATE>
$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>
$<$<CXX_COMPILER_ID:MSVC>:NOMINMAX>
$<$<CXX_COMPILER_ID:MSVC>:BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE>)
$<$<CXX_COMPILER_ID:MSVC>:BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE>
${filesystem_definition})

#-----------------------------------------------------------------------------
# Dependency target
Expand Down Expand Up @@ -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()
Expand Down
Loading