]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a quick check for matching boost versions. 11024/head
authorDavid Wells <drwells@email.unc.edu>
Fri, 9 Oct 2020 00:58:44 +0000 (20:58 -0400)
committerDavid Wells <drwells@email.unc.edu>
Fri, 9 Oct 2020 01:24:25 +0000 (21:24 -0400)
This addresses a problem a user had recently with inscrutable crashes caused by
mixed boost versions. Credit goes to Daniel Jodlbauer for reporting the issue.

cmake/configure/configure_2_boost.cmake
include/deal.II/base/config.h.in

index 24463063bce8507a4a3837a803108c23eb842916..9386f2f5974edb80b0603e9cd8384789a8cc9177 100644 (file)
@@ -92,6 +92,20 @@ MACRO(FEATURE_BOOST_CONFIGURE_BUNDLED)
   # We need to set this path before calling the configure function
   # to be able to use the include paths in the checks.
   SET(BOOST_BUNDLED_INCLUDE_DIRS ${BOOST_FOLDER}/include)
+  #
+  # We still need the version information, which is set up in the FindBoost
+  # module in the non-bundled case:
+  #
+  FILE(STRINGS "${BOOST_BUNDLED_INCLUDE_DIRS}/boost/version.hpp"
+    BOOST_VERSION_STRING
+    REGEX "#define.*BOOST_VERSION")
+
+  STRING(REGEX REPLACE "^.*BOOST_VERSION.* ([0-9]+).*" "\\1"
+    BOOST_VERSION_NUMBER "${BOOST_VERSION_STRING}"
+    )
+  MATH(EXPR Boost_MAJOR_VERSION "${BOOST_VERSION_NUMBER} / 100000")
+  MATH(EXPR Boost_MINOR_VERSION "${BOOST_VERSION_NUMBER} / 100 % 1000")
+  MATH(EXPR Boost_SUBMINOR_VERSION "${BOOST_VERSION_NUMBER} % 100")
 
   FEATURE_BOOST_CONFIGURE_COMMON()
 
index 48d4bf1a83244d023c223cf8f5538bed558217ce..0c9a16b9f90d031a90790d2416aede06957ff417 100644 (file)
     >=  \
     (major)*10000 + (minor)*100 + (subminor))
 
+/*
+ * boost:
+ */
+#define DEAL_II_BOOST_VERSION_MAJOR @Boost_MAJOR_VERSION@
+#define DEAL_II_BOOST_VERSION_MINOR @Boost_MINOR_VERSION@
+#define DEAL_II_BOOST_VERSION_SUBMINOR @Boost_SUBMINOR_VERSION@
 
 /*
  * Gmsh:
@@ -453,4 +459,21 @@ DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
 #include <deal.II/base/numbers.h>
 #include <deal.II/base/types.h>
 
+/*
+ * Include the boost version header to do a quick version check in case, by
+ * accident, we have configured with one version of boost but are compiling
+ * either the library or an external application with a different version of
+ * boost.
+ */
+#include <boost/version.hpp>
+static_assert(
+  BOOST_VERSION == 100000 * DEAL_II_BOOST_VERSION_MAJOR +
+                     100 * DEAL_II_BOOST_VERSION_MINOR +
+                     DEAL_II_BOOST_VERSION_SUBMINOR,
+  "The version number of boost that you are compiling with does not match the "
+  "version number of boost found during deal.II's configuration step. This "
+  "leads to difficult to understand bugs and is not supported. Please check "
+  "that you have set up your application with the same version of boost as "
+  "deal.II.");
+
 #endif

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.