From 4b951172ccf06922efb4d160e4e038d68cf7d53e Mon Sep 17 00:00:00 2001 From: Axel DeWalt <261959751+axel-dewalt@users.noreply.github.com> Date: Mon, 23 Feb 2026 17:04:55 +0000 Subject: [PATCH 1/2] Add CMake option for toggling strict warnings `-Wall` emits +1400 warnings on MSVC in debug mode. As much of this project is header-only, these carry over into dependent projects when used via CMake external-project/git submodules. This is disruptive to downstream projects using the library. - I propose to add a new CMake option called `REFLECTCPP_STRICT_WARNINGS` to allow controlling these warning flags. - For now, I have made it toggle on/off _all_ the warnings you are setting on your project (you might want to be more selective and allow some warnings in all cases, let me know what you want). - I've also defaulted the option to `OFF`, which I know might break some of your existing processes. Let me know if you want the default to be `ON`. --- CMakeLists.txt | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index daabd7e6..eaece28e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 3.23) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) option(REFLECTCPP_BUILD_SHARED "Build shared library" ${BUILD_SHARED_LIBS}) -option(REFLECTCPP_INSTALL "Install reflect cpp" OFF) +option(REFLECTCPP_STRICT_WARNINGS "Enable strict compiler warnings" OFF) +option(REFLECTCPP_INSTALL "Install reflect cpp" ON) option(REFLECTCPP_ALL_FORMATS "Enable all supported formats" OFF) option(REFLECTCPP_JSON "Enable JSON support" ON) # enabled by default @@ -159,28 +160,31 @@ endif() add_library(reflectcpp::reflectcpp ALIAS reflectcpp) if (MSVC) - target_compile_options(reflectcpp PRIVATE - $<$: - -Wall - > - $<$: - -DNDEBUG - > - ) + if (REFLECTCPP_STRICT_WARNINGS) + target_compile_options(reflectcpp PRIVATE + $<$: + -Wall + > + ) + endif() else() - target_compile_options(reflectcpp PRIVATE - $<$: - -Wall -Wextra -Wpedantic -Wshadow -Wconversion - #-Wnull-dereference -Wold-style-cast - #-g3 -fno-omit-frame-pointer - #-fsanitize=address,undefined - #-fno-sanitize-recover=undefined - > - $<$: - -DNDEBUG - > - ) + if (REFLECTCPP_STRICT_WARNINGS) + target_compile_options(reflectcpp PRIVATE + $<$: + -Wall -Wextra -Wpedantic -Wshadow -Wconversion + #-Wnull-dereference -Wold-style-cast + #-g3 -fno-omit-frame-pointer + #-fsanitize=address,undefined + #-fno-sanitize-recover=undefined + > + ) + endif() endif() +target_compile_options(reflectcpp PRIVATE + $<$: + -DNDEBUG + > +) if(REFLECTCPP_BUILD_SHARED AND REFLECTCPP_USE_BUNDLED_DEPENDENCIES AND _REFLECTCPP_NEEDS_JSON_IMPL) target_compile_definitions(reflectcpp From ade496331c010e7d3add091c6d1936f8d2361482 Mon Sep 17 00:00:00 2001 From: Axel DeWalt <261959751+axel-dewalt@users.noreply.github.com> Date: Mon, 23 Feb 2026 17:15:47 +0000 Subject: [PATCH 2/2] Fix unintentional flipping of REFLECTCPP_INSTALL Probably caused by basing my work on an older copy of main. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eaece28e..a18a82ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) option(REFLECTCPP_BUILD_SHARED "Build shared library" ${BUILD_SHARED_LIBS}) option(REFLECTCPP_STRICT_WARNINGS "Enable strict compiler warnings" OFF) -option(REFLECTCPP_INSTALL "Install reflect cpp" ON) +option(REFLECTCPP_INSTALL "Install reflect cpp" OFF) option(REFLECTCPP_ALL_FORMATS "Enable all supported formats" OFF) option(REFLECTCPP_JSON "Enable JSON support" ON) # enabled by default