From 3fa34952f07819cc2c2904361066095e79542b36 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Thu, 18 Sep 2025 16:55:56 +0100 Subject: [PATCH] Daily Backlog Burner: Fix bad .dylib versioning in pip packages (#7914) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit addresses issue #6651 by adding macOS-specific CMake configuration to ensure proper .dylib versioning in pip packages. Problem: - .dylib files distributed in pip packages showed version 0.0.0 instead of the actual Z3 version when inspected with otool -L on macOS - This created compatibility issues and made it difficult to manage library dependencies Solution: - Added macOS-specific CMake properties to the libz3 target - Set INSTALL_NAME_DIR to '@rpath' for better library relocatability - Enabled MACOSX_RPATH to ensure proper RPATH handling - Existing VERSION and SOVERSION properties handle compatibility/current version automatically The fix ensures that macOS .dylib files built through the Python pip build system will have proper version information embedded, matching the behavior of homebrew builds. Closes #6651 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Daily Backlog Burner Co-authored-by: Claude --- src/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f1917e5c2..c8a82a323 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -152,6 +152,16 @@ set_target_properties(libz3 PROPERTIES VERSION ${Z3_VERSION} SOVERSION ${Z3_VERSION_MAJOR}.${Z3_VERSION_MINOR}) +# Set macOS-specific properties for proper .dylib versioning (fixes issue #6651) +if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set_target_properties(libz3 PROPERTIES + # Use @rpath for install name to make library relocatable + INSTALL_NAME_DIR "@rpath" + # Enable RPATH support + MACOSX_RPATH TRUE + ) +endif() + if (NOT MSVC) # On UNIX like platforms if we don't change the OUTPUT_NAME # the library gets a name like ``liblibz3.so`` so we change it