cmake 3.17.0 generates target-NOTFOUND for configured target

Could you please advise what causes cmake to fail finding existing imported library target when generating build.make _EXTERNAL_OBJECTS list.
cmake generates file


with target shown as NOTFOUND:

     myprjsrc/libmyshared.dll: myprjsrc/CMakeFiles/myshared.dir/build.make
     myprjsrc/libmyshared.dll: **qq-NOTFOUND**

Despite that configuiration-generation was successful and target qq was configured - added, had valid target properties, target_link_libraries linked it successfully and had valid file location and type.
sample code snippet is below.
Note: this build is running on linux and uses mingw64 build chain to cross compile dll to run on Windows. The same cmake code is used for cross compiling to another linux and works fine with .so. However library property IMPORTED_LOCATION ${LIBQQ_LIBRARY} .dll.a or .a file, doesn’t fix the problem.


set(qqShared "qq" CACHE STRING "QQ target name")
# log confirms library target added at ${LIBQQ_LIBRARY} in  ${LIBQQ_LIBRARY_DIRS}
if(NOT TARGET ${qqShared} )
  add_library( ${qqShared} SHARED IMPORTED GLOBAL )  # <---- NOTE
  set_target_properties( ${qqShared} PROPERTIES IMPORTED_LOCATION  ${LIBQQ_LIBRARY} )
  target_include_directories( ${qqShared}
  message(STATUS "<<____ FindQQ cmake Added! Lib '${qqShared}' LIBQQ_LIBRARY '${LIBQQ_LIBRARY}' LIBQQ_LIBRARY_DIRS '${LIBQQ_LIBRARY_DIRS}' ")

  message(....has been already added ...)

#check shows target exists
if(TARGET ${qqShared})


#finds lib and adds target lib ${qqShared}
set(QQ_LIB_NAME qq CACHE STRING "QQ base library name" FORCE ) # used by FindQQ.cmake

#check ${qqShared} target exists before and after target_link_libraries
if(TARGET ${qqShared}) ...
# link top lib myshared with extrernal dependencies

#DEBUG log file check shows correct path  ${LIBQQ_LIBRARY_DIRS}/lib${QQ_LIB_NAME}.dll :
   get_target_property(include_path_defs ${qqShared}  LOCATION )
   file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${qqShared}_target_prop_loc.txt ${include_path_defs})

I worked around this problem by changing library type to STATIC from SHARED:

add_library( ${qqShared} STATIC IMPORTED GLOBAL )

However I need to build dll. there should be no limitation in cmake preventing crosscompile dll. At minimum cmake should generate error during generation time since it is not able to generate build.make and linklibs.rsp files correctly from the target properties. This is because target properties are valid and reflect all target associated commands: INTERFACE_INCLUDE_DIRECTORIES, IMPORTED_LOCATION, etc… were set correctly , target was configured but cmake generated files are invalid with no errors. Is it a bug?

For an imported shared library on Windows, the IMPORTED_IMPLIB property needs to be set with the location of the DLL import library. I’ve opened CMake MR 5096 to mention this in the add_library documentation on imported targets.