FindPkgConfig returns wrong results if it returns a static library
I'm looking for OpenSSL, and the relevant cache results are
_OPENSSL_LDFLAGS:INTERNAL=-L/opt/emlix/master/lib;-lssl;-lcrypto
_OPENSSL_LDFLAGS_OTHER:INTERNAL=
_OPENSSL_STATIC_LDFLAGS:INTERNAL=-L/opt/emlix/master/lib;-lssl;-lcrypto;-lz;-ldl;-pthread
_OPENSSL_STATIC_LDFLAGS_OTHER:INTERNAL=-pthread
The problem is that in _pkg_find_libs()
we iterate through ${_prefix}_LDFLAGS
and do not check if the result is static, and use ${_prefix}_STATIC_LDFLAGS
instead. This is not simple: even linking to a dynamic library may return static dependencies. The best idea I came up with is to look at the first library found only.