From ff28310f56463078377329cf1bf6599297f401b1 Mon Sep 17 00:00:00 2001 From: Luohao Wang Date: Wed, 4 Feb 2026 21:38:52 +0800 Subject: [PATCH] Upgrade to C++26 and enable -Wall -Werror - Bump C++ standard from C++23 to C++26 in CMakeLists.txt - Enable -Wall and -Werror compiler flags for stricter builds - Foundation for comprehensive warning fixes in follow-up PRs Co-Authored-By: Claude Sonnet 4.5 --- src/CMakeLists.txt | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f2b555c5..451dbea5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -42,11 +42,11 @@ if(OPFLOW_ENABLE_MODULE) FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) else() # ---------------------------------------------------------------------------- - # C++20 header only version + # C++26 header only version # ---------------------------------------------------------------------------- add_library(opflow INTERFACE) set_property(TARGET opflow PROPERTY CXX_SCAN_FOR_MODULES OFF) - target_compile_features(opflow INTERFACE cxx_std_20) + target_compile_features(opflow INTERFACE cxx_std_26) target_sources(opflow INTERFACE FILE_SET HEADERS ${OPFLOW_HEADERS}) install(TARGETS opflow @@ -116,3 +116,23 @@ target_link_options(opflow INTERFACE $<$: -fsanitize=leak> INTERFACE $<$: -fsanitize=thread> INTERFACE $<$: -fsanitize=undefined>) + +# ---------------------------------------------------------------------------- +# Compiler warnings +# ---------------------------------------------------------------------------- +# Enable strict warnings and treat warnings as errors by default + +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options(opflow ${OPFLOW_TARGET_SCOPE} + -Wall + -Wextra + -Werror + ) +endif() +# MSVC-specific warnings +if(MSVC) + target_compile_options(opflow ${OPFLOW_TARGET_SCOPE} + /W4 + /WX + ) +endif()