fix: uses libc iconv on FreeBSD

This commit is contained in:
shenleban tongying 2024-01-25 02:59:45 -05:00
parent 2acf36d421
commit 4304fc9aef

View file

@ -33,7 +33,6 @@ find_package(PkgConfig REQUIRED)
# Provided by Cmake # Provided by Cmake
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
find_package(BZip2 REQUIRED) find_package(BZip2 REQUIRED)
find_package(Iconv REQUIRED)
# Consider all PkgConfig dependencies as one # Consider all PkgConfig dependencies as one
@ -50,8 +49,19 @@ target_link_libraries(${GOLDENDICT} PRIVATE
PkgConfig::PKGCONFIG_DEPS PkgConfig::PKGCONFIG_DEPS
BZip2::BZip2 BZip2::BZip2
ZLIB::ZLIB ZLIB::ZLIB
Iconv::Iconv )
)
# 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 ()
if (WITH_FFMPEG_PLAYER) if (WITH_FFMPEG_PLAYER)
pkg_check_modules(FFMPEG REQUIRED IMPORTED_TARGET pkg_check_modules(FFMPEG REQUIRED IMPORTED_TARGET