CMakeLists: fix import of external jansson and utf8cpp #7982

Open
gerion0 wants to merge 1 commit from gerion0/gentoo-fixes into master

View file

@ -320,8 +320,11 @@ if (WITH_SYSTEM_PROVIDED_3PARTY)
set(GFLAGS_USE_TARGET_NAMESPACE ON)
find_package(gflags REQUIRED)
find_package(PkgConfig)
pkg_check_modules(jansson REQUIRED IMPORTED_TARGET jansson)
add_library(jansson::jansson ALIAS PkgConfig::jansson)
biodranik commented 2024-04-25 08:31:01 +00:00 (Migrated from github.com)
Review

How did it work on other systems without explicit PkgConfig specification? Will it continue to work? Why it doesn't find the library without explicit PkgConfig?

CC @Ferenc-

How did it work on other systems without explicit PkgConfig specification? Will it continue to work? Why it doesn't find the library without explicit PkgConfig? CC @Ferenc-
gerion0 commented 2024-04-25 08:37:39 +00:00 (Migrated from github.com)
Review

Normally, jansson is vendored as a 3party and configured with CMake:
https://github.com/organicmaps/organicmaps/blob/master/3party/CMakeLists.txt#L35

This will continue to work. A jansson installation of a distribution normally contains (just) a pkgconfig file (it's pretty common). See for example the debian package: https://packages.debian.org/bookworm/amd64/libjansson-dev/filelist

Why it doesn't find the library without explicit PkgConfig?

Appearently, CMake's find_package does not search for pkgconfig files. It needs the FindPkgConfig module for that: https://cmake.org/cmake/help/latest/module/FindPkgConfig.html

Normally, jansson is vendored as a 3party and configured with CMake: https://github.com/organicmaps/organicmaps/blob/master/3party/CMakeLists.txt#L35 This will continue to work. A jansson installation of a distribution normally contains (just) a pkgconfig file (it's pretty common). See for example the debian package: https://packages.debian.org/bookworm/amd64/libjansson-dev/filelist > Why it doesn't find the library without explicit PkgConfig? Appearently, CMake's `find_package` does not search for pkgconfig files. It needs the `FindPkgConfig` module for that: https://cmake.org/cmake/help/latest/module/FindPkgConfig.html
biodranik commented 2024-04-25 08:49:44 +00:00 (Migrated from github.com)
Review

Does it mean that on Debian/Ubuntu the current master works with PkgConfig for utf8 even without explicitly writing it in cmake? If yes, why? Could it be that cmake detects some pkgconfig vars/files/configs on Debian/Ubuntu, but doesn't do it on Gentoo for some reason? Maybe some env vars are missing?

cmake has --trace parameter that may be helpful to discover issues with packages.

Does it mean that on Debian/Ubuntu the current master works with PkgConfig for utf8 even without explicitly writing it in cmake? If yes, why? Could it be that cmake detects some pkgconfig vars/files/configs on Debian/Ubuntu, but doesn't do it on Gentoo for some reason? Maybe some env vars are missing? cmake has `--trace` parameter that may be helpful to discover issues with packages.
gerion0 commented 2024-04-25 08:56:53 +00:00 (Migrated from github.com)
Review

Do you mean the test pipeline here? Does it build with or without WITH_SYSTEM_PROVIDED_3PARTY?

Do you mean the test pipeline here? Does it build with or without `WITH_SYSTEM_PROVIDED_3PARTY`?
Ferenc- commented 2024-04-25 13:40:56 +00:00 (Migrated from github.com)
Review

How did it work on other systems without explicit PkgConfig specification?

It's not past tense, it is present. It is still working with WITH_SYSTEM_PROVIDED_3PARTY perfectly fine, if one installs the latest release of jansson on a system. The find_package is looking for janssonConfig.cmake first, and that is by default installed to /usr/local/lib/cmake/jansson/ if you install from source.

> How did it work on other systems without explicit PkgConfig specification? It's not past tense, it is present. It is still working with `WITH_SYSTEM_PROVIDED_3PARTY` perfectly fine, if one installs the latest release of jansson on a system. The `find_package` is looking for `janssonConfig.cmake` first, and that is by default installed to `/usr/local/lib/cmake/jansson/` if you install from source.
find_package(expat CONFIG REQUIRED)
find_package(jansson CONFIG REQUIRED)
find_package(pugixml REQUIRED)
find_package(utf8cpp REQUIRED)
endif()