From c86a9e424c5ee48e04e0412e9edf44f758e38fb9 Mon Sep 17 00:00:00 2001 From: Baruch Date: Tue, 20 Sep 2022 08:22:11 +0300 Subject: [PATCH] Minimize warnings when not the top-level project (#1124) Minimize warnings when not the top-level project Should fix #970 and #764 when trying to add yaml-cpp to other project --- CMakeLists.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 638ced9..f2c3c62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,11 +106,15 @@ if (NOT DEFINED CMAKE_CXX_STANDARD) CXX_STANDARD 11) endif() +if(YAML_CPP_MAIN_PROJECT) + target_compile_options(yaml-cpp + PRIVATE + $<${not-msvc}:-Wall -Wextra -Wshadow -Weffc++ -Wno-long-long> + $<${not-msvc}:-pedantic -pedantic-errors>) +endif() + target_compile_options(yaml-cpp PRIVATE - $<${not-msvc}:-Wall -Wextra -Wshadow -Weffc++ -Wno-long-long> - $<${not-msvc}:-pedantic -pedantic-errors> - $<$:-MTd> $<$:-MT> $<$:-MDd>