abseil / abseil/abseil-cpp

[Bug]: Abseil ignores user-specified CMAKE_MSVC_RUNTIME_LIBRARY

Ouverte
#2,084 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
C++
Étoiles
18.1k
Forks
3.2k
Merge moyen
20 h 36 min
PR mergées (30 j)
1

Description

### 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_

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Le problème se trouve dans CMakeLists.txt, lignes 61-68. Commencez par comprendre le fonctionnement des variables du cache de CMake et la priorité de FORCE. Examinez la logique existante autour de ABSL_MSVC_STATIC_RUNTIME. La correction consiste probablement à vérifier si CMAKE_MSVC_RUNTIME_LIBRARY est déjà défini avant de le définir, ou à modifier set() pour utiliser une variable du cache. Testez cela en configurant avec la commande fournie et en vérifiant l’indicateur de bibliothèque d’exécution dans les fichiers de build générés.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
cmake, cpp
Domaine
build-system
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
Calme
Clarté
Clairement spécifiée
Accessibilité débutants
65/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.