Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ if(BUILD_TESTING)
endif()

if (NOT LIBAPPIMAGE_SHARED_ONLY)
import_pkgconfig_target(TARGET_NAME liblzma PKGCONFIG_TARGET liblzma)
import_pkgconfig_target(TARGET_NAME liblzma PKGCONFIG_TARGETS liblzma)

import_pkgconfig_target(TARGET_NAME libzstd PKGCONFIG_TARGET libzstd)
import_pkgconfig_target(TARGET_NAME libzstd PKGCONFIG_TARGETS libzstd)


# as distros don't provide suitable squashfuse and squashfs-tools, those dependencies are bundled in, can, and should
Expand All @@ -53,7 +53,7 @@ if (NOT LIBAPPIMAGE_SHARED_ONLY)
message(STATUS "Downloading and building squashfuse")

# Check if fuse is installed to provide early error reports
import_pkgconfig_target(TARGET_NAME libfuse PKGCONFIG_TARGET fuse)
import_pkgconfig_target(TARGET_NAME libfuse PKGCONFIG_TARGETS fuse fuse3)

# TODO: implement out-of-source builds for squashfuse, as for the other dependencies

Expand Down Expand Up @@ -88,7 +88,7 @@ if (NOT LIBAPPIMAGE_SHARED_ONLY)
else()
message(STATUS "Using system squashfuse")

import_pkgconfig_target(TARGET_NAME libsquashfuse PKGCONFIG_TARGET squashfuse)
import_pkgconfig_target(TARGET_NAME libsquashfuse PKGCONFIG_TARGETS squashfuse)
endif()

message(STATUS "Using system libarchive")
Expand Down
12 changes: 6 additions & 6 deletions cmake/imported_dependencies.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ include(${CMAKE_CURRENT_LIST_DIR}/scripts.cmake)
# this is especially an issue with libcairo, where the library is called libcairo
# therefore, all libs imported this way have been prefixed with lib
if(NOT @LIBAPPIMAGE_SHARED_ONLY@)
import_pkgconfig_target(TARGET_NAME libglib PKGCONFIG_TARGET glib-2.0>=2.40)
import_pkgconfig_target(TARGET_NAME libgobject PKGCONFIG_TARGET gobject-2.0>=2.40)
import_pkgconfig_target(TARGET_NAME libgio PKGCONFIG_TARGET gio-2.0>=2.40)
import_pkgconfig_target(TARGET_NAME libzlib PKGCONFIG_TARGET zlib)
import_pkgconfig_target(TARGET_NAME libcairo PKGCONFIG_TARGET cairo)
import_pkgconfig_target(TARGET_NAME librsvg PKGCONFIG_TARGET librsvg-2.0)
import_pkgconfig_target(TARGET_NAME libglib PKGCONFIG_TARGETS "glib-2.0>=2.40")
import_pkgconfig_target(TARGET_NAME libgobject PKGCONFIG_TARGETS "gobject-2.0>=2.40")
import_pkgconfig_target(TARGET_NAME libgio PKGCONFIG_TARGETS "gio-2.0>=2.40")
import_pkgconfig_target(TARGET_NAME libzlib PKGCONFIG_TARGETS "zlib")
import_pkgconfig_target(TARGET_NAME libcairo PKGCONFIG_TARGETS "cairo")
import_pkgconfig_target(TARGET_NAME librsvg PKGCONFIG_TARGETS "librsvg-2.0")
endif()
41 changes: 24 additions & 17 deletions cmake/scripts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,16 @@ endfunction()
# - pkg_config_target: librar(y name to pass to pkg-config (may include a version)
function(import_pkgconfig_target)
set(keywords STATIC OPTIONAL)
set(oneValueArgs TARGET_NAME PKGCONFIG_TARGET)
cmake_parse_arguments(IMPORT_PKGCONFIG_TARGET "${keywords}" "${oneValueArgs}" "" "${ARGN}")
set(oneValueArgs TARGET_NAME)
set(multiValueArgs PKGCONFIG_TARGETS)
cmake_parse_arguments(IMPORT_PKGCONFIG_TARGET "${keywords}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")

