From: Kefu Chai Date: Mon, 13 Nov 2017 07:08:18 +0000 (+0800) Subject: cmake: check gcc version not release date for libstdc++ saneness X-Git-Tag: v13.0.1~79^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=306edd149bbdde3ef9da06d9e85db93e2efc28e9;p=ceph.git cmake: check gcc version not release date for libstdc++ saneness 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 --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 44572cf54fc3..0f239cb6602a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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()