--- a/lang/cpp/src/GpgmeppConfig-w32.cmake.in.in
+++ b/lang/cpp/src/GpgmeppConfig-w32.cmake.in.in
@@ -58,18 +58,27 @@ unset(_targetsDefined)
 unset(_targetsNotDefined)
 unset(_expectedTargets)
 
+get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+if(_IMPORT_PREFIX STREQUAL "/")
+  set(_IMPORT_PREFIX "")
+endif()
+
 # Create imported target Gpgmepp
 add_library(Gpgmepp SHARED IMPORTED)
 
 set_target_properties(Gpgmepp PROPERTIES
-  IMPORTED_IMPLIB "@resolved_libdir@/libgpgmepp.dll.a"
-  INTERFACE_INCLUDE_DIRECTORIES "@resolved_includedir@/gpgme++;@resolved_includedir@"
-  INTERFACE_LINK_LIBRARIES "pthread;@resolved_libdir@/libgpgme.dll.a;@LIBASSUAN_LIBS@"
-  IMPORTED_LOCATION "@resolved_bindir@/libgpgmepp-6.dll"
+  IMPORTED_IMPLIB "${_IMPORT_PREFIX}/lib/libgpgmepp.dll.a"
+  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/gpgme++;${_IMPORT_PREFIX}/include"
+  INTERFACE_LINK_LIBRARIES "pthread;${_IMPORT_PREFIX}/lib/libgpgme.dll.a;@LIBASSUAN_LIBS@"
+  IMPORTED_LOCATION "${_IMPORT_PREFIX}/bin/libgpgmepp-6.dll"
 )
 list(APPEND _IMPORT_CHECK_TARGETS Gpgmepp )
-list(APPEND _IMPORT_CHECK_FILES_FOR_Gpgmepp "@resolved_libdir@/libgpgmepp.dll.a" "@resolved_bindir@/libgpgmepp-6.dll" )
+list(APPEND _IMPORT_CHECK_FILES_FOR_Gpgmepp "${_IMPORT_PREFIX}/lib/libgpgmepp.dll.a" "${_IMPORT_PREFIX}/bin/libgpgmepp-6.dll" )
 
+set(_IMPORT_PREFIX)
 
 if(CMAKE_VERSION VERSION_LESS 2.8.12)
   message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
--- a/lang/qt/src/QGpgmeConfig-w32.cmake.in.in
+++ b/lang/qt/src/QGpgmeConfig-w32.cmake.in.in
@@ -58,16 +58,24 @@
 unset(_targetsNotDefined)
 unset(_expectedTargets)
 
+get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+if(_IMPORT_PREFIX STREQUAL "/")
+  set(_IMPORT_PREFIX "")
+endif()
+
 # Create imported target QGpgme
 add_library(QGpgme SHARED IMPORTED)
 
 set_target_properties(QGpgme PROPERTIES
-  IMPORTED_IMPLIB_RELEASE "@resolved_libdir@/libqgpgme.dll.a"
-  INTERFACE_INCLUDE_DIRECTORIES "@resolved_includedir@/qgpgme;@resolved_includedir@"
+  IMPORTED_IMPLIB "${_IMPORT_PREFIX}/lib/libqgpgme.dll.a"
+  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/qgpgme;${_IMPORT_PREFIX}/include"
   INTERFACE_LINK_LIBRARIES "Gpgmepp;Qt5::Core"
-  IMPORTED_LOCATION "@resolved_bindir@/libqgpgme-15.dll"
+  IMPORTED_LOCATION "${_IMPORT_PREFIX}/bin/libqgpgme-15.dll"
 )
-get_target_property(_libpath QGpgme IMPORTED_IMPLIB_RELEASE)
+get_target_property(_libpath QGpgme IMPORTED_IMPLIB)
 get_target_property(_dllpath QGpgme IMPORTED_LOCATION)
 
 list(APPEND _IMPORT_CHECK_TARGETS QGpgme )
@@ -73,6 +81,8 @@
 list(APPEND _IMPORT_CHECK_TARGETS QGpgme )
 list(APPEND _IMPORT_CHECK_FILES_FOR_QGpgme "${_libpath}" "${_dllpath}" )
 
+set(_IMPORT_PREFIX)
+
 if(CMAKE_VERSION VERSION_LESS 2.8.12)
   message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
 endif()
--- a/lang/qt/src/QGpgmeQt6Config-w32.cmake.in.in
+++ b/lang/qt/src/QGpgmeQt6Config-w32.cmake.in.in
@@ -58,16 +58,24 @@
 unset(_targetsNotDefined)
 unset(_expectedTargets)
 
+get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+if(_IMPORT_PREFIX STREQUAL "/")
+  set(_IMPORT_PREFIX "")
+endif()
+
 # Create imported target QGpgmeQt6
 add_library(QGpgmeQt6 SHARED IMPORTED)
 
 set_target_properties(QGpgmeQt6 PROPERTIES
-  IMPORTED_IMPLIB_RELEASE "@resolved_libdir@/libqgpgmeqt6.dll.a"
-  INTERFACE_INCLUDE_DIRECTORIES "@resolved_includedir@/qgpgme;@resolved_includedir@"
+  IMPORTED_IMPLIB "${_IMPORT_PREFIX}/lib/libqgpgmeqt6.dll.a"
+  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/qgpgme;${_IMPORT_PREFIX}/include"
   INTERFACE_LINK_LIBRARIES "Gpgmepp;Qt6::Core"
-  IMPORTED_LOCATION "@resolved_bindir@/libqgpgmeqt6-15.dll"
+  IMPORTED_LOCATION "${_IMPORT_PREFIX}/bin/libqgpgmeqt6-15.dll"
 )
-get_target_property(_libpath QGpgmeQt6 IMPORTED_IMPLIB_RELEASE)
+get_target_property(_libpath QGpgmeQt6 IMPORTED_IMPLIB)
 get_target_property(_dllpath QGpgmeQt6 IMPORTED_LOCATION)
 
 list(APPEND _IMPORT_CHECK_TARGETS QGpgmeQt6 )
@@ -73,6 +81,8 @@
 list(APPEND _IMPORT_CHECK_TARGETS QGpgmeQt6 )
 list(APPEND _IMPORT_CHECK_FILES_FOR_QGpgmeQt6 "${_libpath}" "${_dllpath}" )
 
+set(_IMPORT_PREFIX)
+
 if(CMAKE_VERSION VERSION_LESS 2.8.12)
   message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
 endif()
