diff --git a/CMake/FindFreetype.cmake b/CMake/FindFreetype.cmake
index 41029f461330ab23e185ca91a4a8c093944b2d54..7b3b8026383e13b5c6387f176a191dd520da1ada 100644
--- a/CMake/FindFreetype.cmake
+++ b/CMake/FindFreetype.cmake
@@ -174,17 +174,27 @@ mark_as_advanced(
 if(Freetype_FOUND)
   if(NOT TARGET Freetype::Freetype)
     include(vtkDetectLibraryType)
+    set(freetype_library_type UNKNOWN)
     if (FREETYPE_LIBRARY_RELEASE)
-      set(_freetype_library_path "${FREETYPE_LIBRARY_RELEASE}")
-    elseif (FREETYPE_LIBRARY_DEBUG)
-      set(_freetype_library_path "${FREETYPE_LIBRARY_DEBUG}")
-    else ()
-      set(_freetype_library_path "${FREETYPE_LIBRARY}")
+      vtk_detect_library_type(freetype_release_library_type
+        PATH "${FREETYPE_LIBRARY_RELEASE}")
+    endif ()
+    if (FREETYPE_LIBRARY_DEBUG)
+      vtk_detect_library_type(freetype_debug_library_type
+        PATH "${FREETYPE_LIBRARY_DEBUG}")
+    endif ()
+    if (freetype_release_library_type AND freetype_debug_library_type)
+      if (freetype_release_library_type STREQUAL freetype_debug_library_type)
+        set(freetype_library_type "${freetype_release_library_type}")
+      endif ()
+    elseif (freetype_release_library_type)
+      set(freetype_library_type "${freetype_release_library_type}")
+    elseif (freetype_debug_library_type)
+      set(freetype_library_type "${freetype_debug_library_type}")
     endif ()
-    vtk_detect_library_type(freetype_library_type
-      PATH "${_freetype_library_path}")
-    unset(_freetype_library_path)
     add_library(Freetype::Freetype "${freetype_library_type}" IMPORTED)
+    unset(freetype_release_library_type)
+    unset(freetype_debug_library_type)
     unset(freetype_library_type)
     set_target_properties(Freetype::Freetype PROPERTIES
       INTERFACE_INCLUDE_DIRECTORIES "${FREETYPE_INCLUDE_DIRS}")
diff --git a/CMake/FindLibHaru.cmake b/CMake/FindLibHaru.cmake
index 7ef877a49307309232c932576f1641b9ae28564d..1f5b881facca745910c7d1223e6f737b157424d7 100644
--- a/CMake/FindLibHaru.cmake
+++ b/CMake/FindLibHaru.cmake
@@ -45,9 +45,27 @@ if (LibHaru_FOUND)
 
   if (NOT TARGET LibHaru::LibHaru)
     include(vtkDetectLibraryType)
-    vtk_detect_library_type(libharu_library_type
-      PATH "${LibHaru_LIBRARY}")
+    set(libharu_library_type UNKNOWN)
+    if (LibHaru_LIBRARY_RELEASE)
+      vtk_detect_library_type(libharu_release_library_type
+        PATH "${LibHaru_LIBRARY_RELEASE}")
+    endif ()
+    if (LibHaru_LIBRARY_DEBUG)
+      vtk_detect_library_type(libharu_debug_library_type
+        PATH "${LibHaru_LIBRARY_DEBUG}")
+    endif ()
+    if (libharu_release_library_type AND libharu_debug_library_type)
+      if (libharu_release_library_type STREQUAL libharu_debug_library_type)
+        set(libharu_library_type "${libharu_release_library_type}")
+      endif ()
+    elseif (libharu_release_library_type)
+      set(libharu_library_type "${libharu_release_library_type}")
+    elseif (libharu_debug_library_type)
+      set(libharu_library_type "${libharu_debug_library_type}")
+    endif ()
     add_library(LibHaru::LibHaru "${libharu_library_type}" IMPORTED)
+    unset(libharu_release_library_type)
+    unset(libharu_debug_library_type)
     unset(libharu_library_type)
     set_target_properties(LibHaru::LibHaru PROPERTIES
       INTERFACE_INCLUDE_DIRECTORIES "${LibHaru_INCLUDE_DIR}")
