[cmake] [macOS] building the shared library does not set `install_name`

未关闭 适合新手
#4,983 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
c, cmake
领域
build-system

调研方向

先比较 CMake 共享库配置与 lib/Makefile 中 macOS 安装名称设置(issue 链接到第 78–83 行)。按照提供的 CMake 构建和安装步骤重现差异,然后使用 otool -D 检查库 ID。完成标准是:使用 CMake 构建的库在 macOS 上具有预期的安装名称行为。

由索引模型根据 Issue 内容生成。

描述

Description

[!NOTE]

This issue applies only to macOS.

When building libzstd shared lib with GNU Make, by default, it sets the install_name for the lib as seen at

https://github.com/meta/zstd/blob/98e7b6ac7a08d9cea44aa7b0f6328e064259e625/lib/Makefile#L78-L83

On the other hand, building libzstd shared lib with CMake, it does not.

Expected behavior

Since make is the main build system for libzstd, CMake should also follow the behavior and set the install_name for the shared lib as well.

Reproduction

  1. Clone the repository: git clone https://github.com/meta/zstd

  2. Change directory to zstd dir: cd zstd

  3. Build: make PREFIX=/opt/libzstd-make

  4. Install: sudo make PREFIX=/opt/libzstd-make install

  5. Print the install_name id: otool -D /opt/libzstd-make/lib/libzstd.1.6.0.dylib

  6. Configure with CMake:

    cmake \
        -DCMAKE_BUILD_TYPE=Release \
        --install-prefix /opt/libzstd-cmake \
        -S . \
        -B /tmp/build-libzstd
    
  7. Build with CMake: cmake --build /tmp/build-libzstd --config Release

  8. Install with CMake: sudo cmake --install /tmp/build-libzstd --config Release

  9. Print the install_name id: otool -D /opt/libzstd-cmake/lib/libzstd.1.6.0.dylib

  10. Check the output of step (5.) is /opt/libzstd-make/lib/libzstd.1.dylib while the output of step (9.) is @rpath/libzstd.1.dylib


[!TIP]

In case there is interest, I already fixed it locally and I can submit a PR for the fix.

主要语言
C
星标
28.1k
派生
2.7k
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

facebook/zstd 的其他 Issue

查看 facebook/zstd 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。