Skip to content

[Bug]: Abseil ignores user-specified CMAKE_MSVC_RUNTIME_LIBRARY #2084

Description

@Shadows-of-Fire

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:

option(ABSL_MSVC_STATIC_RUNTIME
"Link static runtime libraries"
OFF)
if(ABSL_MSVC_STATIC_RUNTIME)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()

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?

cb9a36d

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions