ref: cbeebf007b8bed199212cb4e5da5ae79a5b24f97
parent: 0e30966b198ad28943799eaf5b3b08100b6f70c3
author: Malcolm Nixon <Malcolm.nixon@gmail.com>
date: Wed Apr 3 18:50:33 EDT 2024
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>
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -4,7 +4,7 @@
jobs:
CMakeVersionTest:
- name: Test build with CMake 3.1.0
+ name: Test build with CMake 3.16.0
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
@@ -12,9 +12,9 @@
fetch-depth: 0
- name: Download models
run: ./autogen.sh
- - name: Install CMake 3.1
+ - name: Install CMake 3.16
run: |
- curl -sL https://github.com/Kitware/CMake/releases/download/v3.1.0/cmake-3.1.0-Linux-x86_64.sh -o cmakeinstall.sh
+ curl -sL https://github.com/Kitware/CMake/releases/download/v3.16.0/cmake-3.16.0-Linux-x86_64.sh -o cmakeinstall.sh
chmod +x cmakeinstall.sh
sudo ./cmakeinstall.sh --prefix=/usr/local --exclude-subdir
rm cmakeinstall.sh
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.16)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")include(OpusPackageVersion)
@@ -97,6 +97,12 @@
add_feature_info(OPUS_BUILD_FRAMEWORK OPUS_BUILD_FRAMEWORK ${OPUS_BUILD_FRAMEWORK_HELP_STR})endif()
+if(MSVC)
+ set(OPUS_STATIC_RUNTIME_HELP_STR "build with static runtime library.")
+ option(OPUS_STATIC_RUNTIME ${OPUS_STATIC_RUNTIME_HELP_STR} OFF)+ add_feature_info(OPUS_STATIC_RUNTIME OPUS_STATIC_RUNTIME ${OPUS_STATIC_RUNTIME_HELP_STR})+endif()
+
set(OPUS_FIXED_POINT_DEBUG_HELP_STR "debug fixed-point implementation.")
cmake_dependent_option(OPUS_FIXED_POINT_DEBUG
${OPUS_FIXED_POINT_DEBUG_HELP_STR}@@ -263,6 +269,14 @@
if(OPUS_CUSTOM_MODES)
list(APPEND Opus_PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_custom.h)+endif()
+
+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()
add_library(opus ${opus_headers} ${opus_sources} ${opus_sources_float} ${Opus_PUBLIC_HEADER})--
⑨