add an option to enable warnings as errors

This commit is contained in:
SpaceIm 2021-04-16 11:11:05 +02:00 committed by Charles Giessen
parent ef02739a10
commit 6bb00bf694
2 changed files with 14 additions and 4 deletions

View File

@ -54,7 +54,7 @@ jobs:
sudo apt-get install -y vulkan-headers libvulkan-dev xorg-dev sudo apt-get install -y vulkan-headers libvulkan-dev xorg-dev
- name: CMake Configure - 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 - name: CMake Build
run: cmake --build build run: cmake --build build
@ -79,7 +79,7 @@ jobs:
echo "VULKAN_SDK=./Vulkan-Headers" >> $GITHUB_ENV echo "VULKAN_SDK=./Vulkan-Headers" >> $GITHUB_ENV
- name: CMake Configure - 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 - name: CMake Build
run: cmake --build build run: cmake --build build

View File

@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.10 FATAL_ERROR) cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(VulkanBootstrap) project(VulkanBootstrap)
option(VK_BOOTSTRAP_WERROR "Enable warnings as errors during compilation" OFF)
add_library(vk-boostrap-vulkan-headers INTERFACE) add_library(vk-boostrap-vulkan-headers INTERFACE)
set(VK_BOOTSTRAP_VULKAN_HEADER_DIR "" CACHE STRING "Specify the location of the Vulkan-Headers include directory.") 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
$<$<OR:$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>,${VK_BOOTSTRAP_COMPILER_CLANGPP}>: $<$<OR:$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>,${VK_BOOTSTRAP_COMPILER_CLANGPP}>:
-Wall -Wall
-Wextra -Wextra
-pedantic-errors
-Wconversion -Wconversion
-Wsign-conversion> -Wsign-conversion>
$<$<CXX_COMPILER_ID:MSVC>: $<$<CXX_COMPILER_ID:MSVC>:
/WX
/W4> /W4>
) )
if(VK_BOOTSTRAP_WERROR)
target_compile_options(vk-bootstrap-compiler-warnings
INTERFACE
$<$<OR:$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>,${VK_BOOTSTRAP_COMPILER_CLANGPP}>:
-pedantic-errors>
$<$<CXX_COMPILER_ID:MSVC>:
/WX>
)
endif()
target_include_directories(vk-bootstrap PUBLIC target_include_directories(vk-bootstrap PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>) $<INSTALL_INTERFACE:include>)