CMake: Consistently use imported targets for third party dependencies

This commit is contained in:
Andrew Kaster 2024-06-24 13:08:41 -06:00 committed by Tim Flynn
parent 0879489084
commit a587eafbf4
Notes: sideshowbarker 2024-07-17 18:13:59 +09:00
6 changed files with 15 additions and 36 deletions

View file

@ -40,6 +40,10 @@ if (HAVE_PULSEAUDIO)
target_compile_definitions(webcontent PUBLIC HAVE_PULSEAUDIO=1)
endif()
if (HAS_FONTCONFIG)
target_link_libraries(webcontent PRIVATE Fontconfig::Fontconfig)
endif()
if (HAS_ACCELERATED_GRAPHICS)
target_compile_definitions(webcontent PUBLIC HAS_ACCELERATED_GRAPHICS)
target_link_libraries(webcontent PUBLIC LibAccelGfx)
@ -73,10 +77,6 @@ else()
add_executable(WebContent main.cpp)
endif()
if (HAS_FONTCONFIG)
target_link_libraries(webcontent PRIVATE Fontconfig::Fontconfig)
endif()
target_link_libraries(WebContent PRIVATE webcontent LibURL)
target_sources(webcontent PUBLIC FILE_SET ladybird TYPE HEADERS

View file

@ -1,11 +0,0 @@
find_package(PkgConfig)
pkg_check_modules(WOFF2 REQUIRED IMPORTED_TARGET libwoff2dec)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
WOFF2
REQUIRED_VARS
WOFF2_INCLUDE_DIRS
WOFF2_LIBRARY_DIRS
WOFF2_LIBRARIES
)

View file

@ -1,5 +1,3 @@
include(woff2)
set(SOURCES
AffineTransform.cpp
AntiAliasingPainter.cpp
@ -74,11 +72,6 @@ set(SOURCES
serenity_lib(LibGfx gfx)
target_link_libraries(LibGfx PRIVATE LibCompress LibCore LibCrypto LibFileSystem LibRIFF LibTextCodec LibIPC LibUnicode LibURL)
# Third-party
target_include_directories(LibGfx PRIVATE ${WOFF2_INCLUDE_DIRS})
target_link_libraries(LibGfx PRIVATE ${WOFF2_LIBRARIES})
target_link_directories(LibGfx PRIVATE ${WOFF2_LIBRARY_DIRS})
set(generated_sources TIFFMetadata.h TIFFTagHandler.cpp)
list(TRANSFORM generated_sources PREPEND "ImageFormats/")
@ -98,12 +91,11 @@ add_dependencies(LibGfx generate_tiff_files_handler)
list(TRANSFORM generated_sources PREPEND "${CMAKE_CURRENT_BINARY_DIR}/")
install(FILES ${generated_sources} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibGfx/ImageFormats")
find_package(JPEG REQUIRED)
target_include_directories(LibGfx PRIVATE ${JPEG_INCLUDE_DIRS})
target_link_libraries(LibGfx PRIVATE ${JPEG_LIBRARIES})
target_link_directories(LibGfx PRIVATE ${JPEG_LIBRARY_DIRS})
# Third-party
find_package(PkgConfig)
pkg_check_modules(WOFF2 REQUIRED IMPORTED_TARGET libwoff2dec)
find_package(JPEG REQUIRED)
find_package(PNG REQUIRED)
target_include_directories(LibGfx PRIVATE ${PNG_INCLUDE_DIRS})
target_link_libraries(LibGfx PRIVATE ${PNG_LIBRARIES})
target_link_directories(LibGfx PRIVATE ${PNG_LIBRARY_DIRS})
target_link_libraries(LibGfx PRIVATE PkgConfig::WOFF2 JPEG::JPEG PNG::PNG)

View file

@ -12,8 +12,7 @@ set(SOURCES
serenity_lib(LibMedia media)
target_link_libraries(LibMedia PRIVATE LibCore LibIPC LibGfx LibThreading)
# Third-party
find_package(PkgConfig REQUIRED)
pkg_check_modules(AVCODEC REQUIRED IMPORTED_TARGET libavcodec)
target_include_directories(LibMedia PRIVATE ${AVCODEC_INCLUDE_DIRS})
target_link_directories(LibMedia PRIVATE ${AVCODEC_LIBRARY_DIRS})
target_link_libraries(LibMedia PRIVATE ${AVCODEC_LIBRARIES})
target_link_libraries(LibMedia PRIVATE PkgConfig::AVCODEC)

View file

@ -26,5 +26,4 @@ set(GENERATED_SOURCES ${CURRENT_LIB_GENERATED})
serenity_lib(LibUnicode unicode)
find_package(ICU REQUIRED COMPONENTS data i18n uc)
target_include_directories(LibUnicode PRIVATE ${ICU_INCLUDE_DIRS})
target_link_libraries(LibUnicode PUBLIC ${ICU_LIBRARIES})
target_link_libraries(LibUnicode PRIVATE ICU::i18n ICU::uc ICU::data)

View file

@ -49,9 +49,9 @@ serenity_lib(LibWebView webview)
target_link_libraries(LibWebView PRIVATE LibCore LibFileSystem LibGfx LibIPC LibProtocol LibJS LibWeb LibUnicode LibURL)
target_compile_definitions(LibWebView PRIVATE ENABLE_PUBLIC_SUFFIX=$<BOOL:${ENABLE_PUBLIC_SUFFIX_DOWNLOAD}>)
# Third-party
find_package(SQLite3 REQUIRED)
target_include_directories(LibWebView PRIVATE ${SQLite3_INCLUDE_DIRS})
target_link_libraries(LibWebView PRIVATE ${SQLite3_LIBRARIES})
target_link_libraries(LibWebView PRIVATE SQLite::SQLite3)
foreach(header ${GENERATED_SOURCES})
get_filename_component(extension ${header} EXT)