pkg_check_modules fails on unmet Requires.private pkg-config requirement
Hello,
While improving the pkg-config file of autotrace as shown here: https://github.com/autotrace/autotrace/blob/8d7c8085c63df41f73f0e4c2c3893d33d03f5755/autotrace.pc.in, it came to my attention that a CMake pkg_check_modules(INKSCAPE_DEP autotrace)
fails when pstoedit
is not provided in the environment, due to the FindPkgConfig.cmake module making two calls to pkg-config, one being with --static
causing the problem.
This should not be fatal as I'm building a shared library and don't need the Requires.private
pkg-config packages in the environment, since the libautotrace.so library already captured these in its binary ELF file (as NEEDED dependencies, with the correct RUNPATH search path).
Here's what it looks like, in an environment containing autotrace but not its transitive dependencies (such as pstoedit), using the following sample CMakeLists.txt:
project(dummy)
cmake_minimum_required(VERSION 3.24)
find_package(PkgConfig REQUIRED)
pkg_check_modules(INKSCAPE_DEP REQUIRED autotrace)
Using the freedesktop pkg-config
:
$ cmake --fresh .
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /gnu/store/1pjxm4facm1xhpqad9b7zzcz789j01qq-profile/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /gnu/store/1pjxm4facm1xhpqad9b7zzcz789j01qq-profile/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /gnu/store/1pjxm4facm1xhpqad9b7zzcz789j01qq-profile/bin/pkg-config (found version "0.29.2")
-- Checking for module 'autotrace'
-- Package 'pstoedit', required by 'autotrace', not found
CMake Error at /gnu/store/1fzd3ak386lgv7zl28j7zqkviv8wkz8d-cmake-minimal-3.24.2/share/cmake-3.24/Modules/FindPkgConfig.cmake:607 (message):
A required package was not found
Call Stack (most recent call first):
/gnu/store/1fzd3ak386lgv7zl28j7zqkviv8wkz8d-cmake-minimal-3.24.2/share/cmake-3.24/Modules/FindPkgConfig.cmake:829 (_pkg_check_modules_internal)
CMakeLists.txt:4 (pkg_check_modules)
-- Configuring incomplete, errors occurred!
See also "/tmp/guix-build-inkscape-1.3.2.drv-0/build2/CMakeFiles/CMakeOutput.log".
$ echo $?
1
Using pkgconf
as pkg-config (symlink):
$ cmake --fresh .
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /gnu/store/hbcrngynpzraz9ciqq12wj6abip4s3rn-profile/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /gnu/store/hbcrngynpzraz9ciqq12wj6abip4s3rn-profile/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /gnu/store/hbcrngynpzraz9ciqq12wj6abip4s3rn-profile/bin/pkg-config (found version "2.1.0")
-- Checking for module 'autotrace'
-- Found autotrace, version 0.40.0
Package pstoedit was not found in the pkg-config search path.
Perhaps you should add the directory containing `pstoedit.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pstoedit', required by 'autotrace', not found
Package pstoedit was not found in the pkg-config search path.
Perhaps you should add the directory containing `pstoedit.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pstoedit', required by 'autotrace', not found
Package pstoedit was not found in the pkg-config search path.
Perhaps you should add the directory containing `pstoedit.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pstoedit', required by 'autotrace', not found
Package pstoedit was not found in the pkg-config search path.
Perhaps you should add the directory containing `pstoedit.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pstoedit', required by 'autotrace', not found
Package pstoedit was not found in the pkg-config search path.
Perhaps you should add the directory containing `pstoedit.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pstoedit', required by 'autotrace', not found
Package pstoedit was not found in the pkg-config search path.
Perhaps you should add the directory containing `pstoedit.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pstoedit', required by 'autotrace', not found
Package pstoedit was not found in the pkg-config search path.
Perhaps you should add the directory containing `pstoedit.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pstoedit', required by 'autotrace', not found
Package pstoedit was not found in the pkg-config search path.
Perhaps you should add the directory containing `pstoedit.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pstoedit', required by 'autotrace', not found
Package pstoedit was not found in the pkg-config search path.
Perhaps you should add the directory containing `pstoedit.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pstoedit', required by 'autotrace', not found
Package pstoedit was not found in the pkg-config search path.
Perhaps you should add the directory containing `pstoedit.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pstoedit', required by 'autotrace', not found
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/guix-build-inkscape-1.3.2.drv-0/build2
$ echo $?
0
$ pkg-config --version
0.29.2
$ pkg-config --short-errors --print-errors --exists --static autotrace
Package 'pstoedit', required by 'autotrace', not found
$ echo $?
1
$ pkgconf --version
2.1.0
$ pkgconf --short-errors --print-errors --exists --static autotrace
Package 'pstoedit', required by 'autotrace', not found
$ echo $?
1