From 08df0a732d6a7a1ffa643cc0bf6dad99a4632c74 Mon Sep 17 00:00:00 2001
From: Tobias Frisch <tfrisch@uni-koblenz.de>
Date: Mon, 3 May 2021 15:00:03 +0200
Subject: [PATCH] [#15] Added build type detection in cmake to make gcc
 trigger-happy

Signed-off-by: Tobias Frisch <tfrisch@uni-koblenz.de>
---
 CMakeLists.txt       | 9 +++++++++
 src/vkcv/Context.cpp | 8 +++-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 25ccec41..31484bbb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,6 +4,11 @@ project(vkcv)
 set(CMAKE_CXX_STANDARD 17)
 set(CMAKE_CXX_STANDARD_REQUIRED ON)
 
+if (CMAKE_BUILD_TYPE)
+	string(TOLOWER "${CMAKE_BUILD_TYPE}" _vkcv_build_type)
+	set(vkcv_build_${_vkcv_build_type} 1)
+endif()
+
 message("-- Language: [ C++ " ${CMAKE_CXX_STANDARD} " ]")
 
 set(vkcv_config ${PROJECT_SOURCE_DIR}/config)
@@ -15,6 +20,10 @@ set(vkcv_source ${PROJECT_SOURCE_DIR}/src)
 
 set(vkcv_flags ${CMAKE_CXX_FLAGS})
 
+if (vkcv_build_debug)
+	set(vkcv_flags ${vkcv_flags} " -Wextra -Wall -pedantic")
+endif()
+
 include(${vkcv_config}/Sources.cmake)
 include(${vkcv_config}/Libraries.cmake)
 
diff --git a/src/vkcv/Context.cpp b/src/vkcv/Context.cpp
index 4e6bc21a..63b920ba 100644
--- a/src/vkcv/Context.cpp
+++ b/src/vkcv/Context.cpp
@@ -1,8 +1,6 @@
 #include "Context.hpp"
 #include "CoreManager.hpp"
 
-#include <iostream>
-
 namespace vkcv {
 
 	Context::Context(vk::Instance instance, vk::PhysicalDevice physicalDevice, vk::Device device)
@@ -147,7 +145,7 @@ namespace vkcv {
 		vk::PhysicalDevice phyDevice;
 		std::vector<vk::PhysicalDevice> devices = instance.enumeratePhysicalDevices();
 
-		if (devices.size() == 0) {
+		if (devices.empty()) {
 			throw std::runtime_error("failed to find GPUs with Vulkan support!");
 		}
 
@@ -174,7 +172,7 @@ namespace vkcv {
 	/// <param name="physicalDevice"> The physical device. </param>
 	/// <returns></returns>
 	int Context::deviceScore(const vk::PhysicalDevice& physicalDevice) {
-		int score = 0;
+		uint32_t score = 0;
 		vk::PhysicalDeviceProperties properties = physicalDevice.getProperties();
 		std::vector<vk::QueueFamilyProperties> qFamilyProperties = physicalDevice.getQueueFamilyProperties();
 
@@ -229,7 +227,7 @@ namespace vkcv {
 		}
 
 		uint32_t create = queueCount;
-		for (int i = 0; i < qFamilyCandidates.size() && create > 0; i++) {
+		for (uint32_t i = 0; i < qFamilyCandidates.size() && create > 0; i++) {
 			const int maxCreatableQueues = std::min(create, qFamilyCandidates[i].queueCount);		
 			vk::DeviceQueueCreateInfo qCreateInfo(
 				vk::DeviceQueueCreateFlags(),
-- 
GitLab