Don't use webp/freetype/harfbuzz libs/includes if they're not found

Fixes #3589, #3628, #3831, #3874, #4547
This commit is contained in:
David Capello 2024-09-19 15:16:22 -03:00
parent c4e5473d1c
commit 340883a2f5
3 changed files with 28 additions and 7 deletions

View File

@ -258,16 +258,15 @@ elseif(NOT LAF_BACKEND STREQUAL "skia")
set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY})
set(FREETYPE_INCLUDE_DIRS ${FREETYPE_DIR}/include)
endif()
include_directories(${FREETYPE_INCLUDE_DIRS})
# harfbuzz
if(USE_SHARED_HARFBUZZ)
find_package(HarfBuzz)
elseif(NOT LAF_BACKEND STREQUAL "skia")
set(HARFBUZZ_FOUND ON)
set(HARFBUZZ_LIBRARIES harfbuzz)
set(HARFBUZZ_INCLUDE_DIRS ${HARFBUZZ_DIR}/src)
endif()
include_directories(${HARFBUZZ_INCLUDE_DIRS})
if(USE_SHARED_GIFLIB)
find_package(GIF REQUIRED)
@ -336,11 +335,16 @@ if(ENABLE_WEBP)
NAMES libwebp # required for Windows
PATHS "${SKIA_LIBRARY_DIR}" NO_DEFAULT_PATH)
set(WEBP_INCLUDE_DIR "${SKIA_DIR}/third_party/externals/libwebp/src")
if(WEBP_LIBRARIES)
set(WEBP_FOUND ON)
else()
set(WEBP_FOUND OFF)
endif()
else()
set(WEBP_FOUND ON)
set(WEBP_LIBRARIES webp webpdemux libwebpmux)
set(WEBP_INCLUDE_DIR ${LIBWEBP_DIR}/src)
endif()
include_directories(${WEBP_INCLUDE_DIR})
endif()
message(STATUS "aseprite libwebp: ${WEBP_LIBRARIES}")

View File

@ -143,7 +143,7 @@ target_sources(app-lib PRIVATE
file/qoi_format.cpp
file/svg_format.cpp
file/tga_format.cpp)
if(ENABLE_WEBP)
if(ENABLE_WEBP AND WEBP_FOUND)
target_compile_definitions(app-lib PUBLIC -DENABLE_WEBP)
target_sources(app-lib PRIVATE
file/webp_format.cpp)
@ -749,16 +749,28 @@ target_link_libraries(app-lib
${JPEG_LIBRARIES}
${GIF_LIBRARIES}
${PNG_LIBRARIES}
${WEBP_LIBRARIES}
${ZLIB_LIBRARIES}
${FREETYPE_LIBRARIES}
${HARFBUZZ_LIBRARIES}
json11
archive_static
fmt
tinyexpr
qoi)
if(ENABLE_WEBP AND WEBP_FOUND)
target_link_libraries(app-lib ${WEBP_LIBRARIES})
target_include_directories(app-lib PUBLIC ${WEBP_INCLUDE_DIR})
endif()
if(FREETYPE_FOUND)
target_link_libraries(app-lib ${FREETYPE_LIBRARIES})
target_include_directories(app-lib PUBLIC ${FREETYPE_INCLUDE_DIRS})
endif()
if(HARFBUZZ_FOUND)
target_link_libraries(app-lib ${HARFBUZZ_LIBRARIES})
target_include_directories(app-lib PUBLIC ${HARFBUZZ_INCLUDE_DIRS})
endif()
# Directory where generated files by "gen" utility will stay.
target_include_directories(app-lib PUBLIC ${CMAKE_CURRENT_BINARY_DIR})

View File

@ -82,6 +82,11 @@ if(NOT USE_SHARED_FREETYPE AND NOT LAF_BACKEND STREQUAL "skia")
${CMAKE_CURRENT_BINARY_DIR}/freetype2/include)
endif()
if(HARFBUZZ_FOUND)
target_link_libraries(freetype PRIVATE ${HARFBUZZ_LIBRARIES})
target_include_directories(freetype PRIVATE ${HARFBUZZ_INCLUDE_DIRS})
endif()
if(NOT USE_SHARED_LIBPNG)
add_dependencies(freetype ${PNG_LIBRARIES})
endif()