Skip to content

Fix CMake MSVC runtime override when CMAKE_MSVC_RUNTIME_LIBRARY is us…#2107

Open
ishatiwari21 wants to merge 1 commit into
abseil:masterfrom
ishatiwari21:CMAKE
Open

Fix CMake MSVC runtime override when CMAKE_MSVC_RUNTIME_LIBRARY is us…#2107
ishatiwari21 wants to merge 1 commit into
abseil:masterfrom
ishatiwari21:CMAKE

Conversation

@ishatiwari21

Copy link
Copy Markdown

Summary

This PR updates CMakeLists.txt so that CMAKE_MSVC_RUNTIME_LIBRARY is only set when it has not already been defined.

Motivation

Currently, Abseil unconditionally overwrites CMAKE_MSVC_RUNTIME_LIBRARY, preventing users from specifying their preferred MSVC runtime through the command line or the CMake cache. This makes it difficult for projects integrating Abseil to control the runtime library consistently across their build.

Changes

  • Only sets CMAKE_MSVC_RUNTIME_LIBRARY if it is not already defined.
  • Preserves user-provided values passed via the command line or CMake cache.
  • Retains Abseil's existing default behavior when no runtime library is explicitly configured.
  • Continues to respect ABSL_MSVC_STATIC_RUNTIME for selecting the default static or dynamic runtime when no explicit runtime has been provided.

Impact

This change is backward compatible. Existing users who do not explicitly configure CMAKE_MSVC_RUNTIME_LIBRARY will see no behavioral change, while users who do configure it will have their setting preserved.

Fixes #2084.

@google-cla

google-cla Bot commented Jul 12, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Abseil ignores user-specified CMAKE_MSVC_RUNTIME_LIBRARY

1 participant