Merge pull request #3185

852378ac cmake: ZBar - Android support, fix find_package without pkg-config (xiphon)
This commit is contained in:
Alexander Blair 2020-10-28 00:40:22 -07:00
commit 299067a273
No known key found for this signature in database
GPG key ID: C64552D877C32479
2 changed files with 25 additions and 9 deletions

View file

@ -134,7 +134,7 @@ message(STATUS "OpenSSL: libraries at ${OPENSSL_LIBRARIES} ${OPENSSL_SSL_LIBRARI
# Zbar (for QR scanner) # Zbar (for QR scanner)
if(WITH_SCANNER) if(WITH_SCANNER)
add_definitions(-DWITH_SCANNER) add_definitions(-DWITH_SCANNER)
find_package(ZBar0) find_package(ZBar0 REQUIRED)
message(STATUS "libzbar: include dir at ${ZBAR_INCLUDE_DIR}") message(STATUS "libzbar: include dir at ${ZBAR_INCLUDE_DIR}")
message(STATUS "libzbar: libraries at ${ZBAR_LIBRARIES}") message(STATUS "libzbar: libraries at ${ZBAR_LIBRARIES}")
endif() endif()

View file

@ -9,14 +9,30 @@
# #
find_package(PkgConfig) find_package(PkgConfig)
pkg_check_modules(PC_ZBAR QUIET zbar) if(PkgConfig_FOUND)
set(ZBAR_DEFINITIONS ${PC_ZBAR_CFLAGS_OTHER}) pkg_check_modules(PC_ZBAR QUIET zbar)
find_library(ZBAR_LIBRARIES NAMES zbar if(PC_ZBAR_FOUND)
HINTS ${PC_ZBAR_LIBDIR} ${PC_ZBAR_LIBRARY_DIRS} ) set(ZBAR_DEFINITIONS ${PC_ZBAR_CFLAGS_OTHER})
find_path(ZBAR_INCLUDE_DIR Decoder.h find_library(ZBAR_LIBRARIES NAMES zbar HINTS ${PC_ZBAR_LIBDIR} ${PC_ZBAR_LIBRARY_DIRS})
HINTS ${PC_ZBAR_INCLUDEDIR} ${PC_ZBAR_INCLUDE_DIRS} find_path(ZBAR_INCLUDE_DIR Decoder.h HINTS ${PC_ZBAR_INCLUDEDIR} ${PC_ZBAR_INCLUDE_DIRS} PATH_SUFFIXES zbar)
PATH_SUFFIXES zbar ) endif()
endif()
if(NOT ZBAR_LIBRARIES AND ANDROID)
find_library(ZBARJNI_LIBRARY NAMES zbarjni)
find_library(ICONV_LIBRARY NAMES iconv)
if(ZBARJNI_LIBRARY AND ICONV_LIBRARY)
set(ZBAR_LIBRARIES ${ZBARJNI_LIBRARY} ${ICONV_LIBRARY})
endif()
endif()
if(NOT ZBAR_INCLUDE_DIR)
find_path(ZBAR_H_PATH zbar.h)
if(ZBAR_H_PATH)
set(ZBAR_INCLUDE_DIR "${ZBAR_H_PATH}/zbar")
endif()
endif()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ZBAR DEFAULT_MSG ZBAR_LIBRARIES ZBAR_INCLUDE_DIR) find_package_handle_standard_args(ZBAR DEFAULT_MSG ZBAR_LIBRARIES ZBAR_INCLUDE_DIR)
message(STATUS "Found zbar libraries ${ZBAR_LIBRARIES}") message(STATUS "Found zbar libraries ${ZBAR_LIBRARIES}")