diff --git a/modules/compiler/features.cmake b/modules/compiler/features.cmake index 6229fe6..3856a4d 100644 --- a/modules/compiler/features.cmake +++ b/modules/compiler/features.cmake @@ -1 +1,2 @@ -include(features/reflection) \ No newline at end of file +include(features/reflection) +include(features/c++26) \ No newline at end of file diff --git a/modules/features/c++26.cmake b/modules/features/c++26.cmake new file mode 100644 index 0000000..3e039e8 --- /dev/null +++ b/modules/features/c++26.cmake @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.26) +project(TestCXX) + +# Default to C++23 +set(STD_VERSION 23) + +# Check if the compiler supports C++26 +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag("-std=c++26" COMPILER_SUPPORTS_CXX26) + +if(COMPILER_SUPPORTS_CXX26) + set(STD_VERSION 26) +endif() + +add_executable(${PROJECT_NAME} main.cpp) +target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_${STD_VERSION}) diff --git a/modules/helpers.cmake b/modules/helpers.cmake index 11db264..a20d6c4 100644 --- a/modules/helpers.cmake +++ b/modules/helpers.cmake @@ -23,7 +23,11 @@ function(ConfigureFGLTarget NAME SRC_DIR INCLUDE_DIR) target_compile_definitions(${NAME} PUBLIC "-DFGL_STRICT_WARNINGS=1") endif () - target_compile_features(${NAME} PUBLIC cxx_std_26) + if (COMPILER_SUPPORTS_CXX26) + target_compile_features(${NAME} PUBLIC cxx_std_26) + else () + target_compile_features(${NAME} PUBLIC cxx_std_23) + endif () endfunction() function(SplitDebugSymbols NAME)