]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: check gcc version not release date for libstdc++ saneness
authorKefu Chai <kchai@redhat.com>
Mon, 13 Nov 2017 07:08:18 +0000 (15:08 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 15 Nov 2017 07:22:36 +0000 (15:22 +0800)
there is chance that the release date of a minor or patch version of
libstdc++/gcc is *greater* than that of a major version. so this renders
the existing approach to check the __GLIBCPP__ useless. let's check the
gcc version instead. it's far from a perfect solution. but it's good
enough to cover most cases. assuming that most users use gcc with
libstdc++ comes with it. instead of using 1) gcc with a newer libstdc++,
or 2) clang with a old libstdc++.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/CMakeLists.txt

index 44572cf54fc3af3d4235c43f4fcdfd53c9ef0936..0f239cb6602a73500978aa99f0346dd8b0d39437 100644 (file)
@@ -166,17 +166,12 @@ else()
   set(C_STANDARD_REQUIRED ON)
 endif()
 
-include(CheckCXXSourceCompiles)
-CHECK_CXX_SOURCE_COMPILES("
-int main() {
-#ifdef __GLIBCXX__
-#if __GLIBCXX__ < 20150422ul /* libstdc++ < 5.1.0 */
-#error libstdc++ < 5.1.0 does not confirm to C++11
-#endif
-#endif
-}
-" HAVE_SANE_GLIBCXX)
-if(NOT HAVE_SANE_GLIBCXX)
+
+if(CMAKE_COMPILER_IS_GNUCXX AND
+    CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
+  # this is not always correct, as one can use clang with libstdc++ or
+  # use old gcc with new libstdc++, but it covers the most cases.
+  #
   # libstdc++ 4.9 has O(n) list::size(), and its regex is buggy
   message(WARNING "performance regression is expected due to an O(n) implementation of 'std::list::size()' in libstdc++ older than 5.1.0")
 endif()