From 764880e6cae6d8ffe7d305edba504d1d305ec6d0 Mon Sep 17 00:00:00 2001 From: Simon Gene Gottlieb Date: Wed, 8 Apr 2026 09:50:51 +0200 Subject: [PATCH] feat: option for strict flag usage When compiling yaml-cpp as a root project flags like -Wall -pedantic or -pedantic-error are being set. Some compilers report false positives and/or are not aware of certain flags. While having a strict compile policy is nice and hinders people who are using rare compiler or compiler configurations or sometimes just new compiler. The current workaround is to edit the CMakeLists.txt file and edit out those flags. This patch provides a new mechanism via the option "YAML_CPP_USE_STRICT_FLAGS". The default value is set to ON if it the root project, otherwise OFF. This allows a user to call `cmake -DYAML_CPP_USE_STRICT_FLAGS=OFF .." to deactivate any strict flag settings. log: feat: option for strict flag usage --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f09cc812d..57dc83e41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ option(YAML_CPP_FORMAT_SOURCE "Format source" ${YAML_CPP_MAIN_PROJECT}) option(YAML_CPP_DISABLE_UNINSTALL "Disable uninstallation of yaml-cpp" OFF) option(YAML_USE_SYSTEM_GTEST "Use system googletest if found" OFF) option(YAML_ENABLE_PIC "Use Position-Independent Code " ON) +option(YAML_CPP_USE_STRICT_FLAGS "Uses strict compilation flags e.g.: -Wall" ${YAML_CPP_MAIN_PROJECT}) cmake_dependent_option(YAML_CPP_BUILD_TESTS "Enable yaml-cpp tests" OFF @@ -109,7 +110,7 @@ if (NOT DEFINED CMAKE_CXX_STANDARD) CXX_STANDARD 11) endif() -if(YAML_CPP_MAIN_PROJECT) +if (YAML_CPP_USE_STRICT_FLAGS) target_compile_options(yaml-cpp PRIVATE $<${print-warnings}:-Wall -Wextra -Wshadow -Weffc++ -Wno-long-long>