From 6bb00bf694c298478cfc7f0189e44806f6538afa Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Fri, 16 Apr 2021 11:11:05 +0200 Subject: [PATCH] add an option to enable warnings as errors --- .github/workflows/ci_build.yml | 4 ++-- CMakeLists.txt | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci_build.yml b/.github/workflows/ci_build.yml index f2559c0..9a94269 100644 --- a/.github/workflows/ci_build.yml +++ b/.github/workflows/ci_build.yml @@ -54,7 +54,7 @@ jobs: sudo apt-get install -y vulkan-headers libvulkan-dev xorg-dev - name: CMake Configure - run: cmake -Bbuild -DVK_BOOTSTRAP_TEST=ON -DCMAKE_BUILD_TYPE=Debug + run: cmake -Bbuild -DVK_BOOTSTRAP_WERROR=ON -DVK_BOOTSTRAP_TEST=ON -DCMAKE_BUILD_TYPE=Debug - name: CMake Build run: cmake --build build @@ -79,7 +79,7 @@ jobs: echo "VULKAN_SDK=./Vulkan-Headers" >> $GITHUB_ENV - name: CMake Configure - run: cmake -Bbuild -DVK_BOOTSTRAP_TEST=ON -DCMAKE_BUILD_TYPE=Debug + run: cmake -Bbuild -DVK_BOOTSTRAP_WERROR=ON -DVK_BOOTSTRAP_TEST=ON -DCMAKE_BUILD_TYPE=Debug - name: CMake Build run: cmake --build build diff --git a/CMakeLists.txt b/CMakeLists.txt index 8766779..ab1d8ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR) project(VulkanBootstrap) +option(VK_BOOTSTRAP_WERROR "Enable warnings as errors during compilation" OFF) + add_library(vk-boostrap-vulkan-headers INTERFACE) set(VK_BOOTSTRAP_VULKAN_HEADER_DIR "" CACHE STRING "Specify the location of the Vulkan-Headers include directory.") @@ -43,14 +45,22 @@ target_compile_options(vk-bootstrap-compiler-warnings $<$,$,${VK_BOOTSTRAP_COMPILER_CLANGPP}>: -Wall -Wextra - -pedantic-errors -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() + target_include_directories(vk-bootstrap PUBLIC $ $)