Bug cmake usage of pkg-config is broken
#1
Due to lack of developer area I use this part of the forum.

To make a long story short: the current usage of pkg-config is broken, it just throws results from pkg-config away.

Now a few questions about how to address the problem:

On which platforms is pkg-config expected to exist? I just noticed that some of the Linux Jenkins builds has a private pkg-config. Was it just forgotten to add? Realistically every Linux installation out there will have a copy of it, especially in the light of the fact that kodi relies on a large number of external libraries which will most likely fail to build if pkg-config does not exist. I would make it a hard failure if ${PKG_CONFIG_FOUND} is not set after find_package(PkgConfig),  if "UNIX" is set, which would cover Linux and FreeBSD. cmake will fail anyway for me if pkg-config is moved away. Any opinions on that?

Most of the *.cmale files that make  use of pkg_check_modules should probably be wrapped like:

cmake:

if (PKG_CONFIG_FOUND)
pkg_check_modules(ExtLib extlib QUIET)
else()
find_path(ExtLib_INCLUDE_DIRS NAMES extlib/extlib.h)
find_library(ExtLib_LIBRARIES NAMES extlib libextlib)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ExtLib REQUIRED_VARS ExtLib_LIBRARY ExtLib_INCLUDE_DIRS)
endif()
if (ExtLib_FOUND)
if(NOT TARGET ExtLib::ExtLib)
add_library(ExtLib::ExtLib UNKNOWN IMPORTED)
set_target_properties(ExtLib::ExtLib PROPERTIES IMPORTED_LOCATION "${ExtLib_LIBRARIES}" INTERFACE_INCLUDE_DIRECTORIES "${ExtLib_INCLUDE_DIRS}")
endif()
endif()

So essentially mimic the pkg_check_modules result for remaining systems that do not have pkg-config.

I have to find out of set_target_properties is actually complete, there are likely cases where *_CLAGS and *_LDFLAGS have to be used.

I'm willing to do the conversion, just need some input as stated above.

Thanks.
Reply


Messages In This Thread
cmake usage of pkg-config is broken - by olh_ - 2019-03-21, 17:24
Logout Mark Read Team Forum Stats Members Help
cmake usage of pkg-config is broken0