Skip to content

Commit 1b60fae

Browse files
authored
feat: option for strict flag usage (#1430)
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
1 parent f407cc9 commit 1b60fae

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ option(YAML_CPP_FORMAT_SOURCE "Format source" ${YAML_CPP_MAIN_PROJECT})
2121
option(YAML_CPP_DISABLE_UNINSTALL "Disable uninstallation of yaml-cpp" OFF)
2222
option(YAML_USE_SYSTEM_GTEST "Use system googletest if found" OFF)
2323
option(YAML_ENABLE_PIC "Use Position-Independent Code " ON)
24+
option(YAML_CPP_USE_STRICT_FLAGS "Uses strict compilation flags e.g.: -Wall" ${YAML_CPP_MAIN_PROJECT})
2425

2526
cmake_dependent_option(YAML_CPP_BUILD_TESTS
2627
"Enable yaml-cpp tests" OFF
@@ -92,7 +93,7 @@ if (NOT DEFINED CMAKE_CXX_STANDARD)
9293
CXX_STANDARD 11)
9394
endif()
9495

95-
if(YAML_CPP_MAIN_PROJECT)
96+
if (YAML_CPP_USE_STRICT_FLAGS)
9697
target_compile_options(yaml-cpp
9798
PRIVATE
9899
$<${print-warnings}:-Wall -Wextra -Wshadow -Weffc++ -Wno-long-long>

0 commit comments

Comments
 (0)