Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyberhan123 committed Nov 28, 2023
1 parent 18bd8af commit 73d8e98
Show file tree
Hide file tree
Showing 7 changed files with 551 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
/out/
/cmake-build-debug/
/cmake-build-debug-visual-studio/
/cmake-build-release-visual-studio/

16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.14)
project("whisper-build")


Expand All @@ -24,9 +24,15 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
include(whisper)
include_directories(${whisper_SOURCE_DIR})

include(dr_libs)
include_directories(${dr_libs_SOURCE_DIR})

set(WHISPER_ABI whisper-abi)
add_library(${WHISPER_ABI} SHARED whisper_abi.cpp whisper_abi.h)
set_target_properties(${WHISPER_ABI} PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_compile_definitions(${WHISPER_ABI} PUBLIC WHISPER_SHARED WHISPER_BUILD ${WHISPER_EXTRA_FLAGS})
target_link_libraries(${WHISPER_ABI} PUBLIC $<TARGET_OBJECTS:whisper> ${WHISPER_EXTRA_LIBS} ${CMAKE_THREAD_LIBS_INIT})
add_library(${WHISPER_ABI} SHARED whisper_abi.cpp whisper_abi.h ${dr_libs_SOURCE_DIR}/dr_wav.h)

target_include_directories(${WHISPER_ABI} PUBLIC .)

set_target_properties(${WHISPER_ABI} PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_compile_definitions(${WHISPER_ABI} PUBLIC WHISPER_SHARED WHISPER_BUILD)
target_link_libraries(${WHISPER_ABI} PRIVATE whisper ${CMAKE_THREAD_LIBS_INIT})

3 changes: 2 additions & 1 deletion cmake/FetchContentMakeAvaliable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ if(NOT ${NAME}_POPULATED)
FetchContent_Populate(${NAME})
add_subdirectory(${${NAME}_SOURCE_DIR} ${${NAME}_BINARY_DIR})
endif()
endmacro()macro(FetchContent_MakeAvailable NAME)
endmacro()
macro(FetchContent_MakeAvailable NAME)
FetchContent_GetProperties(${NAME})
if(NOT ${NAME}_POPULATED)
FetchContent_Populate(${NAME})
Expand Down
17 changes: 17 additions & 0 deletions cmake/dr_libs.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
include(FetchContent)
# FetchContent_MakeAvailable was not added until CMake 3.14
if(${CMAKE_VERSION} VERSION_LESS 3.14)
include(add_FetchContent_MakeAvailable.cmake)
endif()

set(DR_LIBS_GIT_TAG 9eed1be421749ba68a87e5b4c3b10858f8580689)
set(DR_LIBS_GIT_URL https://github.com/mackron/dr_libs)
set(BUILD_SHARED_LIBS OFF)

FetchContent_Declare(
dr_libs
GIT_REPOSITORY ${DR_LIBS_GIT_URL}
GIT_TAG ${DR_LIBS_GIT_TAG}
)

FetchContent_MakeAvailable(dr_libs)
15 changes: 14 additions & 1 deletion cmake/whisper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,24 @@ endif()

set(WHISPER_GIT_TAG ffdb5c4735a2410dbc209c180199890966895ce6)
set(WHISPER_GIT_URL https://github.com/ggerganov/whisper.cpp)
set(BUILD_SHARED_LIBS OFF)

FetchContent_Declare(
whisper
GIT_REPOSITORY ${WHISPER_GIT_URL}
GIT_TAG ${WHISPER_GIT_TAG}
)

FetchContent_MakeAvailable(whisper)
FetchContent_MakeAvailable(whisper)
include_directories(${whisper_SOURCE_DIR})

target_compile_definitions(whisper PUBLIC
WHISPER_SHARED
GGML_SHARED
)
target_compile_definitions(whisper PRIVATE
WHISPER_BUILD
GGML_BUILD
)

set_target_properties(whisper PROPERTIES POSITION_INDEPENDENT_CODE ON)
Loading

0 comments on commit 73d8e98

Please sign in to comment.