Fix incorrect cxx26 checking
This commit is contained in:
@@ -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
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user