Skip to content

Commit cbeebf0

Browse files
Malcolmnixonjmvalin
authored andcommitted
Update cmake to 3.16 and add OPUS_STATIC_RUNTIME option to control MSVC runtime library choice.
Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca>
1 parent 0e30966 commit cbeebf0

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

.github/workflows/cmake.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ on: [push, pull_request]
44

55
jobs:
66
CMakeVersionTest:
7-
name: Test build with CMake 3.1.0
7+
name: Test build with CMake 3.16.0
88
runs-on: ubuntu-20.04
99
steps:
1010
- uses: actions/checkout@v3
1111
with:
1212
fetch-depth: 0
1313
- name: Download models
1414
run: ./autogen.sh
15-
- name: Install CMake 3.1
15+
- name: Install CMake 3.16
1616
run: |
17-
curl -sL https://github.com/Kitware/CMake/releases/download/v3.1.0/cmake-3.1.0-Linux-x86_64.sh -o cmakeinstall.sh
17+
curl -sL https://github.com/Kitware/CMake/releases/download/v3.16.0/cmake-3.16.0-Linux-x86_64.sh -o cmakeinstall.sh
1818
chmod +x cmakeinstall.sh
1919
sudo ./cmakeinstall.sh --prefix=/usr/local --exclude-subdir
2020
rm cmakeinstall.sh

CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.1)
1+
cmake_minimum_required(VERSION 3.16)
22
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
33

44
include(OpusPackageVersion)
@@ -97,6 +97,12 @@ if(APPLE)
9797
add_feature_info(OPUS_BUILD_FRAMEWORK OPUS_BUILD_FRAMEWORK ${OPUS_BUILD_FRAMEWORK_HELP_STR})
9898
endif()
9999

100+
if(MSVC)
101+
set(OPUS_STATIC_RUNTIME_HELP_STR "build with static runtime library.")
102+
option(OPUS_STATIC_RUNTIME ${OPUS_STATIC_RUNTIME_HELP_STR} OFF)
103+
add_feature_info(OPUS_STATIC_RUNTIME OPUS_STATIC_RUNTIME ${OPUS_STATIC_RUNTIME_HELP_STR})
104+
endif()
105+
100106
set(OPUS_FIXED_POINT_DEBUG_HELP_STR "debug fixed-point implementation.")
101107
cmake_dependent_option(OPUS_FIXED_POINT_DEBUG
102108
${OPUS_FIXED_POINT_DEBUG_HELP_STR}
@@ -265,6 +271,14 @@ if(OPUS_CUSTOM_MODES)
265271
list(APPEND Opus_PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_custom.h)
266272
endif()
267273

274+
if(MSVC)
275+
if(OPUS_STATIC_RUNTIME)
276+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
277+
else()
278+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
279+
endif()
280+
endif()
281+
268282
add_library(opus ${opus_headers} ${opus_sources} ${opus_sources_float} ${Opus_PUBLIC_HEADER})
269283
add_library(Opus::opus ALIAS opus)
270284

0 commit comments

Comments
 (0)