From efd3d21b49b31fc3cd79c0cd160a235275ad929c Mon Sep 17 00:00:00 2001
From: vargheseg <vargheseg@users.noreply.github.com>
Date: Mon, 18 Feb 2019 13:30:30 +0100
Subject: [PATCH] Support case insensitive CMAKE_BUILD_TYPE

Cmake treats CMAKE_BUILD_TYPE string as case insensitve. Make the check
for enabling coverage reflect this to make usage less restrictive.
---
 cmake/enable_code_coverage_report.cmake | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/cmake/enable_code_coverage_report.cmake b/cmake/enable_code_coverage_report.cmake
index 44c270d..6f3db2b 100644
--- a/cmake/enable_code_coverage_report.cmake
+++ b/cmake/enable_code_coverage_report.cmake
@@ -27,8 +27,11 @@
 
 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 --coverage")
 
-#The make coverage command is only available in debug mode
-IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
+# The make coverage command is only available in debug mode.  Also
+# factor in that cmake treats CMAKE_BUILD_TYPE string as case
+# insensitive.
+string(TOUPPER ${CMAKE_BUILD_TYPE} build_type_uppercase)
+IF(build_type_uppercase STREQUAL "DEBUG")
   configure_file(cmake/make_coverage.sh.in
     ${PROJECT_BINARY_DIR}/make_coverage.sh @ONLY)
   add_custom_target(coverage
@@ -36,5 +39,5 @@ IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
     COMMENT "Generating test coverage documentation" VERBATIM
     )
-ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
+ENDIF()
 
-- 
GitLab