Initial Commit

master
Harald Wolff 2024-03-27 10:35:17 +01:00
parent 1558ec5a16
commit 662f582e9d
1 changed files with 22 additions and 18 deletions

View File

@ -3,12 +3,14 @@ cmake_minimum_required (VERSION 3.5)
project(whisper.cpp VERSION 1.5.4) project(whisper.cpp VERSION 1.5.4)
set(SOVERSION 1) set(SOVERSION 1)
set(WHISPER_BASE_DIR ${CMAKE_CURRENT_LIST_DIR})
# Add path to modules # Add path to modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") list(APPEND CMAKE_MODULE_PATH "${WHISPER_BASE_DIR}/cmake/")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) if(PROJECT_IS_TOP_LEVEL AND CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(WHISPER_STANDALONE ON) set(WHISPER_STANDALONE ON)
include(GitVars) include(GitVars)
include(BuildTypes) include(BuildTypes)
@ -17,11 +19,13 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
if (EXISTS "${CMAKE_SOURCE_DIR}/bindings/ios/Makefile-tmpl") if (EXISTS "${CMAKE_SOURCE_DIR}/bindings/ios/Makefile-tmpl")
configure_file(${CMAKE_SOURCE_DIR}/bindings/ios/Makefile-tmpl ${CMAKE_SOURCE_DIR}/bindings/ios/Makefile @ONLY) configure_file(${CMAKE_SOURCE_DIR}/bindings/ios/Makefile-tmpl ${CMAKE_SOURCE_DIR}/bindings/ios/Makefile @ONLY)
endif() endif()
configure_file(${CMAKE_SOURCE_DIR}/bindings/javascript/package-tmpl.json ${CMAKE_SOURCE_DIR}/bindings/javascript/package.json @ONLY) configure_file(${WHISPER_BASE_DIR}/bindings/javascript/package-tmpl.json ${CMAKE_SOURCE_DIR}/bindings/javascript/package.json @ONLY)
else() else()
set(WHISPER_STANDALONE OFF) set(WHISPER_STANDALONE OFF)
endif() endif()
if (EMSCRIPTEN) if (EMSCRIPTEN)
set(BUILD_SHARED_LIBS_DEFAULT OFF) set(BUILD_SHARED_LIBS_DEFAULT OFF)
@ -249,7 +253,7 @@ if (WHISPER_CUBLAS)
enable_language(CUDA) enable_language(CUDA)
set(GGML_SOURCES_CUDA ggml-cuda.cu ggml-cuda.h) set(GGML_SOURCES_CUDA ${WHISPER_BASE_DIR}/ggml-cuda.cu ${WHISPER_BASE_DIR}/ggml-cuda.h)
add_compile_definitions(GGML_USE_CUBLAS) add_compile_definitions(GGML_USE_CUBLAS)
@ -527,21 +531,21 @@ endif()
set(TARGET whisper) set(TARGET whisper)
add_library(${TARGET} add_library(${TARGET}
ggml.h ${WHISPER_BASE_DIR}/ggml.h
ggml.c ${WHISPER_BASE_DIR}/ggml.c
ggml-alloc.h ${WHISPER_BASE_DIR}/ggml-alloc.h
ggml-alloc.c ${WHISPER_BASE_DIR}/ggml-alloc.c
ggml-backend.h ${WHISPER_BASE_DIR}/ggml-backend.h
ggml-backend.c ${WHISPER_BASE_DIR}/ggml-backend.c
ggml-quants.h ${WHISPER_BASE_DIR}/ggml-quants.h
ggml-quants.c ${WHISPER_BASE_DIR}/ggml-quants.c
${GGML_SOURCES_METAL} ${GGML_SOURCES_METAL}
${GGML_SOURCES_CUDA} ${GGML_SOURCES_CUDA}
${GGML_SOURCES_OPENCL} ${GGML_SOURCES_OPENCL}
${GGML_SOURCES_SYCL} ${GGML_SOURCES_SYCL}
${GGML_HEADERS_SYCL} ${GGML_HEADERS_SYCL}
whisper.h ${WHISPER_BASE_DIR}/whisper.h
whisper.cpp ${WHISPER_BASE_DIR}/whisper.cpp
) )
# Set the version numbers # Set the version numbers
@ -591,7 +595,7 @@ if (BUILD_SHARED_LIBS)
if (WHISPER_METAL) if (WHISPER_METAL)
# TODO: I think this should make ggml-metal.m "see" the ggml-metal.metal file from the "bin" directory # TODO: I think this should make ggml-metal.m "see" the ggml-metal.metal file from the "bin" directory
# but for some reason it does not work here like it does in llama.cpp # but for some reason it does not work here like it does in llama.cpp
set_target_properties(${TARGET} PROPERTIES RESOURCE "${CMAKE_CURRENT_SOURCE_DIR}/ggml-metal.metal") set_target_properties(${TARGET} PROPERTIES RESOURCE "${WHISPER_BASE_DIR}/ggml-metal.metal")
endif() endif()
endif() endif()
@ -631,7 +635,7 @@ install(TARGETS ${TARGET}
# bindings # bindings
# #
add_subdirectory(bindings) add_subdirectory(${WHISPER_BASE_DIR}/bindings)
# #
# programs, examples and tests # programs, examples and tests
@ -639,9 +643,9 @@ add_subdirectory(bindings)
if (WHISPER_BUILD_TESTS AND NOT CMAKE_JS_VERSION) if (WHISPER_BUILD_TESTS AND NOT CMAKE_JS_VERSION)
enable_testing() enable_testing()
add_subdirectory(tests) add_subdirectory(${WHISPER_BASE_DIR}/tests)
endif () endif ()
if (WHISPER_BUILD_EXAMPLES) if (WHISPER_BUILD_EXAMPLES)
add_subdirectory(examples) add_subdirectory(${WHISPER_BASE_DIR}/examples)
endif() endif()