diff --git a/driver/CMakeLists.txt b/driver/CMakeLists.txt index 848d835..bf543f9 100644 --- a/driver/CMakeLists.txt +++ b/driver/CMakeLists.txt @@ -10,6 +10,7 @@ option(LPAC_WITH_HTTP_CURL "Build HTTP Curl interface" ON) aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} DIR_INTERFACE_SRCS) if(LPAC_DYNAMIC_DRIVERS) add_library(euicc-drivers SHARED ${DIR_INTERFACE_SRCS}) + list(APPEND LIBEUICC_DRIVERS_REQUIRES "libeuicc = ${PROJECT_VERSION}") else() add_library(euicc-drivers STATIC ${DIR_INTERFACE_SRCS}) endif() @@ -26,9 +27,16 @@ if(LPAC_WITH_APDU_PCSC) target_link_libraries(euicc-drivers winscard) elseif(APPLE) target_link_libraries(euicc-drivers "-framework PCSC") + if(LPAC_DYNAMIC_DRIVERS) + # for pkg-config + set(LIBEUICC_DRIVERS_EXTRA_CFLAGS "-framework PCSC") + endif() else() find_package(PCSCLite) target_link_libraries(euicc-drivers PCSCLite::PCSCLite) + if(LPAC_DYNAMIC_DRIVERS) + list(APPEND LIBEUICC_DRIVERS_REQUIRES "libpcsclite") + endif() endif() endif() @@ -44,6 +52,10 @@ if(LPAC_WITH_APDU_GBINDER) pkg_check_modules(GBINDER REQUIRED IMPORTED_TARGET libgbinder) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) target_link_libraries(euicc-drivers PkgConfig::GBINDER PkgConfig::GLIB) + if(LPAC_DYNAMIC_DRIVERS) + list(APPEND LIBEUICC_DRIVERS_REQUIRES "libgbinder") + list(APPEND LIBEUICC_DRIVERS_REQUIRES "glib-2.0") + endif() endif() if(LPAC_WITH_HTTP_CURL) @@ -54,6 +66,9 @@ if(LPAC_WITH_HTTP_CURL) else() find_package(curl) target_link_libraries(euicc-drivers curl) + if(LPAC_DYNAMIC_DRIVERS) + list(APPEND LIBEUICC_DRIVERS_REQUIRES "libcurl") + endif() endif() endif() @@ -66,9 +81,12 @@ if(LPAC_DYNAMIC_DRIVERS) endif() endforeach() set_target_properties(euicc-drivers PROPERTIES PUBLIC_HEADER "${ALL_HEADERS}") - # Install a pkg-config file - configure_file(libeuicc-drivers.pc.in libeuicc-drivers.pc @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libeuicc-drivers.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + # Install a pkg-config file (mainly for Linux; macOS is untested; Win32 is not supported) + if(UNIX) + list(JOIN LIBEUICC_DRIVERS_REQUIRES ", " LIBEUICC_DRIVERS_REQUIRES) + configure_file(libeuicc-drivers.pc.in libeuicc-drivers.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libeuicc-drivers.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + endif() set_target_properties(euicc-drivers PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR}) install(TARGETS euicc-drivers LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/euicc) diff --git a/driver/libeuicc-drivers.pc.in b/driver/libeuicc-drivers.pc.in index e99ba8e..2ea330c 100644 --- a/driver/libeuicc-drivers.pc.in +++ b/driver/libeuicc-drivers.pc.in @@ -6,6 +6,6 @@ includedir="${prefix}/include" Name: libeuicc-drivers Description: An "official" collection of drivers (backends) and their loader for use with libeuicc Version: @PROJECT_VERSION@ -Requires: libeuicc = @PROJECT_VERSION@ -Cflags: -I${includedir} +Requires: @LIBEUICC_DRIVERS_REQUIRES@ +Cflags: -I${includedir} @LIBEUICC_DRIVERS_EXTRA_CFLAGS@ Libs: -L${libdir} -leuicc-drivers