xiph / xiph/opus

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

Open
#333 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
3.3k
Forks
808
PR merge metrics
No merged PRs in 30d

Description

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()

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in CMakeLists.txt and review the existing CMake 3.1 runtime configuration alongside CMAKE_MSVC_RUNTIME_LIBRARY and its generator-expression documentation. Configure Debug and Release MSVC builds with and without OPUS_STATIC_RUNTIME; done means both static and DLL runtime selections work without changing the non-MSVC build paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cmake
Domain
build-system
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.