# check whether parameters have been set
if(NOT IMPORT_PKGCONFIG_TARGET_TARGET_NAME)
message(FATAL_ERROR "TARGET_NAME parameter missing, but is required")
endif()
if(NOT IMPORT_PKGCONFIG_TARGET_PKGCONFIG_TARGET)
message(FATAL_ERROR "PKGCONFIG_TARGET parameter missing, but is required")
if(NOT IMPORT_PKGCONFIG_TARGET_PKGCONFIG_TARGETS)
message(FATAL_ERROR "PKGCONFIG_TARGETS parameter missing, but is required")
endif()

find_package(PkgConfig REQUIRED)
Expand All @@ -104,25 +105,31 @@ function(import_pkgconfig_target)
set(type "static")
endif()

message(STATUS "Importing target ${IMPORT_PKGCONFIG_TARGET_TARGET_NAME} via pkg-config (${IMPORT_PKGCONFIG_TARGET_PKGCONFIG_TARGET}, ${type})")
message(STATUS "Importing target ${IMPORT_PKGCONFIG_TARGET_TARGET_NAME} via pkg-config (${IMPORT_PKGCONFIG_TARGET_PKGCONFIG_TARGETS}, ${type})")

if(NOT IMPORT_PKGCONFIG_TARGET_OPTIONAL)
set(extra_args REQUIRED)
endif()
foreach(pkgconfig_target ${IMPORT_PKGCONFIG_TARGET_PKGCONFIG_TARGETS})
pkg_check_modules(${IMPORT_PKGCONFIG_TARGET_TARGET_NAME}-IMPORTED ${pkgconfig_target} ${extra_args})

if(NOT ${IMPORT_PKGCONFIG_TARGET_TARGET_NAME}-IMPORTED_FOUND AND IMPORT_PKGCONFIG_TARGET_OPTIONAL)
continue()
endif()

pkg_check_modules(${IMPORT_PKGCONFIG_TARGET_TARGET_NAME}-IMPORTED ${IMPORT_PKGCONFIG_TARGET_PKGCONFIG_TARGET} ${extra_args})
message(STATUS "Found pkg-config target ${pkgconfig_target}, importing")

if(IMPORT_PKGCONFIG_TARGET_STATIC)
set(prefix ${IMPORT_PKGCONFIG_TARGET_TARGET_NAME}-IMPORTED_STATIC)
else()
set(prefix ${IMPORT_PKGCONFIG_TARGET_TARGET_NAME}-IMPORTED)
endif()

import_library_from_prefix(${IMPORT_PKGCONFIG_TARGET_TARGET_NAME} ${prefix})

if(NOT ${IMPORT_PKGCONFIG_TARGET_TARGET_NAME}-IMPORTED_FOUND AND IMPORT_PKGCONFIG_TARGET_OPTIONAL)
return()
endif()
endforeach()

if(IMPORT_PKGCONFIG_TARGET_STATIC)
set(prefix ${IMPORT_PKGCONFIG_TARGET_TARGET_NAME}-IMPORTED_STATIC)
else()
set(prefix ${IMPORT_PKGCONFIG_TARGET_TARGET_NAME}-IMPORTED)
if(NOT IMPORT_PKGCONFIG_TARGET_OPTIONAL)
message(FATAL_ERROR "pkg-config could not find required packages ${IMPORT_PKGCONFIG_TARGET_PKGCONFIG_TARGETS}")
endif()

import_library_from_prefix(${IMPORT_PKGCONFIG_TARGET_TARGET_NAME} ${prefix})
endfunction()

function(import_find_pkg_target target_name pkg_name variable_prefix)
Expand Down
Loading