2022-10-22 10:07:59 +00:00
# dependencies
find_package ( Threads REQUIRED )
# third-party
2023-04-30 09:14:33 +00:00
if ( WHISPER_SDL2 )
2022-10-25 16:13:08 +00:00
# SDL2
find_package ( SDL2 REQUIRED )
string ( STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES )
message ( STATUS "SDL2_INCLUDE_DIRS = ${SDL2_INCLUDE_DIRS}" )
2024-06-26 17:11:38 +00:00
message ( STATUS "SDL2_LIBRARIES = ${SDL2_LIBRARIES}" )
2022-10-25 16:13:08 +00:00
endif ( )
2022-10-22 10:07:59 +00:00
2023-12-29 10:23:27 +00:00
if ( WHISPER_CLBLAST )
find_package ( CLBlast REQUIRED )
endif ( )
2023-02-15 17:28:10 +00:00
# common
set ( TARGET common )
2024-06-26 17:11:38 +00:00
unset ( COMMON_EXTRA_LIBS )
2024-05-21 15:31:41 +00:00
if ( WHISPER_FFMPEG )
2024-06-26 17:11:38 +00:00
# As of cmake 3.27, there is no official cmake support for FindFFmpeg.
# Consequnelty we added a FindFFmpeg.cmake script the cmake subfolder:
# whisper.cpp does not need the full ffmpeg libs, just AVFORMAT AVCODEC AVUTIL SWRESAMPLE
# libswresample performs highly optimized audio resampling, rematrixing and sample format conversion operations
# libavcodec provides a generic encoding/decoding framework and contains multiple decoders and encoders for audio, video and subtitle streams, and several bitstream filters.
# libavformat provides a generic framework for multiplexing and demultiplexing (muxing and demuxing) audio, video and subtitle streams.
find_package ( FFmpeg REQUIRED )
if ( NOT ${ FFMPEG_FOUND } )
message ( FATAL_ERROR "Cannot find ffmpeg libs/headers" )
endif ( )
message ( STATUS "Found ffmpeg libs: ${FFMPEG_LIBRARIES}" )
message ( STATUS "Found ffmpeg headers in: ${FFMPEG_INCLUDE_DIRS}" )
message ( STATUS "ffmpeg definitions: ${FFMPEG_DEFINITIONS}" )
2024-06-26 18:42:39 +00:00
message ( STATUS "Found avformat ${AVFORMAT_VERSION}" )
2024-06-26 17:11:38 +00:00
include_directories ( ${ FFMPEG_INCLUDE_DIRS } )
add_compile_definitions ( WHISPER_FFMPEG )
list ( APPEND COMMON_EXTRA_LIBS ${ FFMPEG_LIBRARIES } )
2024-05-21 15:31:41 +00:00
set ( COMMON_SOURCES_FFMPEG ffmpeg-transcode.cpp )
endif ( )
2024-06-26 17:11:38 +00:00
2023-02-15 17:28:10 +00:00
add_library ( ${ TARGET } STATIC
c o m m o n . h
c o m m o n . c p p
2023-04-30 15:51:57 +00:00
c o m m o n - g g m l . h
c o m m o n - g g m l . c p p
2024-03-28 09:59:48 +00:00
g r a m m a r - p a r s e r . h
2023-11-13 08:51:34 +00:00
g r a m m a r - p a r s e r . c p p
2024-05-21 15:31:41 +00:00
$ { C O M M O N _ S O U R C E S _ F F M P E G }
2023-02-15 17:28:10 +00:00
)
include ( DefaultTargetOptions )
2024-06-26 17:11:38 +00:00
target_link_libraries ( ${ TARGET } PRIVATE whisper ${ COMMON_EXTRA_LIBS } )
2023-04-30 15:51:57 +00:00
2023-02-15 17:28:10 +00:00
set_target_properties ( ${ TARGET } PROPERTIES POSITION_INDEPENDENT_CODE ON )
2024-04-09 15:23:33 +00:00
set_target_properties ( ${ TARGET } PROPERTIES FOLDER "libs" )
2023-02-15 17:28:10 +00:00
2023-04-30 09:14:33 +00:00
if ( WHISPER_SDL2 )
2023-02-15 17:28:10 +00:00
# common-sdl
set ( TARGET common-sdl )
add_library ( ${ TARGET } STATIC
c o m m o n - s d l . h
c o m m o n - s d l . c p p
)
include ( DefaultTargetOptions )
2024-06-26 17:11:38 +00:00
target_include_directories ( ${ TARGET } PUBLIC ${ SDL2_INCLUDE_DIRS } )
target_link_libraries ( ${ TARGET } PRIVATE ${ SDL2_LIBRARIES } )
2023-02-15 17:28:10 +00:00
set_target_properties ( ${ TARGET } PROPERTIES POSITION_INDEPENDENT_CODE ON )
2024-04-09 15:23:33 +00:00
set_target_properties ( ${ TARGET } PROPERTIES FOLDER "libs" )
2023-02-15 17:28:10 +00:00
endif ( )
2024-02-19 08:50:15 +00:00
# add json lib
2024-05-13 11:29:39 +00:00
add_library ( json_cpp INTERFACE )
target_include_directories ( json_cpp INTERFACE ${ CMAKE_CURRENT_SOURCE_DIR } )
2024-02-19 08:50:15 +00:00
2022-10-22 10:07:59 +00:00
# examples
2022-10-25 16:13:08 +00:00
include_directories ( ${ CMAKE_CURRENT_SOURCE_DIR } )
2022-10-22 10:07:59 +00:00
if ( EMSCRIPTEN )
add_subdirectory ( whisper.wasm )
2022-11-25 21:57:46 +00:00
add_subdirectory ( stream.wasm )
2022-11-26 09:40:06 +00:00
add_subdirectory ( command.wasm )
2022-12-11 09:09:01 +00:00
add_subdirectory ( bench.wasm )
2023-02-04 07:10:25 +00:00
elseif ( CMAKE_JS_VERSION )
add_subdirectory ( addon.node )
2022-10-22 10:07:59 +00:00
else ( )
2024-12-21 07:43:49 +00:00
add_subdirectory ( cli )
2022-10-25 16:13:08 +00:00
add_subdirectory ( bench )
2024-12-21 07:43:49 +00:00
add_subdirectory ( server )
2023-04-30 15:51:57 +00:00
add_subdirectory ( quantize )
2024-12-21 07:43:49 +00:00
if ( WHISPER_SDL2 )
add_subdirectory ( stream )
add_subdirectory ( command )
add_subdirectory ( talk-llama )
add_subdirectory ( lsp )
if ( GGML_SYCL )
add_subdirectory ( sycl )
endif ( )
endif ( WHISPER_SDL2 )
add_subdirectory ( deprecation-warning )
2022-10-22 10:07:59 +00:00
endif ( )
2023-12-14 13:58:26 +00:00
2024-04-09 15:23:33 +00:00
if ( WHISPER_SDL2 )
add_subdirectory ( wchess )
endif ( WHISPER_SDL2 )