Skip to content

Fix pkg-config paths for absolute CMake install directories - #611

Open
fhgffy wants to merge 1 commit into
libtom:developfrom
fhgffy:fix-cmake-pkgconfig-absolute-dirs
Open

fhgffy wants to merge 1 commit into
libtom:developfrom
fhgffy:fix-cmake-pkgconfig-absolute-dirs

Conversation

@fhgffy

@fhgffy fhgffy commented Oct 5, 2026

Copy link
Copy Markdown

Summary

Handle absolute CMake install directories in libtommath.pc while preserving the existing prefix-relative form for relative directories.

With BUILD_SHARED_LIBS=ON and an absolute CMAKE_INSTALL_INCLUDEDIR or CMAKE_INSTALL_LIBDIR, installation already places files in the requested directory. The current pkg-config template nevertheless prepends ${prefix}/, producing include/library paths that do not exist. An installed consumer fails to find tommath.h, or fails to link -ltommath when only the library directory is absolute.

The fix computes each pkg-config directory independently. The shared Makefile also uses this template, so its substitutions are updated to preserve its existing byte-for-byte output.

Tests

  • A new shared-build CTest covers relative, absolute, and both mixed directory layouts without performing an installation
  • That regression fails on unchanged production code and passes with the fix
  • Separate installed pkg-config consumers compile, link and run for all four layouts plus custom relative directories
  • A relocated relative installation works with pkg-config's prefix override
  • Existing CMake tests pass in both static and shared modes, as does helper.pl --check-all
  • The actual makefile.shared metadata recipe produces identical output before and after the patch for default and custom prefixes

Tested on Linux x86-64 with GCC 14.2.0, CMake 3.31.6 and pkg-config 1.8.1. Full libtool builds and other platforms were not run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant