From 5d5d265ae0799dc6a64046f9fd9d408bdc0ea6f7 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 4 Oct 2023 15:38:53 +0200 Subject: [PATCH] Add cmake flag to use system-provided miniaudio (#4867) Example usage: `cmake -DUSE_SYSTEM_MINIAUDIO=ON ..` --- CHANGELOG.md | 1 + CMakeLists.txt | 1 + src/CMakeLists.txt | 11 ++++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e568dd01..ace836f8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ - Dev: Fixed flickering when running with Direct2D on Windows. (#4851) - Dev: Fix qtkeychain include for Qt6 users. (#4863) - Dev: Add a compile-time flag `CHATTERINO_UPDATER` which can be turned off to disable update checks. (#4854) +- Dev: Add a compile-time flag `USE_SYSTEM_MINIAUDIO` which can be turned on to use the system miniaudio. (#4867) ## 2.4.6 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f3e1699b..d3ebd4c5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ option(USE_SYSTEM_PAJLADA_SETTINGS "Use system pajlada settings library" OFF) option(USE_SYSTEM_LIBCOMMUNI "Use system communi library" OFF) option(USE_SYSTEM_QTKEYCHAIN "Use system QtKeychain library" OFF) option(BUILD_WITH_QTKEYCHAIN "Build Chatterino with support for your system key chain" ON) +option(USE_SYSTEM_MINIAUDIO "Build Chatterino with your system miniaudio" OFF) option(BUILD_WITH_CRASHPAD "Build chatterino with crashpad" OFF) option(USE_PRECOMPILED_HEADERS "Use precompiled headers" ON) option(BUILD_WITH_QT6 "Use Qt6 instead of default Qt5" OFF) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b24a8ac47..be3d3336f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -912,7 +912,16 @@ target_include_directories(${LIBRARY_PROJECT} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} target_include_directories(${LIBRARY_PROJECT} PUBLIC ${CMAKE_SOURCE_DIR}/lib/semver/include) # miniaudio dependency https://github.com/mackron/miniaudio -target_include_directories(${LIBRARY_PROJECT} PUBLIC ${CMAKE_SOURCE_DIR}/lib/miniaudio) +if (USE_SYSTEM_MINIAUDIO) + message(STATUS "Building with system miniaudio") + include(CheckIncludeFileCXX) + CHECK_INCLUDE_FILE_CXX("miniaudio.h" MINIAUDIO_FOUND) + if (NOT MINIAUDIO_FOUND) + message(FATAL_ERROR "miniaudio.h not found on your system") + endif() +else () + target_include_directories(${LIBRARY_PROJECT} PUBLIC ${CMAKE_SOURCE_DIR}/lib/miniaudio) +endif () if (UNIX) if (CMAKE_DL_LIBS)