abseil / abseil/abseil-cpp

[Bug]: Abseil ignores user-specified CMAKE_MSVC_RUNTIME_LIBRARY

オープン
#2,084 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
C++
スター
18.1k
フォーク
3.2k
平均マージ
20時間 36分
マージ済み PR(30日)
1

説明

### Describe the issue

When providing `CMAKE_MSVC_RUNTIME_LIBRARY` either on the CLI or as a cache variable before adding Abseil as a sub project, it has no effect.

This is because Abseil forcibly sets the value of these variables here:
https://github.com/abseil/abseil-cpp/blob/cb9a36d737ceaca2bdb1bc62a20b43ed42ec0ae2/CMakeLists.txt#L61-L68

These should either be changed to cache variables (which always cede to an existing cache variable if one is present, unless using `FORCE` or `INTERNAL`), or the logic should be switched to not run if `CMAKE_MSVC_RUNTIME_LIBRARY` is already defined.

This is semi-mitigated by `ABSL_MSVC_STATIC_RUNTIME` but only if the user intends to use one of Abseil's permutations derived from that variable, so it isn't as flexible.

### Steps to reproduce the problem

Configure abseil via `cmake -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_BUILD_TYPE=Debug -GNinja`.

Observe that any created object files expect to be linked against the debug msvc runtime library, ignoring the user-provided value.

### What version of Abseil are you using?

cb9a36d737ceaca2bdb1bc62a20b43ed42ec0ae2

### What operating system and version are you using?

Windows 11

### What compiler and version are you using?

MSVC 17.14

### What build system are you using?

CMake 3.31

### Additional context

_No response_

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

問題は CMakeLists.txt の 61~68 行目です。まず、CMake のキャッシュ変数の仕組みと FORCE の優先順位を理解してください。ABSL_MSVC_STATIC_RUNTIME 周辺の既存のロジックを確認してください。修正では、CMAKE_MSVC_RUNTIME_LIBRARY を設定する前にすでに設定されているかを確認するか、set() をキャッシュ変数に変更することになる可能性があります。提供されたコマンドで configure を実行し、生成されたビルドファイル内のランタイムライブラリフラグを確認してテストしてください。

索引モデルが issue の本文から書いたものです。

評価

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

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

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