From 89dc34f0eae30d38bc978601e76117d8ab4d7f4b Mon Sep 17 00:00:00 2001
From: Smilencer <527646889@qq.com>
Date: Mon, 14 Feb 2022 14:21:35 +0800
Subject: [PATCH] fix(build): update GCC and CMake checker  (#1041)

---
 CMakeLists.txt            | 9 ++++++++-
 bin/dsn.cmake             | 4 ++--
 thirdparty/CMakeLists.txt | 8 ++++----
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f449619232..7b3d13f7b5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,11 @@
-cmake_minimum_required(VERSION 3.5.2)
+cmake_minimum_required(VERSION 3.11.0)
+
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+    # require at least gcc 5.4.0
+    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.4.0)
+        message(FATAL_ERROR "GCC version must be at least 5.4.0!")
+    endif ()
+endif ()
 
 project(dsn C CXX)
 
diff --git a/bin/dsn.cmake b/bin/dsn.cmake
index fa7f8774bd..ec925d6c7d 100644
--- a/bin/dsn.cmake
+++ b/bin/dsn.cmake
@@ -260,8 +260,8 @@ function(dsn_setup_compiler_flags)
     # add sanitizer check
     if(DEFINED SANITIZER)
         if(NOT (("${COMPILER_FAMILY}" STREQUAL "clang") OR
-        ("${COMPILER_FAMILY}" STREQUAL "gcc" AND "${COMPILER_VERSION}" VERSION_GREATER "4.8")))
-            message(SEND_ERROR "Cannot use sanitizer without clang or gcc >= 4.8")
+        ("${COMPILER_FAMILY}" STREQUAL "gcc" AND "${COMPILER_VERSION}" VERSION_GREATER "5.4.0")))
+            message(SEND_ERROR "Cannot use sanitizer without clang or gcc >= 5.4.0")
         endif()
 
         message(STATUS "Running cmake with sanitizer=${SANITIZER}")
diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt
index 3f5e8228b6..3cbd5162bd 100644
--- a/thirdparty/CMakeLists.txt
+++ b/thirdparty/CMakeLists.txt
@@ -18,12 +18,12 @@
 ##############################################################################
 
 project(pegasus_thirdparties)
-cmake_minimum_required(VERSION 3.0.2)
+cmake_minimum_required(VERSION 3.11.0)
 
 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
-    # require at least gcc 4.8
-    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
-        message(FATAL_ERROR "GCC version must be at least 4.8!")
+    # require at least gcc 5.4.0
+    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.4.0)
+        message(FATAL_ERROR "GCC version must be at least 5.4.0!")
     endif ()
 endif ()