2024-05-03 20:14:27 +00:00
|
|
|
#### Various workarounds
|
2023-05-05 10:43:22 +00:00
|
|
|
|
|
|
|
if (APPLE)
|
|
|
|
# old & new homebrew's include paths
|
|
|
|
target_include_directories(${GOLDENDICT} PRIVATE /usr/local/include /opt/homebrew/include)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
target_include_directories(${GOLDENDICT} PRIVATE
|
|
|
|
${PROJECT_SOURCE_DIR}/thirdparty)
|
|
|
|
|
|
|
|
#### Special Platform supporting libraries
|
|
|
|
|
|
|
|
if (LINUX OR BSD)
|
|
|
|
find_package(X11 REQUIRED)
|
2024-01-25 05:59:13 +00:00
|
|
|
if (X11_FOUND AND X11_Xtst_FOUND)
|
|
|
|
target_compile_definitions(${GOLDENDICT} PUBLIC HAVE_X11)
|
|
|
|
target_link_libraries(${GOLDENDICT} PRIVATE ${X11_LIBRARIES} ${X11_Xtst_LIB})
|
|
|
|
target_include_directories(${GOLDENDICT} PRIVATE ${X11_INCLUDE_DIR} ${X11_Xtst_INCLUDE_PATH})
|
|
|
|
else ()
|
|
|
|
message(FATAL_ERROR "Cannot find X11 and libXtst!")
|
|
|
|
endif ()
|
2023-05-05 10:43:22 +00:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (APPLE)
|
|
|
|
find_library(CARBON_LIBRARY Carbon REQUIRED)
|
|
|
|
target_link_libraries(${GOLDENDICT} PRIVATE ${CARBON_LIBRARY})
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
##### Finding packages from package manager
|
|
|
|
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
find_package(ZLIB REQUIRED)
|
|
|
|
find_package(BZip2 REQUIRED)
|
|
|
|
|
|
|
|
# Consider all PkgConfig dependencies as one
|
|
|
|
pkg_check_modules(PKGCONFIG_DEPS IMPORTED_TARGET
|
|
|
|
hunspell
|
|
|
|
lzo2
|
|
|
|
opencc
|
|
|
|
vorbis # .ogg
|
|
|
|
vorbisfile
|
|
|
|
liblzma
|
2024-03-20 03:08:17 +00:00
|
|
|
xapian-core
|
|
|
|
)
|
2023-05-05 10:43:22 +00:00
|
|
|
|
|
|
|
target_link_libraries(${GOLDENDICT} PRIVATE
|
|
|
|
PkgConfig::PKGCONFIG_DEPS
|
|
|
|
BZip2::BZip2
|
2023-06-01 03:39:29 +00:00
|
|
|
ZLIB::ZLIB
|
2024-01-25 07:59:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# On FreeBSD, there are two iconv, libc iconv & GNU libiconv.
|
|
|
|
# The system one is good enough, the following is a workaround to use libc iconv on freeBSD.
|
|
|
|
if (BSD STREQUAL "FreeBSD")
|
|
|
|
# Simply do nothing. libc includes iconv on freeBSD.
|
|
|
|
# LIBICONV_PLUG is a magic word to turn /usr/include/local/inconv.h, which belong to GNU libiconv, into normal iconv.h
|
|
|
|
# Same hack used by SDL https://github.com/libsdl-org/SDL/blob/d6ebbc2fa4abdbe0bd53d0ce8804a492ecb042b9/src/stdlib/SDL_iconv.c#L27-L28
|
|
|
|
target_compile_definitions(${GOLDENDICT} PUBLIC LIBICONV_PLUG)
|
|
|
|
else ()
|
|
|
|
find_package(Iconv REQUIRED)
|
|
|
|
target_link_libraries(${GOLDENDICT} PRIVATE Iconv::Iconv)
|
|
|
|
endif ()
|
2023-05-05 10:43:22 +00:00
|
|
|
|
|
|
|
if (WITH_FFMPEG_PLAYER)
|
|
|
|
pkg_check_modules(FFMPEG REQUIRED IMPORTED_TARGET
|
|
|
|
libavcodec
|
|
|
|
libavformat
|
|
|
|
libavutil
|
|
|
|
libswresample
|
2024-03-20 03:08:17 +00:00
|
|
|
)
|
2023-05-05 10:43:22 +00:00
|
|
|
target_link_libraries(${GOLDENDICT} PRIVATE PkgConfig::FFMPEG)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (WITH_EPWING_SUPPORT)
|
2023-06-01 03:39:29 +00:00
|
|
|
find_library(EB_LIBRARY eb REQUIRED)
|
|
|
|
target_link_libraries(${GOLDENDICT} PRIVATE ${EB_LIBRARY})
|
2023-05-05 10:43:22 +00:00
|
|
|
endif ()
|
|
|
|
|
2023-06-01 03:39:29 +00:00
|
|
|
if (WITH_ZIM)
|
2024-11-19 07:29:08 +00:00
|
|
|
if (APPLE)
|
2024-11-19 07:58:57 +00:00
|
|
|
|
|
|
|
# 执行 brew list 命令并捕获输出
|
|
|
|
execute_process(
|
|
|
|
COMMAND brew --prefix libzim
|
|
|
|
OUTPUT_VARIABLE LIBZIM_PATH
|
|
|
|
|
|
|
|
)
|
2024-11-19 07:59:22 +00:00
|
|
|
message(STATUS "zim path:${LIBZIM_PATH}")
|
2024-11-19 07:44:21 +00:00
|
|
|
# ICU from homebrew is "key-only", we need to manually prioritize it -> see `brew info icu4c`
|
2024-11-19 07:58:57 +00:00
|
|
|
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${LIBZIM_PATH}/lib/pkgconfig")
|
2024-11-19 07:44:21 +00:00
|
|
|
endif ()
|
2023-06-01 03:39:29 +00:00
|
|
|
pkg_check_modules(ZIM REQUIRED IMPORTED_TARGET libzim)
|
2023-05-27 04:12:16 +00:00
|
|
|
target_link_libraries(${GOLDENDICT} PRIVATE PkgConfig::ZIM)
|
2024-11-15 20:13:34 +00:00
|
|
|
|
2024-09-10 09:52:23 +00:00
|
|
|
if (APPLE)
|
2024-11-19 07:11:15 +00:00
|
|
|
# 执行 brew list 命令并捕获输出
|
|
|
|
execute_process(
|
|
|
|
COMMAND brew --prefix icu4c
|
|
|
|
OUTPUT_VARIABLE BREW_OUTPUT
|
|
|
|
ERROR_VARIABLE BREW_ERROR
|
|
|
|
RESULT_VARIABLE BREW_RESULT
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# 输出 brew 命令的结果
|
|
|
|
message(STATUS "icu4c path:${BREW_OUTPUT}")
|
2024-11-18 05:47:49 +00:00
|
|
|
# 查找 ICU 库
|
2024-11-19 06:21:20 +00:00
|
|
|
# 设置 CMAKE_PREFIX_PATH
|
2024-11-19 07:46:41 +00:00
|
|
|
set(ICU_DEBUG ON)
|
2024-11-19 07:19:39 +00:00
|
|
|
set(ICU_ROOT "${BREW_OUTPUT}")
|
2024-11-19 07:54:54 +00:00
|
|
|
find_package(ICU COMPONENTS i18n data uc)
|
2024-11-19 06:23:09 +00:00
|
|
|
message(STATUS "ICU_LIBRARIES: ${ICU_LIBRARIES}")
|
|
|
|
|
2024-11-18 06:12:06 +00:00
|
|
|
target_link_libraries(${GOLDENDICT} PRIVATE ${ICU_LIBRARIES})
|
2024-09-10 09:52:23 +00:00
|
|
|
endif ()
|
2023-06-01 03:39:29 +00:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (USE_SYSTEM_FMT)
|
|
|
|
find_package(fmt)
|
|
|
|
target_link_libraries(${GOLDENDICT} PRIVATE fmt::fmt)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (USE_SYSTEM_TOML)
|
|
|
|
find_package(tomlplusplus)
|
|
|
|
target_link_libraries(${GOLDENDICT} PRIVATE tomlplusplus::tomlplusplus)
|
2024-10-10 01:11:57 +00:00
|
|
|
endif ()
|