diff --git a/CMakeLists.txt b/CMakeLists.txt index 197e7c30..dcf53618 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,7 +134,7 @@ message(STATUS "OpenSSL: libraries at ${OPENSSL_LIBRARIES} ${OPENSSL_SSL_LIBRARI # Zbar (for QR scanner) if(WITH_SCANNER) add_definitions(-DWITH_SCANNER) - find_package(ZBar0) + find_package(ZBar0 REQUIRED) message(STATUS "libzbar: include dir at ${ZBAR_INCLUDE_DIR}") message(STATUS "libzbar: libraries at ${ZBAR_LIBRARIES}") endif() diff --git a/cmake/FindZBar0.cmake b/cmake/FindZBar0.cmake index efb10098..f97b2378 100644 --- a/cmake/FindZBar0.cmake +++ b/cmake/FindZBar0.cmake @@ -9,14 +9,30 @@ # find_package(PkgConfig) -pkg_check_modules(PC_ZBAR QUIET zbar) -set(ZBAR_DEFINITIONS ${PC_ZBAR_CFLAGS_OTHER}) -find_library(ZBAR_LIBRARIES NAMES zbar - HINTS ${PC_ZBAR_LIBDIR} ${PC_ZBAR_LIBRARY_DIRS} ) -find_path(ZBAR_INCLUDE_DIR Decoder.h - HINTS ${PC_ZBAR_INCLUDEDIR} ${PC_ZBAR_INCLUDE_DIRS} - PATH_SUFFIXES zbar ) +if(PkgConfig_FOUND) + pkg_check_modules(PC_ZBAR QUIET zbar) + if(PC_ZBAR_FOUND) + set(ZBAR_DEFINITIONS ${PC_ZBAR_CFLAGS_OTHER}) + find_library(ZBAR_LIBRARIES NAMES zbar HINTS ${PC_ZBAR_LIBDIR} ${PC_ZBAR_LIBRARY_DIRS}) + find_path(ZBAR_INCLUDE_DIR Decoder.h HINTS ${PC_ZBAR_INCLUDEDIR} ${PC_ZBAR_INCLUDE_DIRS} 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) find_package_handle_standard_args(ZBAR DEFAULT_MSG ZBAR_LIBRARIES ZBAR_INCLUDE_DIR) message(STATUS "Found zbar libraries ${ZBAR_LIBRARIES}") -