Attempt to fix ZLIB CMake logic on Windows
authorReid Kleckner <rnk@google.com>
Sun, 1 Mar 2020 16:45:22 +0000 (08:45 -0800)
committerReid Kleckner <rnk@google.com>
Sun, 1 Mar 2020 16:45:24 +0000 (08:45 -0800)
CMake doesn't seem to like it when you regex search for "^".

llvm/lib/Support/CMakeLists.txt

index cf6ce98..77b507d 100644 (file)
@@ -198,10 +198,12 @@ if(LLVM_ENABLE_ZLIB)
     get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION)
   endif()
   get_filename_component(zlib_library ${zlib_library} NAME)
-  if(zlib_library MATCHES "^${CMAKE_STATIC_LIBRARY_PREFIX}.*${CMAKE_STATIC_LIBRARY_SUFFIX}$")
+  if(CMAKE_STATIC_LIBRARY_PREFIX AND
+     zlib_library MATCHES "^${CMAKE_STATIC_LIBRARY_PREFIX}.*${CMAKE_STATIC_LIBRARY_SUFFIX}$")
     STRING(REGEX REPLACE "^${CMAKE_STATIC_LIBRARY_PREFIX}" "" zlib_library ${zlib_library})
     STRING(REGEX REPLACE "${CMAKE_STATIC_LIBRARY_SUFFIX}$" "" zlib_library ${zlib_library})
-  elseif(zlib_library MATCHES "^${CMAKE_SHARED_LIBRARY_PREFIX}.*${CMAKE_SHARED_LIBRARY_SUFFIX}$")
+  elseif(CMAKE_SHARED_LIBRARY_PREFIX AND
+         zlib_library MATCHES "^${CMAKE_SHARED_LIBRARY_PREFIX}.*${CMAKE_SHARED_LIBRARY_SUFFIX}$")
     STRING(REGEX REPLACE "^${CMAKE_SHARED_LIBRARY_PREFIX}" "" zlib_library ${zlib_library})
     STRING(REGEX REPLACE "${CMAKE_SHARED_LIBRARY_SUFFIX}$" "" zlib_library ${zlib_library})
   endif()