Verify compiler version before building anything (#6293)
authorLoïc Blot <nerzhul@users.noreply.github.com>
Thu, 24 Aug 2017 15:16:55 +0000 (17:16 +0200)
committerGitHub <noreply@github.com>
Thu, 24 Aug 2017 15:16:55 +0000 (17:16 +0200)
GCC 4.9 and Clang 3.4 are the minimum

CMakeLists.txt

index b405d5e2bb9c96dee87a33a14006e9d0d1c9f698..33e7c93b3914f451bc7d9a9186e9ec5dec8bd0bd 100644 (file)
@@ -11,6 +11,8 @@ set(PROJECT_NAME_CAPITALIZED "Minetest")
 
 # Works only for cmake 3.1 and greater
 set(CMAKE_CXX_STANDARD 11)
+set(GCC_MINIMUM_VERSION "4.8")
+set(CLANG_MINIMUM_VERSION "3.4")
 
 # Also remember to set PROTOCOL_VERSION in network/networkprotocol.h when releasing
 set(VERSION_MAJOR 0)
@@ -203,6 +205,23 @@ find_package(GMP REQUIRED)
 find_package(Json REQUIRED)
 find_package(Lua REQUIRED)
 
+# JsonCPP doesn't compile well on GCC 4.8
+if(NOT ENABLE_SYSTEM_JSONCPP)
+       set(GCC_MINIMUM_VERSION "4.9")
+endif()
+
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+       if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${GCC_MINIMUM_VERSION}")
+               message(FATAL_ERROR "Insufficient gcc version, found ${CMAKE_CXX_COMPILER_VERSION}. "
+                       "Version ${GCC_MINIMUM_VERSION} or higher is required.")
+       endif()
+elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+       if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${CLANG_MINIMUM_VERSION}")
+               message(FATAL_ERROR "Insufficient clang version, found ${CMAKE_CXX_COMPILER_VERSION}. "
+                       "Version ${CLANG_MINIMUM_VERSION} or higher is required.")
+       endif()
+endif()
+
 # Subdirectories
 # Be sure to add all relevant definitions above this