diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 98f11472..e2b7d39f 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -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 @@ -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 @@ -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") diff --git a/cmake/imported_dependencies.cmake.in b/cmake/imported_dependencies.cmake.in index 402fa4c3..f97517de 100644 --- a/cmake/imported_dependencies.cmake.in +++ b/cmake/imported_dependencies.cmake.in @@ -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() diff --git a/cmake/scripts.cmake b/cmake/scripts.cmake index 0228e739..e544004d 100644 --- a/cmake/scripts.cmake +++ b/cmake/scripts.cmake @@ -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) @@ -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)