CMake Config uses absolute paths.
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 54/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- cmake
- 领域
- build-system
调研方向
从 CMakeLists.txt 开始,检查 GNUInstallDirs 变量如何传递到生成的 cjson.cmake、cjson_utils.cmake 和 cjson-<BUILD_TYPE>.cmake 文件中。比较配置更改前后的生成导入;当已安装的 cJSON 软件包可以从另一个安装前缀中找到且不包含硬编码路径时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Out of the box it is not possible to import cjson using find_package cmake command If you have not build the library yourself. This is due to the CMakeLists.txt file using CMAKE_INSTALL_FULL_* variables from GNUInstallDirs module which according to the documentation should not be used on install() commands.
In any case the fix is simple, just replace CMAKE_INSTALL_FULL_* variables with their relative counterparts (i.e., CMAKE_INSTALL_LIBDIR, CMAKE_INSTALL_BINDIR, etc.)
If you want a little bit more detail. What happens is that if you use the FULL variables in install commands. The cmake config files will use the FULL path as the installation prefix instead of calculating the path at runtime base on the file location. You can see this in the cjson.cmake file (more or less line 48) and in cjson_utils.cmake where when using the FULL variant the code looks like this:
# The installation prefix configured by this project.
set(_IMPORT_PREFIX "/<my-person-install>/cjson/cjson-1.7.19/")
While when using the relative paths it looks like this:
# Compute the installation prefix relative to this file.
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
if(_IMPORT_PREFIX STREQUAL "/")
set(_IMPORT_PREFIX "")
endif()
You can also see it on the cjson-<BUILD_TYPE>.cmake Where the IMPORTED_LOCATION_<BUILD_TYPE> will be the FULL path and if using the relative path variables it will just use the calculated _IMPORT_PREFIX instead.
If you want I can make a pull request with this simple fix. 😅
PS. This does not affect CJSON_INCLUDE_DIRS and CJSON_INCLUDE_DIR variables. Those still have the full path.
- 主要语言
- C
- 星标
- 13k
- 派生
- 3.5k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
DaveGamble/cJSON 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 86/100
DaveGamble/cJSON#1094 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
DaveGamble/cJSON#1093 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
DaveGamble/cJSON#1082 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
DaveGamble/cJSON#1081 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
DaveGamble/cJSON#1074 ·
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
python-pillow/Pillow#10087 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
OpenPrinting/cups#1729 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
awslabs/amazon-kinesis-video-streams-webrtc-sdk-c#2406 ·
维护者通常 2 天内回复
-
status:needs-triage
难度 2/5 1-3 小时 新手友好度 90/100
PX4/PX4-Autopilot#28923 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复