|
| 1 | +# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | +# All rights reserved. |
| 3 | +# |
| 4 | +# This source code is licensed under the BSD-style license found in the |
| 5 | +# LICENSE file in the root directory of this source tree. |
| 6 | + |
| 7 | +cmake_minimum_required(VERSION 3.24) |
| 8 | +project(voxtral_tts) |
| 9 | + |
| 10 | +set(CMAKE_CXX_STANDARD 17) |
| 11 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 12 | + |
| 13 | +set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..) |
| 14 | + |
| 15 | +include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake) |
| 16 | + |
| 17 | +set(_common_include_directories ${EXECUTORCH_ROOT}/..) |
| 18 | + |
| 19 | +# gflags |
| 20 | +set(gflags_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../../third-party/gflags) |
| 21 | +find_package(gflags REQUIRED) |
| 22 | + |
| 23 | +# ExecuTorch |
| 24 | +list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../../..) |
| 25 | +find_package(executorch CONFIG REQUIRED FIND_ROOT_PATH_BOTH) |
| 26 | +executorch_target_link_options_shared_lib(executorch) |
| 27 | + |
| 28 | +set(link_libraries executorch gflags) |
| 29 | + |
| 30 | +# Common ops |
| 31 | +list(APPEND link_libraries optimized_native_cpu_ops_lib cpublas eigen_blas) |
| 32 | +executorch_target_link_options_shared_lib(optimized_native_cpu_ops_lib) |
| 33 | + |
| 34 | +# CPU-only builds need quantized and custom ops |
| 35 | +if(NOT EXECUTORCH_BUILD_CUDA) |
| 36 | + list(APPEND link_libraries quantized_ops_lib custom_ops) |
| 37 | + executorch_target_link_options_shared_lib(quantized_ops_lib) |
| 38 | + executorch_target_link_options_shared_lib(custom_ops) |
| 39 | +endif() |
| 40 | + |
| 41 | +# XNNPACK |
| 42 | +if(TARGET xnnpack_backend) |
| 43 | + set(xnnpack_backend_libs xnnpack_backend XNNPACK xnnpack-microkernels-prod) |
| 44 | + if(TARGET kleidiai) |
| 45 | + list(APPEND xnnpack_backend_libs kleidiai) |
| 46 | + endif() |
| 47 | + list(APPEND link_libraries ${xnnpack_backend_libs}) |
| 48 | + executorch_target_link_options_shared_lib(xnnpack_backend) |
| 49 | +endif() |
| 50 | + |
| 51 | +# LLM runner extension |
| 52 | +if(NOT TARGET extension_llm_runner) |
| 53 | + message( |
| 54 | + FATAL_ERROR |
| 55 | + "ExecuTorch must be installed with EXECUTORCH_BUILD_EXTENSION_LLM_RUNNER enabled." |
| 56 | + ) |
| 57 | +endif() |
| 58 | + |
| 59 | +if(ANDROID) |
| 60 | + list(APPEND link_libraries log) |
| 61 | +endif() |
| 62 | + |
| 63 | +list( |
| 64 | + APPEND |
| 65 | + link_libraries |
| 66 | + extension_llm_runner |
| 67 | + extension_module |
| 68 | + extension_data_loader |
| 69 | + extension_tensor |
| 70 | + extension_flat_tensor |
| 71 | +) |
| 72 | + |
| 73 | +# CUDA backend |
| 74 | +if(EXECUTORCH_BUILD_CUDA) |
| 75 | + find_package(CUDAToolkit REQUIRED) |
| 76 | + list(APPEND link_libraries aoti_cuda_backend) |
| 77 | + if(NOT MSVC) |
| 78 | + executorch_target_link_options_shared_lib(aoti_cuda_backend) |
| 79 | + endif() |
| 80 | +endif() |
| 81 | + |
| 82 | +# Metal backend |
| 83 | +if(EXECUTORCH_BUILD_METAL) |
| 84 | + list(APPEND link_libraries metal_backend) |
| 85 | + executorch_target_link_options_shared_lib(metal_backend) |
| 86 | +endif() |
| 87 | + |
| 88 | +# Tokenizer |
| 89 | +list(APPEND link_libraries tokenizers::tokenizers) |
| 90 | + |
| 91 | +add_executable( |
| 92 | + voxtral_tts_runner main.cpp voxtral_tts_runner.cpp wav_writer.cpp |
| 93 | +) |
| 94 | +if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") |
| 95 | + target_link_options_gc_sections(voxtral_tts_runner) |
| 96 | + if(NOT APPLE AND NOT MSVC) |
| 97 | + target_link_options(voxtral_tts_runner PRIVATE "LINKER:-s") |
| 98 | + endif() |
| 99 | +endif() |
| 100 | + |
| 101 | +target_include_directories( |
| 102 | + voxtral_tts_runner PUBLIC ${_common_include_directories} |
| 103 | + ${EXECUTORCH_ROOT}/third-party/json/include |
| 104 | +) |
| 105 | +target_link_libraries(voxtral_tts_runner PUBLIC ${link_libraries}) |
| 106 | +target_compile_options(voxtral_tts_runner PUBLIC ${_common_compile_options}) |
0 commit comments