From 9ade0feebde06085485ccc266a608ce400011df5 Mon Sep 17 00:00:00 2001 From: kj16609 Date: Mon, 17 Nov 2025 04:40:22 -0500 Subject: [PATCH] Fix incorrect cxx26 checking --- modules/features/c++26.cmake | 23 ++++++++++------------- modules/helpers.cmake | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/modules/features/c++26.cmake b/modules/features/c++26.cmake index 3e039e8..e7bf61c 100644 --- a/modules/features/c++26.cmake +++ b/modules/features/c++26.cmake @@ -1,16 +1,13 @@ cmake_minimum_required(VERSION 3.26) -project(TestCXX) -# Default to C++23 -set(STD_VERSION 23) +include(CheckCXXSourceCompiles) -# 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}) +# Test actual compilation of C++26 code +set(CMAKE_REQUIRED_FLAGS "-std=c++26") +check_cxx_source_compiles(" +struct A { + auto operator<=>(const A&) const = default; // C++20/26 feature +}; +int main() { A a,b; return (a <=> b) == 0 ? 0 : 1; } +" HAS_CXX26) +set(CMAKE_REQUIRED_FLAGS "") # reset \ No newline at end of file diff --git a/modules/helpers.cmake b/modules/helpers.cmake index a20d6c4..16ec247 100644 --- a/modules/helpers.cmake +++ b/modules/helpers.cmake @@ -23,7 +23,7 @@ function(ConfigureFGLTarget NAME SRC_DIR INCLUDE_DIR) target_compile_definitions(${NAME} PUBLIC "-DFGL_STRICT_WARNINGS=1") endif () - if (COMPILER_SUPPORTS_CXX26) + if (HAS_CXX26) target_compile_features(${NAME} PUBLIC cxx_std_26) else () target_compile_features(${NAME} PUBLIC cxx_std_23)