Skip to content

Conversation

@olilarkin
Copy link
Member

Configure CMAKE_MSVC_RUNTIME_LIBRARY to use MultiThreaded (static) runtime instead of the default MultiThreadedDLL (dynamic) runtime. This links the C runtime library statically, eliminating the need for vcruntime DLLs at runtime.

  • Enable CMP0091 policy to support CMAKE_MSVC_RUNTIME_LIBRARY
  • Set runtime to /MT for Release, /MTd for Debug configurations

Configure CMAKE_MSVC_RUNTIME_LIBRARY to use MultiThreaded (static)
runtime instead of the default MultiThreadedDLL (dynamic) runtime.
This links the C runtime library statically, eliminating the need
for vcruntime DLLs at runtime.

- Enable CMP0091 policy to support CMAKE_MSVC_RUNTIME_LIBRARY
- Set runtime to /MT for Release, /MTd for Debug configurations
Explicitly set MSVC_RUNTIME_LIBRARY property on bgfx, bx, bimg,
bimg_decode, bimg_encode, and freetype targets to ensure they
all use the static runtime library (/MT for Release, /MTd for Debug).

This ensures consistent runtime linking across the main project
and all third-party dependencies fetched via FetchContent.
Add CMAKE_POLICY_DEFAULT_CMP0091 to ensure the MSVC runtime library
policy is propagated to all subprojects including those added via
FetchContent (bgfx, bx, bimg, freetype).
The runtime library variable must be set before FetchContent targets
are configured, not after. Move the setting to before the
FetchContent_MakeAvailable(bgfx) call so bgfx, bx, bimg, and freetype
all pick up the /MT runtime setting during their configuration.
bgfx's cmake_minimum_required(3.10.2) resets the CMP0091 policy,
so we need to set CMAKE_POLICY_DEFAULT_CMP0091 NEW immediately
before FetchContent_MakeAvailable to ensure the policy is applied
when bgfx is configured.
Add target_compile_options with /MT and /MTd flags directly to each
FetchContent target (bx, bimg, bimg_decode, bimg_encode, bgfx, freetype)
as a more direct approach to ensure static runtime linking.
Add explicit /MT and /MTd compile options via add_compile_options
in compile_flags.cmake so all visage library targets (VisageGraphics,
VisageUtils, VisageUI, VisageWidgets, VisageWindowing, VisageApp)
use the static runtime.
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.

3 participants