From 8c2e033540ec5eb5601c3e89e18af8ff12a2ffe2 Mon Sep 17 00:00:00 2001 From: Matthew Barr Date: Wed, 18 Jan 2017 15:16:18 +1100 Subject: [PATCH] cmake: test reverse_graph instead of using version It seems that some distros are using a patched Boost 1.62.0 which means our workaround in reverse_graph has a conflict. Add a CMake test to see if we need to use the patched reverse_graph. --- CMakeLists.txt | 1 + cmake/boost.cmake | 41 +++++++++++++++++++ cmake/config.h.in | 2 + include/boost-patched/graph/reverse_graph.hpp | 2 +- 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 cmake/boost.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index bc60fe48..97039b13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,7 @@ if(NOT Boost_FOUND) endif() endif() +include (${CMAKE_MODULE_PATH}/boost.cmake) # -- make this work? set(python_ADDITIONAL_VERSIONS 2.7 2.6) find_package(PythonInterp) diff --git a/cmake/boost.cmake b/cmake/boost.cmake new file mode 100644 index 00000000..3d513deb --- /dev/null +++ b/cmake/boost.cmake @@ -0,0 +1,41 @@ +# Boost 1.62 has a bug that we've patched around, check if it is required +if (Boost_VERSION EQUAL 106200) + set (CMAKE_REQUIRED_INCLUDES ${BOOST_INCLUDEDIR} "${PROJECT_SOURCE_DIR}/include") + set (BOOST_REV_TEST " +#include +#include +#include +#include + +int main(int,char*[]) +{ + using namespace boost; + // Check const reverse_graph + { + typedef adjacency_list< vecS, vecS, bidirectionalS, + property, + property, + property + > AdjList; + typedef reverse_graph Graph; + BOOST_CONCEPT_ASSERT(( BidirectionalGraphConcept )); + } + return 0; +} +") + + CHECK_CXX_SOURCE_COMPILES("${BOOST_REV_TEST}" BOOST_REVGRAPH_OK) + + if (NOT BOOST_REVGRAPH_OK) + message(STATUS "trying patched") + CHECK_CXX_SOURCE_COMPILES(" +#include +${BOOST_REV_TEST}" BOOST_REVGRAPH_PATCH) + endif() + + if (NOT BOOST_REVGRAPH_OK AND NOT BOOST_REVGRAPH_PATCH) + message(FATAL_ERROR "Something is wrong with this copy of boost::reverse_graph") + endif() + + unset (CMAKE_REQUIRED_INCLUDES) +endif () # Boost 1.62.0 diff --git a/cmake/config.h.in b/cmake/config.h.in index d8430f22..c7b577c2 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in @@ -89,3 +89,5 @@ /* define if this is a release build. */ #cmakedefine RELEASE_BUILD +/* define if reverse_graph requires patch for boost 1.62.0 */ +#cmakedefine BOOST_REVGRAPH_PATCH diff --git a/include/boost-patched/graph/reverse_graph.hpp b/include/boost-patched/graph/reverse_graph.hpp index 07a11f9b..8f98a1d5 100644 --- a/include/boost-patched/graph/reverse_graph.hpp +++ b/include/boost-patched/graph/reverse_graph.hpp @@ -5,7 +5,7 @@ #include -#if (BOOST_VERSION == 106200) +#if defined(BOOST_REVGRAPH_PATCH) // Boost 1.62.0 does not implement degree() in reverse_graph which is required // by BidirectionalGraph, so add it.