Make build type and build.sh case insensitive
authorXy Ziemba <xyziemba@microsoft.com>
Wed, 4 Feb 2015 02:29:51 +0000 (18:29 -0800)
committerXy Ziemba <xyziemba@microsoft.com>
Wed, 4 Feb 2015 02:29:51 +0000 (18:29 -0800)
Before this change, build.sh requires lowercase commands, but
CMAKE_BUILD_TYPE required an uppercase parameter. This fixes that
mismatch by making both case insensitive.

CMakeLists.txt
build.sh

index c7f55e6..c3c15e8 100644 (file)
@@ -82,21 +82,25 @@ if (WIN32)
     set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:RELWITHDEBINFO>:${Definition}>)
   endforeach (Definition ${CLR_DEFINES_RELWITHDEBINFO_INIT})
 
-elseif (CLR_CMAKE_PLATFORM_UNIX)  
+elseif (CLR_CMAKE_PLATFORM_UNIX)
+
+  # Use uppercase CMAKE_BUILD_TYPE for the string comparisons below
+  string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_CMAKE_BUILD_TYPE)
+
   # For single-configuration toolset
   # set the different configuration defines.
-  if (CMAKE_BUILD_TYPE STREQUAL DEBUG)
+  if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG)
     # First DEBUG
     set_property(DIRECTORY  PROPERTY COMPILE_DEFINITIONS ${CLR_DEFINES_DEBUG_INIT})
-  elseif (CMAKE_BUILD_TYPE STREQUAL RELEASE)
+  elseif (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE)
     # Then RELEASE
     set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS ${CLR_DEFINES_RELEASE_INIT})
-  elseif (CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
+  elseif (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
     # And then RELWITHDEBINFO
     set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${CLR_DEFINES_RELWITHDEBINFO_INIT})
-  else (CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
-    message(FATAL_ERROR "Unknown build type! Allowed DEBUG, RELEASE and RELWITHDEBINFO!")
-  endif (CMAKE_BUILD_TYPE STREQUAL DEBUG)
+  else (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
+    message(FATAL_ERROR "Unknown build type! Set CMAKE_BUILD_TYPE to DEBUG, RELEASE and RELWITHDEBINFO!")
+  endif (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG)
 
 endif(WIN32)
 
index 25ee783..45eab58 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -117,7 +117,8 @@ __CleanBuild=false
 
 for i in "$@"
     do
-        case $i in
+        lowerI="$(echo $i | awk '{print tolower($0)}')"
+        case $lowerI in
         -?|-h|--help)
         usage
         exit 1