--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -583,6 +583,7 @@ if (LLVM_ENABLE_Z3_SOLVER)
   if (NOT Z3_FOUND)
     message(FATAL_ERROR "LLVM_ENABLE_Z3_SOLVER cannot be enabled when Z3 is not available.")
   endif()
+  set(Z3_LIBRARIES z3)
 
   set(LLVM_WITH_Z3 1)
 endif()
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -86,7 +86,7 @@ endif()
 
 # Link Z3 if the user wants to build it.
 if(LLVM_WITH_Z3)
-  set(system_libs ${system_libs} ${Z3_LIBRARIES})
+  set(system_libs ${system_libs} z3)
 endif()
 
 # Override the C runtime allocator on Windows and embed it into LLVM tools & libraries
