Skip to content

rewrite-install-paths: relocate CVC_DEPS_PREFIX too (fix assimp's absolute zlib export) - #413

Merged
transfix merged 3 commits into
masterfrom
fix/assimp-relocatable-zlib-cmake-export
Jul 26, 2026
Merged

rewrite-install-paths: relocate CVC_DEPS_PREFIX too (fix assimp's absolute zlib export)#413
transfix merged 3 commits into
masterfrom
fix/assimp-relocatable-zlib-cmake-export

Conversation

@transfix

Copy link
Copy Markdown
Owner

Problem

The published assimp bundle's lib/cmake/assimp-6.0/assimpTargets.cmake hardcodes an absolute build-sandbox zlib path in INTERFACE_LINK_LIBRARIES:

INTERFACE_LINK_LIBRARIES "$<$<NOT:$<CONFIG:DEBUG>>:/tmp/cvcpkg-builder/cvcpkg-job-assimp-XXXX/cvcpkg-prefix-assimp-YYYY/lib/libz.so>;...;rt"

Root cause: the recipe builds assimp with -DASSIMP_BUILD_ZLIB=OFF, so assimp's CMake links ${ZLIB_LIBRARIES} — an absolute path from the classic FindZLIB module — and exports it instead of the relocatable ZLIB::ZLIB. That path exists on no consumer, so any downstream find_package(assimp CONFIG) + target_link_libraries(... assimp::assimp) fails to link, locally and in CI. (Worked around defensively in libcvc #158; this fixes the root cause for every consumer.)

Fix

cvc_rewrite_install_paths (auto-run by cvc_cmake_build) already relocates absolute $CVC_INSTALL_DIR paths in installed .pc/.cmake files to a per-file ${CMAKE_CURRENT_LIST_DIR}/${pcfiledir} anchor. It now does the same for $CVC_DEPS_PREFIX paths — the external-dependency absolutes CMake does not relocate. Sound because cvcpkg's flat install co-locates every dependency with the package at the consumer prefix, so both prefixes map to the same anchor. It only fires where such a path literally appears, so it's a no-op for exports that are already clean — fixing the whole class, not just assimp.

Verification

  • A real cvcpkg build assimp with this change produced ${CMAKE_CURRENT_LIST_DIR}/../../../lib/libz.so (no /tmp path, 0 leftover absolutes), and a find_package(assimp) + link consumer built cleanly with no defensive rewrite.
  • New regression test tests/unit/test_rewrite_deps_prefix.py (fails without the fix); existing test_rewrite_readonly_files.py still passes.

After merge: rebuild + republish assimp so the catalog bundle carries the clean export; then libcvc's defensive rewrite becomes a harmless no-op.

transfix added 3 commits July 26, 2026 17:46
…export)

cvc_rewrite_install_paths (run automatically by cvc_cmake_build) rewrote
only absolute $CVC_INSTALL_DIR paths in installed .pc/.cmake files. But a
recipe's exported CMake target can also bake an absolute path to a
DEPENDENCY that lived under $CVC_DEPS_PREFIX at build time — the canonical
case is assimp, built with -DASSIMP_BUILD_ZLIB=OFF, whose CMake links
${ZLIB_LIBRARIES} (an absolute path from the classic FindZLIB module) and
exports THAT into assimpTargets.cmake instead of the relocatable ZLIB::ZLIB.
The path (/tmp/cvcpkg-builder/.../lib/libz.so) exists on no consumer, so any
downstream find_package(assimp CONFIG) + link assimp::assimp fails
everywhere — locally and in CI. (Worked around defensively in libcvc PR #158;
this fixes the root cause for every consumer.)

CMake relocates its OWN paths via ${_IMPORT_PREFIX}; the leak is external
dependency absolutes it does not touch. Extend the helper to rewrite
$CVC_DEPS_PREFIX paths to the same per-file ${CMAKE_CURRENT_LIST_DIR}/pc-file
anchor it already uses for $CVC_INSTALL_DIR — sound because cvcpkg's FLAT
install co-locates every dependency with the package at the consumer prefix.
It only fires where such a path literally appears (a no-op for exports that
are already clean), so it fixes the whole class without touching clean recipes.

Verified: a real 'cvcpkg build assimp' with this change produced an export
with ${CMAKE_CURRENT_LIST_DIR}/../../../lib/libz.so (no /tmp path), and a
find_package(assimp)+link consumer built cleanly with NO defensive rewrite.
New regression test tests/unit/test_rewrite_deps_prefix.py (fails without the
fix); existing rewrite tests still pass.
cvc_rewrite_install_paths is a POSIX build-time shell helper (sourced by
cvc_cmake_build); the CI runs the Python unit suite on windows too, where
bash/the helper do not apply. Guard the module with pytest.mark.skipif.
The +cvc.1 bundle baked an absolute build-sandbox zlib path into
assimpTargets.cmake, so find_package(assimp)+link failed on every consumer.
The shared rewrite-install-paths fix (this PR) makes the export relocatable;
bump so populate-server publishes 6.0.5+cvc.2 carrying the corrected bundle
(the catalog is immutable per version, so a same-revision republish would
409). libcvc's unpinned assimp dep picks up +cvc.2 automatically.
@github-actions

Copy link
Copy Markdown

Dev-cluster recipe build — ⏳ submitted — still building on the cluster (see log); not blocking

Recipes: assimp

build log
DAG pr-413-30223950190-linux-x86_64-release-shared: 1 jobs (linux/x86_64/release/shared)
  Skipping freebsd/x86_64: no registered builder can serve it
  Skipping openbsd/x86_64: no registered builder can serve it
  Skipping netbsd/x86_64: no registered builder can serve it
  Auto-added 3 unpublished dependency(ies) for windows/x86_64/release/shared: curl, openssl, pkg-config
DAG pr-413-30223950190-windows-x86_64-release-shared: 4 jobs (windows/x86_64/release/shared)

Waiting for 2 DAG(s)...
  ✓ #1132 assimp (linux/x86_64): succeeded

4 job(s) still building after 1500s (submitted OK, continuing on the cluster): #1133 assimp, #1134 curl, #1135 openssl, #1136 pkg-config

@transfix
transfix merged commit 977c8b9 into master Jul 26, 2026
24 checks passed
@transfix
transfix deleted the fix/assimp-relocatable-zlib-cmake-export branch August 2, 2026 22:16
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