Skip to content

Commit

Permalink
{Build} Add CMake support for OPUS build
Browse files Browse the repository at this point in the history
Summary:
Enable optional OPUS compilation
- Add a CMake preprocessor `BUILD_WITH_OPUS`
- If required:
  - Add CMake rules to fetch OPUS library
  - Enable `OPUS_IS_AVAILABLE` CPP
- Update `pixi run build` to compile with OPUS support by default to ease CI and testing long term support of the feature

Differential Revision:
D68632323

Privacy Context Container: L1163201
  • Loading branch information
SeaOtocinclus authored and facebook-github-bot committed Jan 24, 2025
1 parent ecb5db3 commit 54f1ebf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ add_subdirectory(vrs)

OPTION(BUILD_TOOLS "Build all of the tools" ON)
OPTION(BUILD_SAMPLES "Build sample code and sample apps" ON)
OPTION(BUILD_WITH_OPUS "Build VRS to support OPUS" OFF)

if (BUILD_TOOLS)
# Add the vrs command line utility
Expand Down
12 changes: 12 additions & 0 deletions cmake/LibrariesSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ find_package(PNG REQUIRED)
find_package(JPEG REQUIRED)
find_package(TurboJpeg REQUIRED)

if (BUILD_WITH_OPUS)
include(FetchContent)
FetchContent_Declare(
opus
URL https://downloads.xiph.org/releases/opus/opus-1.5.2.tar.gz
URL_HASH SHA256=65c1d2f78b9f2fb20082c38cbe47c951ad5839345876e46941612ee87f9a7ce1
)
FetchContent_MakeAvailable(opus)
message("BUILD WITH OPUS: ON")
endif()


# Setup unit test infra, but only if unit tests are enabled
if (UNIT_TESTS)
enable_testing()
Expand Down
4 changes: 2 additions & 2 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ version = "1.1.0"
# Note: extra CLI argument after `pixi run TASK` are passed to the task cmd.
clean = { cmd = "rm -rf build" }
print-env = { cmd = "echo $PATH" }
prepare = "cmake -G 'Ninja' -B build -S . -DCMAKE_BUILD_TYPE=Release"
prepare = "cmake -G 'Ninja' -B build -S . -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_OPUS:BOOL=ON"
build = { cmd = "cmake --build build --config Release --target all", depends_on = [
"prepare",
] }
Expand All @@ -36,7 +36,7 @@ vrs = { cmd = "build/tools/vrs/vrs", depends_on = ["build"]}

[target.win-64.tasks] # Deal with windows specifics (prepare and build)
cmake-generator = "cmake --help"
prepare = "cmake -G 'Visual Studio 16 2019' -B build -S . -DCMAKE_BUILD_TYPE=Release"
prepare = "cmake -G 'Visual Studio 16 2019' -B build -S . -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_OPUS:BOOL=ON"
build = { cmd = "cmake --build build --config Release -- /m", depends_on = [
"prepare",
] }
Expand Down
6 changes: 6 additions & 0 deletions vrs/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ target_link_libraries(vrs_utils
rapidjson::rapidjson
vrs_logging
)

if (BUILD_WITH_OPUS)
target_link_libraries(vrs_utils PRIVATE opus)
target_compile_definitions(vrs_utils PRIVATE OPUS_IS_AVAILABLE)
endif()

target_include_directories(vrs_utils
INTERFACE
$<BUILD_INTERFACE:${VRS_SOURCE_DIR}>
Expand Down

0 comments on commit 54f1ebf

Please sign in to comment.