diff options
author | Matthias Maennich <maennich@google.com> | 2023-11-21 15:35:34 +0000 |
---|---|---|
committer | Giuliano Procida <gprocida@google.com> | 2023-12-13 11:19:47 +0000 |
commit | c7af6bdc843bbcd3c629190fe4093b9009085c61 (patch) | |
tree | c6b751eae839dbd093c7c693e35304364133f036 | |
parent | 4610b46b005f1d3ecc58405d7fa4562f66115652 (diff) | |
download | stg-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.txt | 11 | ||||
-rw-r--r-- | README.md | 2 |
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) @@ -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* | |