Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

CMake Config uses absolute paths.

オープン
#987 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
54/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
cmake
領域
build-system

調査の方向性

CMakeLists.txt から始め、GNUInstallDirs の変数が生成される cjson.cmake、cjson_utils.cmake、cjson-<BUILD_TYPE>.cmake ファイルにどのように反映されるかを調べます。構成変更の前後で生成された import を比較します。別のインストールプレフィックスから、ハードコードされたパスなしでインストール済みの 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 はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

DaveGamble/cJSON のほかの issue

DaveGamble/cJSON の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。