- find_package(Qt6 ...) -> find_package(Qt5 ...)
- 移除 qt_standard_project_setup() (Qt5 无此函数)
- qt_add_resources -> qt5_add_resources + .qrc 资源文件
- QTextStream::setEncoding(QStringConverter::Utf8) -> setCodec("UTF-8")
(3 个 tokenizer 文件 + logger.cpp)
- 更新 tests/CMakeLists.txt 使用 Qt5::Core
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
48 lines
1.2 KiB
CMake
48 lines
1.2 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
|
|
# 使用 Catch2 作为测试框架(通过 FetchContent 自动下载)
|
|
include(FetchContent)
|
|
FetchContent_Declare(
|
|
Catch2
|
|
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
|
GIT_TAG v3.6.0
|
|
GIT_SHALLOW TRUE
|
|
)
|
|
FetchContent_MakeAvailable(Catch2)
|
|
|
|
# 测试需要的源文件
|
|
set(TEST_SOURCES
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../src/core/audio_processor.cpp
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../src/core/mel_spectrogram.cpp
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../src/core/whisper_tokenizer.cpp
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../src/core/vad.cpp
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../src/utils/logger.cpp
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../src/utils/timer.cpp
|
|
)
|
|
|
|
# 测试可执行文件
|
|
add_executable(tests
|
|
test_audio_processor.cpp
|
|
test_vad.cpp
|
|
test_mel_spectrogram.cpp
|
|
test_whisper_tokenizer.cpp
|
|
${TEST_SOURCES}
|
|
)
|
|
|
|
target_include_directories(tests PRIVATE
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../src
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../third_party
|
|
)
|
|
|
|
target_link_libraries(tests PRIVATE
|
|
Catch2::Catch2WithMain
|
|
Qt5::Core
|
|
pthread
|
|
)
|
|
|
|
target_compile_features(tests PRIVATE cxx_std_17)
|
|
|
|
# 注册测试
|
|
include(Catch)
|
|
catch_discover_tests(tests)
|