From a5036f23685c98546c32ba8270cbcf7bbf7cc2d1 Mon Sep 17 00:00:00 2001 From: Dani Camba Date: Wed, 15 Feb 2023 17:55:36 +0100 Subject: [PATCH] add cmake options to hide warnings if is not main project --- CMakeLists.txt | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d87f43..4596d09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR) project(VulkanBootstrap) +option(VK_BOOTSTRAP_DISABLE_WARNINGS "Enable warnings as errors during compilation" OFF) option(VK_BOOTSTRAP_WERROR "Enable warnings as errors during compilation" OFF) add_library(vk-bootstrap-vulkan-headers INTERFACE) @@ -42,25 +43,27 @@ else() set(VK_BOOTSTRAP_COMPILER_CLANGPP 0) endif() -target_compile_options(vk-bootstrap-compiler-warnings - INTERFACE - $<$,$,${VK_BOOTSTRAP_COMPILER_CLANGPP}>: - -Wall - -Wextra - -Wconversion - -Wsign-conversion> - $<$: - /W4> - ) - -if(VK_BOOTSTRAP_WERROR) +if(NOT VK_BOOTSTRAP_DISABLE_WARNINGS) target_compile_options(vk-bootstrap-compiler-warnings INTERFACE $<$,$,${VK_BOOTSTRAP_COMPILER_CLANGPP}>: - -pedantic-errors> + -Wall + -Wextra + -Wconversion + -Wsign-conversion> $<$: - /WX> + /W4> ) + + if(VK_BOOTSTRAP_WERROR) + target_compile_options(vk-bootstrap-compiler-warnings + INTERFACE + $<$,$,${VK_BOOTSTRAP_COMPILER_CLANGPP}>: + -pedantic-errors> + $<$: + /WX> + ) + endif() endif() target_include_directories(vk-bootstrap PUBLIC