2022-10-22 13:07:59 +03:00
# dependencies
find_package ( Threads REQUIRED )
# third-party
2023-04-30 12:14:33 +03:00
if ( WHISPER_SDL2 )
2022-10-25 19:13:08 +03:00
# SDL2
find_package ( SDL2 REQUIRED )
string ( STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES )
message ( STATUS "SDL2_INCLUDE_DIRS = ${SDL2_INCLUDE_DIRS}" )
2024-06-26 20:11:38 +03:00
message ( STATUS "SDL2_LIBRARIES = ${SDL2_LIBRARIES}" )
2022-10-25 19:13:08 +03:00
endif ( )
2022-10-22 13:07:59 +03:00
2023-12-29 19:23:27 +09:00
if ( WHISPER_CLBLAST )
find_package ( CLBlast REQUIRED )
endif ( )
2023-02-15 19:28:10 +02:00
# common
set ( TARGET common )
2024-06-26 20:11:38 +03:00
unset ( COMMON_EXTRA_LIBS )
2024-05-21 08:31:41 -07:00
if ( WHISPER_FFMPEG )
2024-06-26 20:11:38 +03: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 21:42:39 +03:00
message ( STATUS "Found avformat ${AVFORMAT_VERSION}" )
2024-06-26 20:11:38 +03:00
include_directories ( ${ FFMPEG_INCLUDE_DIRS } )
add_compile_definitions ( WHISPER_FFMPEG )
list ( APPEND COMMON_EXTRA_LIBS ${ FFMPEG_LIBRARIES } )
2024-05-21 08:31:41 -07:00
set ( COMMON_SOURCES_FFMPEG ffmpeg-transcode.cpp )
endif ( )
2024-06-26 20:11:38 +03:00
2023-02-15 19:28:10 +02:00
add_library ( ${ TARGET } STATIC
c o m m o n . h
c o m m o n . c p p
2023-04-30 18:51:57 +03: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 11:59:48 +02:00
g r a m m a r - p a r s e r . h
2023-11-13 03:51:34 -05:00
g r a m m a r - p a r s e r . c p p
2024-05-21 08:31:41 -07:00
$ { C O M M O N _ S O U R C E S _ F F M P E G }
2023-02-15 19:28:10 +02:00
)
include ( DefaultTargetOptions )
2024-06-26 20:11:38 +03:00
target_link_libraries ( ${ TARGET } PRIVATE whisper ${ COMMON_EXTRA_LIBS } )
2023-04-30 18:51:57 +03:00
2023-02-15 19:28:10 +02:00
set_target_properties ( ${ TARGET } PROPERTIES POSITION_INDEPENDENT_CODE ON )
2024-04-09 08:23:33 -07:00
set_target_properties ( ${ TARGET } PROPERTIES FOLDER "libs" )
2023-02-15 19:28:10 +02:00
2023-04-30 12:14:33 +03:00
if ( WHISPER_SDL2 )
2023-02-15 19:28:10 +02: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 20:11:38 +03:00
target_include_directories ( ${ TARGET } PUBLIC ${ SDL2_INCLUDE_DIRS } )
target_link_libraries ( ${ TARGET } PRIVATE ${ SDL2_LIBRARIES } )
2023-02-15 19:28:10 +02:00
set_target_properties ( ${ TARGET } PROPERTIES POSITION_INDEPENDENT_CODE ON )
2024-04-09 08:23:33 -07:00
set_target_properties ( ${ TARGET } PROPERTIES FOLDER "libs" )
2023-02-15 19:28:10 +02:00
endif ( )
2024-02-19 09:50:15 +01:00
# add json lib
2024-05-13 19:29:39 +08:00
add_library ( json_cpp INTERFACE )
target_include_directories ( json_cpp INTERFACE ${ CMAKE_CURRENT_SOURCE_DIR } )
2024-02-19 09:50:15 +01:00
2022-10-22 13:07:59 +03:00
# examples
2022-10-25 19:13:08 +03:00
include_directories ( ${ CMAKE_CURRENT_SOURCE_DIR } )
2022-10-22 13:07:59 +03:00
if ( EMSCRIPTEN )
add_subdirectory ( whisper.wasm )
2022-11-25 23:57:46 +02:00
add_subdirectory ( stream.wasm )
2022-11-26 11:40:06 +02:00
add_subdirectory ( command.wasm )
2022-12-11 11:09:01 +02:00
add_subdirectory ( bench.wasm )
2023-02-04 15:10:25 +08:00
elseif ( CMAKE_JS_VERSION )
add_subdirectory ( addon.node )
2022-10-22 13:07:59 +03:00
else ( )
2024-12-21 09:43:49 +02:00
add_subdirectory ( cli )
2022-10-25 19:13:08 +03:00
add_subdirectory ( bench )
2024-12-21 09:43:49 +02:00
add_subdirectory ( server )
2023-04-30 18:51:57 +03:00
add_subdirectory ( quantize )
2024-12-21 09:43:49 +02: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 13:07:59 +03:00
endif ( )
2023-12-14 15:58:26 +02:00
2024-04-09 08:23:33 -07:00
if ( WHISPER_SDL2 )
add_subdirectory ( wchess )
endif ( WHISPER_SDL2 )