boostorg / gil

Boost.GIL - Generic Image Library | Requires C++14 since Boost 1.80
https://boostorg.github.io/gil
Boost Software License 1.0
178 stars 163 forks source link

fix: Automatic detection of <filesystem> header #684

Closed marco-langer closed 2 years ago

marco-langer commented 2 years ago

Description

PR #636 has added detection for the <filesystem> header, but now examples using the IO extensions can't be compiled with C++11 or C++14 anymore. This PR fixes this issue.

References

Compiling one of the examples, e.g.

g++ x_gradient.cpp -std=c++11 -ljpeg

results in

In file included from ../../boost/libs/gil/include/boost/gil/io/path_spec.hpp:11,
                 from ../../boost/libs/gil/include/boost/gil/io/get_read_device.hpp:13,
                 from ../../boost/libs/gil/include/boost/gil/io/get_reader.hpp:11,
                 from ../../boost/libs/gil/include/boost/gil/extension/io/jpeg/read.hpp:18,
                 from ../../boost/libs/gil/include/boost/gil/extension/io/jpeg.hpp:11,
                 from ../../boost/libs/gil/example/x_gradient.cpp:9:
../../boost/libs/gil/include/boost/gil/io/detail/filesystem.hpp:55:29: error: ‘filesystem’ is not a namespace-name
   55 | namespace filesystem = std::filesystem;
....

Tasklist

mloskot commented 2 years ago

Nice, thanks!

marco-langer commented 2 years ago

I don't understand why it wasn't caught by the tests, are we using BOOST_GIL_IO_USE_BOOST_FILESYSTEM in the test runners?

mloskot commented 2 years ago

@marco-langer

Good question. I don't understand why tests did not catch it. I don't see BOOST_GIL_IO_USE_BOOST_FILESYSTEM defined anywhere.

The GHA basically run b2 test: https://github.com/boostorg/gil/blob/9ecdb876b33e06725b3b81e9db3ad0d9f60c58f7/.github/workflows/ci.yml#L114

which only runs minimal IO test called simple_all_formats: https://github.com/boostorg/gil/blob/9ecdb876b33e06725b3b81e9db3ad0d9f60c58f7/test/extension/io/Jamfile#L36-L44

So, for C++11 and C++14 none of these #define-s should happen https://github.com/boostorg/gil/blob/9ecdb876b33e06725b3b81e9db3ad0d9f60c58f7/include/boost/gil/io/detail/filesystem.hpp#L14-L21

and for simple_all_formats test build for C++11 and C++14, this case should happen: https://github.com/boostorg/gil/blob/9ecdb876b33e06725b3b81e9db3ad0d9f60c58f7/include/boost/gil/io/detail/filesystem.hpp#L36-L38