Can't force find_library to find .dll suffix

When executing find_library in
find_library(PostgreSQL_LIBRARIES NAMES libpq.dll pq
PATHS
“${PQ_ROOT}/src/interfaces/libpq”
NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH

)
it debug report indicate
VAR: PostgreSQL_LIBRARIES
NAMES: “libpq.dll”
“pq”

find_library considered the following locations:

…postgresql-9.3.6/src/interfaces/libpq/(lib|)libpq.dll(.dll.a|.a|.lib)
The item was found at
…postgresql-9.3.6/src/interfaces/libpq/libpq.a
So it finds only static and ignores .dll.
If “pq” is removed , the library is not being found:
VAR: PostgreSQL_LIBRARIES
NAMES: “libpq.dll”

…/postgresql-9.3.6/src/interfaces/libpq/(lib|)libpq.dll(.dll.a|.a|.lib)
The item was not found despite valid file is there
Why is .dll ignored and how to force cmake to find it?

Under Windows, you don’t link against the DLL file but against a stub .lib file. The DLL is used only when running the application. That’s probably what cmake searches for.

This is not “under Windows”, but on Linux cross compiling to run on Windows target using mingw64 toolchain. So the dependent library libpq.dll is built 1st and then libpqxx library also has to be built on Linux, It will be used in the emulator wine and on Windows 10.
Additional info: Te issue is that when building libpqxx (with libpq as dependent) error comes up:
Linking CXX shared library libpqxx.dll
CMakeFiles/pqxx_shared.dir/objects.a(connection_base.cxx.obj):connection_base.cxx:(.text+0x8eac): undefined reference to `__imp_select’

Thanks, does it mean that for cross compiling the library property LOCATION should be library .dll.a file, not .dll file?

For MinGW environments (cross or native), the IMPORTED_IMPLIB property should be set to the .dll.a file.