aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Maennich <maennich@google.com>2023-11-21 15:35:34 +0000
committerGiuliano Procida <gprocida@google.com>2023-12-13 11:19:47 +0000
commitc7af6bdc843bbcd3c629190fe4093b9009085c61 (patch)
treec6b751eae839dbd093c7c693e35304364133f036
parent4610b46b005f1d3ecc58405d7fa4562f66115652 (diff)
downloadstg-c7af6bdc843bbcd3c629190fe4093b9009085c61.tar.gz
CMake: Enforce minimum build requirements for GCC and Clang
STG is known to build with GCC 11, Clang 15 or any later versions. Hence, update the documentation and enforce the minimum requirements at CMake build time. PiperOrigin-RevId: 584321236 Change-Id: Id44dd9f4fb2ecc445970b32a1c854f0b8422d0e6
-rw-r--r--CMakeLists.txt11
-rw-r--r--README.md2
2 files changed, 12 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5dda38c..bb112da 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,6 +27,17 @@ set(CMAKE_CXX_STANDARD 20)
add_compile_options(-fstrict-enums -Wall -Wextra)
+set(MINIMUM_GNU_VERSION 11)
+set(MINIMUM_Clang_VERSION 15)
+
+# Note, the quotes around the variable are significant. If we use a compiler
+# that does not resolve to a definition above, the empty string corresponds to
+# a version where all components are omitted and hence treated as zero.
+if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${MINIMUM_${CMAKE_CXX_COMPILER_ID}_VERSION}")
+ message(FATAL_ERROR "Unsupported Compiler Version!\n"
+ "Need at least ${CMAKE_CXX_COMPILER_ID} ${MINIMUM_${CMAKE_CXX_COMPILER_ID}_VERSION}")
+endif()
+
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# GCC has problems detecting "no-return" switches and destructors.
add_compile_options(-Wno-return-type)
diff --git a/README.md b/README.md
index da17a12..9906ce8 100644
--- a/README.md
+++ b/README.md
@@ -37,7 +37,7 @@ Instructions are included for local and Docker builds.
### Dependencies
-STG is written in C++20. It is known to compile with GCC 11, Clang 14 or
+STG is written in C++20. It is known to compile with GCC 11, Clang 15 or
later versions.
| *Dependency* | *Debian* | *RedHat* |