Skip to content

Commit

Permalink
Use Opus and Flac from precompiled dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
cbjeukendrup committed Jul 18, 2024
1 parent f2d4db3 commit 7ffb036
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 17 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ endif(MUE_COMPILE_USE_CCACHE)
###########################################

if (MUE_COMPILE_MACOS_PRECOMPILED_DEPS_PATH)
list(PREPEND CMAKE_PREFIX_PATH ${MUE_COMPILE_MACOS_PRECOMPILED_DEPS_PATH})
list(PREPEND CMAKE_PREFIX_PATH ${MUE_COMPILE_MACOS_PRECOMPILED_DEPS_PATH})

# These are included in the precompiled dependencies, so let's use them from there
set(MUE_COMPILE_USE_SYSTEM_FLAC ON)
set(MUE_COMPILE_USE_SYSTEM_OPUS ON)
endif()

set(QT_MIN_VERSION "6.2.4")
Expand Down
22 changes: 18 additions & 4 deletions src/framework/audio/cmake/SetupFlac.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,27 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

if (MUE_COMPILE_USE_SYSTEM_FLAC)
find_package(FLAC)

if (FLAC_FOUND)
message(STATUS "Found flac: ${FLAC_VERSION}")
set(FLAC_TARGETS FLAC::FLAC FLAC::FLAC++)
return()
endif()

find_package(PkgConfig REQUIRED)

pkg_check_modules(flac REQUIRED IMPORTED_TARGET flac)
pkg_check_modules(flacpp REQUIRED IMPORTED_TARGET flac++)

set(FLAC_TARGETS PkgConfig::flac PkgConfig::flacpp)
else()
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../thirdparty/flac flac)
set(FLAC_TARGETS flac)
if (FLAC_FOUND)
message(STATUS "Found flac: ${FLAC_VERSION}")
set(FLAC_TARGETS PkgConfig::flac PkgConfig::flacpp)
return()
else()
message(WARNING "Set MUE_COMPILE_USE_SYSTEM_FLAC=ON, but system flac not found, built-in will be used")
endif()
endif()

add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../thirdparty/flac flac)
set(FLAC_TARGETS flac)
29 changes: 17 additions & 12 deletions src/framework/audio/thirdparty/opusenc/cmake/SetupOpus.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,31 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

if (MUE_COMPILE_USE_SYSTEM_OPUS)
find_package(Opus)

if (OPUS_FOUND)
message(STATUS "Found opus: ${OPUS_VERSION}")
return()
endif()

find_package(PkgConfig REQUIRED)

pkg_check_modules(OPUS opus)

if (OPUS_FOUND)
message(STATUS "Found opus: ${OPUS_VERSION}")
else ()
message(WARNING "Set MUE_COMPILE_USE_SYSTEM_OPUS=ON, but system opus not found, built-in will be used")
return()
endif ()
endif ()

message(WARNING "Set MUE_COMPILE_USE_SYSTEM_OPUS=ON, but system opus not found, built-in will be used")
endif ()

if (NOT OPUS_FOUND)
set(OPUS_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../opus/opus-1.4)
add_subdirectory(${OPUS_LIB_DIR} opus)
set(OPUS_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../opus/opus-1.4)
add_subdirectory(${OPUS_LIB_DIR} opus)

set(OPUS_INCLUDE_DIRS ${OPUS_LIB_DIR}/include)
set(OPUS_LIBRARIES opus)
set(OPUS_INCLUDE_DIRS ${OPUS_LIB_DIR}/include)
set(OPUS_LIBRARIES opus)

target_no_warning(opus -Wno-conversion)
target_no_warning(opus -Wno-truncate)
target_no_warning(opus -Wno-uninitialized)
endif ()
target_no_warning(opus -Wno-conversion)
target_no_warning(opus -Wno-truncate)
target_no_warning(opus -Wno-uninitialized)

0 comments on commit 7ffb036

Please sign in to comment.