From e4f85c2c9a9ace0c822acd93f35736c31f2c1981 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 but 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 CMake option "YAML_CPP_USE_STRICT_FLAGS". The default value is set to ON if its 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 b7dda4b7e..f6415ffcd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,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 @@ -92,7 +93,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>