Skip to content

Compiling with CMake for Windows/MSVC only supports DLL runtime libraries #333

@Malcolmnixon

Description

@Malcolmnixon

I'm attempting to consume opus as a git submodule from an official tag, and build a Godot extension cross-compiling for Windows, Linux, and Android.

The current CMakeLists.txt targets cmake 3.1 which hard-codes the C runtime library to either MultiThreadedDebugDLL or MultiThreadedDLL. The resulting code therefore has to ship the Microsoft runtime library DLL.

Upgrading CMakeLists.txt to cmake_minimum_required(VERSION 3.15) unlocks the options for specifying the runtime library options on the command-line such as cmake -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded .

It would be preferable to support an OPUS_STATIC_RUNTIME option, which for MSVC would use CMAKE_MSVC_RUNTIME_LIBRARY Generator Expressions to correctly specify the Debug or Release Static or DLL runtimes.

Possibly something like:

if(MSVC)
  if(OPUS_STATIC_RUNTIME)
    set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
  else()
    set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
  endif()
endif()

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