FindPkgConfig: property INTERFACE_LINK_DIRECTORIES is missing for pkg-config IMPORTED_TARGET
My toolchain:
- CMake 3.16.4 on Windows.
- MinGW GCC 9.2.1
- pkg-config 0.29.2
I have build curl library with their CMake and part of it's libcurl.pc
is as follows:
prefix=C:/usr
exec_prefix=${prefix}
libdir=C:/usr/lib
includedir=${prefix}/include
supported_protocols="DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS LDAP POP3 POP3S RTSP SMB SMBS SMTP SMTPS TELNET TFTP"
supported_features="SSL IPv6 libz AsynchDNS NTLM"
Name: libcurl
URL: https://curl.haxx.se/
Description: Library to transfer files with ftp, http, etc.
Version: 7.69.0-DEV
Libs: -L${libdir} -lcurl
Cflags: -I${includedir}
Now I have my own target which has such lines:
cmake_minimum_required(VERSION 3.16)
# [...]
find_package(PkgConfig REQUIRED)
pkg_check_modules(libcurl REQUIRED IMPORTED_TARGET libcurl>=7.17.0)
get_target_property(VAR PkgConfig::libcurl INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "INTERFACE_INCLUDE_DIRECTORIES: ${VAR}")
get_target_property(VAR PkgConfig::libcurl INTERFACE_LINK_LIBRARIES)
message(STATUS "INTERFACE_LINK_LIBRARIES: ${VAR}")
get_target_property(VAR PkgConfig::libcurl INTERFACE_LINK_DIRECTORIES)
message(STATUS "INTERFACE_LINK_DIRECTORIES: ${VAR}")
CMake build log contains:
-- INTERFACE_INCLUDE_DIRECTORIES: C:/usr/include
-- INTERFACE_LINK_LIBRARIES: curl
-- INTERFACE_LINK_DIRECTORIES: VAR-NOTFOUND
My pkg-cofig reports:
> C:\mingw64\mingw64\bin\pkg-config.exe --libs libcurl
-LC:/usr/lib -lcurl
> C:\mingw64\mingw64\bin\pkg-config.exe --cflags libcurl
-IC:/usr/include
When I build my project, I end with: C:/mingw64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.1/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lcurl
.
- curl's
-I
is present in compiler command. - curl's
-L
is not present in linker command - All other library's linker and incldue paths are correct (I use multiple libraries and before adding curl everything worked).
It seems for me that INTERFACE_LINK_DIRECTORIES
somehow doesn't work (it's not found) and the target_link_libraries(my_proj PUBLIC PkgConfig::libcurl)
doesn't forward the linker search path.
Edited by Brad King