Update: Using C++26 with contracts enabled

This commit is contained in:
David Gil de Gómez Pérez
2026-08-12 13:47:50 +03:00
parent 206742e9b3
commit 41111dba30
6 changed files with 125 additions and 24 deletions
+19
View File
@@ -12,6 +12,22 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
message(
FATAL_ERROR
"GCC 16+ is required (found ${CMAKE_CXX_COMPILER_VERSION}). "
"Use the 'default' CMake preset or cmake/toolchains/gcc-16.cmake."
)
endif()
else()
message(
FATAL_ERROR
"This project requires GCC 16+. Found compiler: ${CMAKE_CXX_COMPILER_ID}. "
"Select the GCC 16 toolchain / default CMake preset in CLion."
)
endif()
option(COURSE_BUILD_TESTS "Build Google Test exercise targets" ON)
option(COURSE_WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF)
option(COURSE_ENABLE_CONTRACTS "Enable C++26 contracts on GCC 16+" ON)
@@ -37,3 +53,6 @@ if(COURSE_BUILD_TESTS)
endif()
add_subdirectory(modules)
include(Cppcheck)
course_add_cppcheck_targets()