]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
cmake: test reverse_graph instead of using version
authorMatthew Barr <matthew.barr@intel.com>
Wed, 18 Jan 2017 04:16:18 +0000 (15:16 +1100)
committerMatthew Barr <matthew.barr@intel.com>
Thu, 19 Jan 2017 22:26:34 +0000 (09:26 +1100)
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
cmake/boost.cmake [new file with mode: 0644]
cmake/config.h.in
include/boost-patched/graph/reverse_graph.hpp

index bc60fe4866b7ae9aab9df0fbf7dc4fb02d6d4b1f..97039b13fe64691f148ec4a28f19991b12f841ea 100644 (file)
@@ -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 (file)
index 0000000..3d513de
--- /dev/null
@@ -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 <boost/graph/graph_concepts.hpp>
+#include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/reverse_graph.hpp>
+#include <boost/concept/assert.hpp>
+
+int main(int,char*[])
+{
+  using namespace boost;
+  // Check const reverse_graph
+  {
+    typedef adjacency_list< vecS, vecS, bidirectionalS,
+      property<vertex_color_t, int>,
+      property<edge_weight_t, int>,
+      property<graph_name_t, std::string>
+    > AdjList;
+    typedef reverse_graph<AdjList> Graph;
+    BOOST_CONCEPT_ASSERT(( BidirectionalGraphConcept<Graph> ));
+  }
+  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-patched/graph/reverse_graph.hpp>
+${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
index d8430f2280af0d4c6c10c738641e34aed1666122..c7b577c22bd745fac80222859f147ec30002d4df 100644 (file)
@@ -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
index 07a11f9b9a1f63d9397b1250071987b7ed0eea99..8f98a1d5fff161fb96ed1f0f62d1bbe872aa98f6 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <boost/graph/reverse_graph.hpp>
 
-#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.