FindPkgConfig does not set INTERFACE_LINK_OPTIONS property on imported targets
For example, when building against SDL2 on Windows (MSYS2 MinGW64), pkg-config --libs-only-other sdl2
gives a -mwindows
linker flag.
Relevant lines from CMakeLists.txt:
find_package(PkgConfig REQUIRED)
pkg_check_modules(sdl2 REQUIRED IMPORTED_TARGET sdl2)
add_executable(hello main.c)
target_link_libraries(hello PkgConfig::sdl2)
With the library configured like this, -mwindows
flag doesn't get passed to the linker when building the executable.
I've encountered this using CMake 3.13.4, but by looking into the sources, it doesn't seem like this behaviour has been changed since that version.
I'd be willing to submit a MR for this, but I might need some guidance on how to properly test it - the fix itself is trivial, but the tests for the IMPORTED_TARGET feature are not as transparent to me.