[llvm] Make ZLIB handling compatible with multi-configuration generators
authorJonas Devlieghere <jonas@devlieghere.com>
Mon, 27 Jul 2020 22:36:16 +0000 (15:36 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Mon, 27 Jul 2020 22:37:18 +0000 (15:37 -0700)
The CMAKE_BUILD_TYPE is only meaningful to single-configuration
generators (such as make and Ninja). For multi-configuration generators
like Xcode and MSVC this variable won't be set, resulting in a CMake
error.

llvm/lib/Support/CMakeLists.txt

index 82b7ceb..7b45dc6 100644 (file)
@@ -200,8 +200,11 @@ add_llvm_component_library(LLVMSupport
 set(llvm_system_libs ${system_libs})
 
 if(LLVM_ENABLE_ZLIB)
-  string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
-  get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION_${build_type})
+  # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators.
+  if(CMAKE_BUILD_TYPE)
+    string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
+    get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION_${build_type})
+  endif()
   if(NOT zlib_library)
     get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION)
   endif()