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

Boost includes: use BOOST_ALLOW_DEPRECATED_HEADERS to suppress warnings #13021

Merged
merged 2 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions cmake/configure/configure_2_boost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,26 @@ MACRO(FEATURE_BOOST_CONFIGURE_COMMON)
ENDIF()

ENABLE_IF_SUPPORTED(BOOST_CXX_FLAGS "-Wno-unused-local-typedefs")

# At least BOOST 1.74 has the problem that some of the BOOST headers
# include other BOOST headers that are deprecated, and this then leads to
# warnings. That's rather annoying.

# The configure function is called only once. In case an externally provided
# boost library is detected, BOOST_INCLUDE_DIRS contains the include paths to
# be used and BOOST_BUNDLED_INCLUDE_DIRS is empty. For the bundled library, it
# is the other way around.
LIST(APPEND CMAKE_REQUIRED_INCLUDES ${BOOST_INCLUDE_DIRS} ${BOOST_BUNDLED_INCLUDE_DIRS})

CHECK_CXX_COMPILER_BUG(
"
#define BOOST_CONFIG_HEADER_DEPRECATED_HPP_INCLUDED
#define BOOST_HEADER_DEPRECATED(a) _Pragma(\"GCC error \\\"stop compilation\\\"\");
#include <boost/geometry/index/rtree.hpp>
int main() { return 0; }
Copy link
Member Author

@tamiko tamiko Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bangerth This isn't particularly pretty but it works: I had to override the BOOST_HEADER_DEPRECATED(a) macro in order to force a compilation error. -Werror doesn't help here because a #pragma message is not a warning...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, clever. That's why my test didn't fail.

"
DEAL_II_BOOST_HAS_BROKEN_HEADER_DEPRECATIONS)
RESET_CMAKE_REQUIRED()
ENDMACRO()


Expand Down
6 changes: 6 additions & 0 deletions include/deal.II/base/bounding_box_data_out.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@
#include <deal.II/boost_adaptors/segment.h>

DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
#ifdef DEAL_II_BOOST_HAS_BROKEN_HEADER_DEPRECATIONS
# define BOOST_ALLOW_DEPRECATED_HEADERS
#endif
#include <boost/geometry/index/rtree.hpp>
#ifdef DEAL_II_BOOST_HAS_BROKEN_HEADER_DEPRECATIONS
# undef BOOST_ALLOW_DEPRECATED_HEADERS
#endif
#include <boost/geometry/strategies/strategies.hpp>
DEAL_II_ENABLE_EXTRA_DIAGNOSTICS

Expand Down
3 changes: 3 additions & 0 deletions include/deal.II/base/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@
/* cmake/modules/FindSYMENGINE.cmake */
#cmakedefine DEAL_II_SYMENGINE_WITH_LLVM

/* cmake/configure/configure_2_boost.cmake */
#cmakedefine DEAL_II_BOOST_HAS_BROKEN_HEADER_DEPRECATIONS

/* cmake/configure/configure_2_trilinos.cmake */
#cmakedefine DEAL_II_TRILINOS_CXX_SUPPORTS_SACADO_COMPLEX_RAD
#cmakedefine DEAL_II_TRILINOS_WITH_EPETRAEXT
Expand Down
1 change: 0 additions & 1 deletion include/deal.II/grid/grid_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/geometry/index/rtree.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/serialization/array.hpp>
#include <boost/serialization/vector.hpp>
Expand Down
6 changes: 6 additions & 0 deletions include/deal.II/numerics/rtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
* can include rtree.hpp. Otherwise a compilation error within boost
* headers is encountered.
*/
#ifdef DEAL_II_BOOST_HAS_BROKEN_HEADER_DEPRECATIONS
# define BOOST_ALLOW_DEPRECATED_HEADERS
#endif
#include <boost/geometry/index/rtree.hpp>
#ifdef DEAL_II_BOOST_HAS_BROKEN_HEADER_DEPRECATIONS
# undef BOOST_ALLOW_DEPRECATED_HEADERS
#endif
DEAL_II_ENABLE_EXTRA_DIAGNOSTICS

#include <memory>
Expand Down