cmake_minimum_required(VERSION 3.20) project( modern_cpp_course VERSION 1.0.0 DESCRIPTION "Modern C++ course from basics to C++26" LANGUAGES CXX ) set(CMAKE_CXX_STANDARD 26) 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) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(CourseOptions) include(CourseExercise) add_subdirectory(support) if(COURSE_BUILD_TESTS) include(FetchContent) FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG v1.15.2 ) set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) enable_testing() include(GoogleTest) endif() add_subdirectory(modules) include(Cppcheck) course_add_cppcheck_targets()