2019-01-24 11:47:28 -08:00
|
|
|
cmake_minimum_required(VERSION 3.9)
|
2023-05-09 01:12:45 +08:00
|
|
|
project(libass C)
|
2019-01-24 11:47:28 -08:00
|
|
|
|
2024-06-06 10:15:08 +03:00
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libass ${CMAKE_CURRENT_BINARY_DIR})
|
2019-01-24 11:47:28 -08:00
|
|
|
|
2023-05-09 01:12:45 +08:00
|
|
|
set(CONFIG_FREETYPE 1)
|
|
|
|
set(CONFIG_FRIBIDI 1)
|
|
|
|
set(CONFIG_HARFBUZZ 1)
|
2019-01-24 11:47:28 -08:00
|
|
|
|
2023-05-09 01:12:45 +08:00
|
|
|
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/libass/*.c)
|
2022-05-20 05:14:39 +08:00
|
|
|
|
|
|
|
set(PKG_REQUIRES_LIBASS "harfbuzz >= 1.2.3, fribidi >= 0.19.1, freetype2 >= 9.17.3")
|
|
|
|
set(PKG_LIBS_LIBASS)
|
2020-07-28 02:43:23 +02:00
|
|
|
if(WIN32)
|
2023-05-09 01:12:45 +08:00
|
|
|
set(CONFIG_DIRECTWRITE 1)
|
2020-07-28 02:43:23 +02:00
|
|
|
list(FILTER SOURCES EXCLUDE REGEX ".*ass_coretext.c$")
|
|
|
|
list(FILTER SOURCES EXCLUDE REGEX ".*ass_fontconfig.c$")
|
2022-05-20 05:14:39 +08:00
|
|
|
|
|
|
|
#dependency fribidi does not support uwp builds, link gdi32 directly
|
|
|
|
set(FONT_LIBRARY gdi32)
|
|
|
|
set(PKG_LIBS_LIBASS -lgdi32)
|
2020-07-28 02:43:23 +02:00
|
|
|
elseif(APPLE)
|
2023-05-09 01:12:45 +08:00
|
|
|
set(CONFIG_CORETEXT 1)
|
2020-07-28 02:43:23 +02:00
|
|
|
list(FILTER SOURCES EXCLUDE REGEX ".*ass_directwrite.c$")
|
|
|
|
list(FILTER SOURCES EXCLUDE REGEX ".*ass_fontconfig.c$")
|
2022-05-20 05:14:39 +08:00
|
|
|
|
2023-05-09 01:12:45 +08:00
|
|
|
include(CheckCSourceCompiles)
|
2022-05-20 05:14:39 +08:00
|
|
|
check_c_source_compiles(
|
|
|
|
"
|
|
|
|
#include <ApplicationServices/ApplicationServices.h>
|
|
|
|
int main(void){
|
|
|
|
CTFontDescriptorCopyAttribute(NULL, kCTFontURLAttribute);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
"
|
|
|
|
CHECK_OLD_OSX
|
|
|
|
)
|
2023-05-09 01:12:45 +08:00
|
|
|
if(CHECK_OLD_OSX)
|
2022-05-20 05:14:39 +08:00
|
|
|
set(FONT_LIBRARY "-framework ApplicationServices -framework CoreFoundation")
|
|
|
|
set(PKG_LIBS_LIBASS "-framework ApplicationServices -framework CoreFoundation")
|
|
|
|
else()
|
|
|
|
set(FONT_LIBRARY "-framework CoreText -framework CoreFoundation")
|
|
|
|
set(PKG_LIBS_LIBASS "-framework CoreText -framework CoreFoundation")
|
|
|
|
endif()
|
2023-05-09 01:12:45 +08:00
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
|
|
set(CONFIG_FONTCONFIG 1)
|
2020-07-28 02:43:23 +02:00
|
|
|
list(FILTER SOURCES EXCLUDE REGEX ".*ass_coretext.c$")
|
|
|
|
list(FILTER SOURCES EXCLUDE REGEX ".*ass_directwrite.c$")
|
2020-12-01 01:48:57 +08:00
|
|
|
|
|
|
|
find_package(Fontconfig REQUIRED)
|
2022-05-20 05:14:39 +08:00
|
|
|
set(FONT_LIBRARY Fontconfig::Fontconfig)
|
|
|
|
set(PKG_REQUIRES_LIBASS "fontconfig >= 2.10.92, ${PKG_REQUIRES_LIBASS}")
|
2023-05-09 01:12:45 +08:00
|
|
|
else()
|
|
|
|
list(FILTER SOURCES EXCLUDE REGEX ".*ass_directwrite.c$")
|
|
|
|
list(FILTER SOURCES EXCLUDE REGEX ".*ass_coretext.c$")
|
|
|
|
list(FILTER SOURCES EXCLUDE REGEX ".*ass_fontconfig.c$")
|
2022-05-20 05:14:39 +08:00
|
|
|
endif()
|
|
|
|
|
2023-05-09 01:12:45 +08:00
|
|
|
if(NOT WIN32)
|
2022-05-20 05:14:39 +08:00
|
|
|
set(PKG_LIBS_LIBASS "${PKG_LIBS_LIBASS} -lm")
|
2020-07-28 02:43:23 +02:00
|
|
|
endif()
|
2019-01-24 11:47:28 -08:00
|
|
|
|
|
|
|
find_package(Freetype REQUIRED)
|
|
|
|
|
2023-05-09 01:12:45 +08:00
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_check_modules(FRIBIDI REQUIRED IMPORTED_TARGET fribidi)
|
|
|
|
pkg_check_modules(HARFBUZZ REQUIRED IMPORTED_TARGET harfbuzz)
|
2019-01-31 05:41:51 +08:00
|
|
|
|
2022-05-20 05:14:39 +08:00
|
|
|
# libass use win32 api to open files on windows since https://github.com/libass/libass/commit/f664ced049394e2a5d4300ba526e206df73ec729
|
|
|
|
# so remove dependency dirent.
|
2020-08-06 22:07:46 +02:00
|
|
|
|
2023-05-09 01:12:45 +08:00
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in config.h)
|
2019-01-24 11:47:28 -08:00
|
|
|
|
2019-01-31 05:41:51 +08:00
|
|
|
add_library(ass ${SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/libass.def)
|
2019-01-24 11:47:28 -08:00
|
|
|
|
2020-07-28 02:43:23 +02:00
|
|
|
target_include_directories(ass PRIVATE
|
2023-05-09 01:12:45 +08:00
|
|
|
PkgConfig::FRIBIDI
|
|
|
|
PkgConfig::HARFBUZZ)
|
2020-07-28 02:43:23 +02:00
|
|
|
target_link_libraries(ass PRIVATE
|
|
|
|
Freetype::Freetype
|
2023-05-09 01:12:45 +08:00
|
|
|
PkgConfig::FRIBIDI
|
|
|
|
PkgConfig::HARFBUZZ
|
2022-05-20 05:14:39 +08:00
|
|
|
${FONT_LIBRARY})
|
2019-01-24 11:47:28 -08:00
|
|
|
|
|
|
|
install(TARGETS ass
|
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
ARCHIVE DESTINATION lib)
|
|
|
|
|
2019-02-01 14:11:01 -05:00
|
|
|
# pkgconfig file
|
|
|
|
set(prefix ${CMAKE_INSTALL_PREFIX})
|
|
|
|
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
|
|
|
|
set(libdir ${CMAKE_INSTALL_PREFIX}/lib)
|
|
|
|
set(includedir ${CMAKE_INSTALL_PREFIX}/include)
|
|
|
|
set(PACKAGE_VERSION ${LIBASS_VERSION})
|
2022-05-20 05:14:39 +08:00
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
set(PKG_REQUIRES_PUBLIC ${PKG_REQUIRES_LIBASS})
|
|
|
|
set(PKG_LIBS_PUBLIC ${PKG_LIBS_LIBASS})
|
2023-05-09 01:12:45 +08:00
|
|
|
else()
|
|
|
|
set(PKG_REQUIRES_PRIVATE ${PKG_REQUIRES_LIBASS})
|
|
|
|
set(PKG_LIBS_PRIVATE ${PKG_LIBS_LIBASS})
|
2021-09-29 23:44:05 +08:00
|
|
|
endif()
|
2019-02-01 14:11:01 -05:00
|
|
|
configure_file(libass.pc.in libass.pc @ONLY)
|
|
|
|
install(FILES
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/libass.pc
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|