From 156e94588d6b968afc76f8407c681d4827908118 Mon Sep 17 00:00:00 2001 From: Salah-Eddine Missri Date: Mon, 29 Jan 2018 16:20:14 +0100 Subject: [PATCH 1/3] Quiet find optional libraries OpenCV/Iconv --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dbabad9..6f7e899 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,7 @@ if(WIN32) endif() # OpenCV classes -find_package(OpenCV) +find_package(OpenCV QUIET) if(OpenCV_FOUND) list(APPEND LIBZXING_FILES opencv/src/zxing/MatSource.cpp @@ -58,7 +58,7 @@ include_directories(core/src) add_library(libzxing ${LIBZXING_FILES}) set_target_properties(libzxing PROPERTIES PREFIX "") -find_package(Iconv) +find_package(Iconv QUIET) if(ICONV_FOUND) include_directories(${ICONV_INCLUDE_DIR}) target_link_libraries(libzxing ${ICONV_LIBRARIES}) From 2013ea02fb84f6688ac63689d1e2cbcb672fe6e2 Mon Sep 17 00:00:00 2001 From: Salah-Eddine Missri Date: Tue, 30 Jan 2018 14:44:42 +0100 Subject: [PATCH 2/3] Append suffix to library only when built in Debug mode --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f7e899..c392e6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,9 @@ include(source_files.cmake) if(WIN32) include_directories(core/lib/win32) - set(CMAKE_DEBUG_POSTFIX -debug) + if(CMAKE_BUILD_TYPE EQUAL Debug) + set(CMAKE_DEBUG_POSTFIX d) + endif() endif() # OpenCV classes From f33dc09894745d14ba60f5a3643b8fc2f6977ed4 Mon Sep 17 00:00:00 2001 From: Salah-Eddine Missri Date: Wed, 31 Jan 2018 18:18:41 +0100 Subject: [PATCH 3/3] Export symbols to compile correctly on Windows --- CMakeLists.txt | 19 ++++++++---- core/src/zxing/BarcodeFormat.h | 6 ++-- core/src/zxing/DecodeHints.h | 55 +++++++++++++++++----------------- 3 files changed, 46 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c392e6e..50fca6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,9 +57,16 @@ if(OpenCV_FOUND) endif() include_directories(core/src) -add_library(libzxing ${LIBZXING_FILES}) +add_library(libzxing SHARED ${LIBZXING_FILES}) set_target_properties(libzxing PROPERTIES PREFIX "") +include(GenerateExportHeader) +generate_export_header(libzxing EXPORT_FILE_NAME ${CMAKE_BINARY_DIR}/zxing_export.h) +target_include_directories(libzxing PUBLIC + $ + $ +) + find_package(Iconv QUIET) if(ICONV_FOUND) include_directories(${ICONV_INCLUDE_DIR}) @@ -87,13 +94,15 @@ file(GLOB_RECURSE ZXING_FILES add_executable(zxing ${ZXING_FILES}) target_link_libraries(zxing libzxing) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zxing_export.h + DESTINATION include +) install(TARGETS zxing libzxing EXPORT zxing-targets - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin - ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin + ARCHIVE DESTINATION lib INCLUDES DESTINATION include ) - install(EXPORT zxing-targets DESTINATION lib/zxing/cmake NAMESPACE zxing::) install( diff --git a/core/src/zxing/BarcodeFormat.h b/core/src/zxing/BarcodeFormat.h index f9d123d..21c72b7 100644 --- a/core/src/zxing/BarcodeFormat.h +++ b/core/src/zxing/BarcodeFormat.h @@ -21,6 +21,8 @@ * limitations under the License. */ +#include + namespace zxing { class BarcodeFormat { @@ -48,11 +50,11 @@ class BarcodeFormat { UPC_EAN_EXTENSION }; - BarcodeFormat(Value v) : value(v) {} + BarcodeFormat(Value v) : value(v) {} const Value value; operator Value () const {return value;} - static char const* barcodeFormatNames[]; + static LIBZXING_EXPORT char const* barcodeFormatNames[]; }; } diff --git a/core/src/zxing/DecodeHints.h b/core/src/zxing/DecodeHints.h index 57b1c65..82f2b14 100644 --- a/core/src/zxing/DecodeHints.h +++ b/core/src/zxing/DecodeHints.h @@ -20,6 +20,7 @@ * limitations under the License. */ +#include #include #include @@ -35,34 +36,34 @@ class DecodeHints { Ref callback; public: - static const DecodeHintType AZTEC_HINT = 1 << BarcodeFormat::AZTEC; - static const DecodeHintType CODABAR_HINT = 1 << BarcodeFormat::CODABAR; - static const DecodeHintType CODE_39_HINT = 1 << BarcodeFormat::CODE_39; - static const DecodeHintType CODE_93_HINT = 1 << BarcodeFormat::CODE_93; - static const DecodeHintType CODE_128_HINT = 1 << BarcodeFormat::CODE_128; - static const DecodeHintType DATA_MATRIX_HINT = 1 << BarcodeFormat::DATA_MATRIX; - static const DecodeHintType EAN_8_HINT = 1 << BarcodeFormat::EAN_8; - static const DecodeHintType EAN_13_HINT = 1 << BarcodeFormat::EAN_13; - static const DecodeHintType ITF_HINT = 1 << BarcodeFormat::ITF; - static const DecodeHintType MAXICODE_HINT = 1 << BarcodeFormat::MAXICODE; - static const DecodeHintType PDF_417_HINT = 1 << BarcodeFormat::PDF_417; - static const DecodeHintType QR_CODE_HINT = 1 << BarcodeFormat::QR_CODE; - static const DecodeHintType RSS_14_HINT = 1 << BarcodeFormat::RSS_14; - static const DecodeHintType RSS_EXPANDED_HINT = 1 << BarcodeFormat::RSS_EXPANDED; - static const DecodeHintType UPC_A_HINT = 1 << BarcodeFormat::UPC_A; - static const DecodeHintType UPC_E_HINT = 1 << BarcodeFormat::UPC_E; - static const DecodeHintType UPC_EAN_EXTENSION_HINT = 1 << BarcodeFormat::UPC_EAN_EXTENSION; + static LIBZXING_EXPORT const DecodeHintType AZTEC_HINT = 1 << BarcodeFormat::AZTEC; + static LIBZXING_EXPORT const DecodeHintType CODABAR_HINT = 1 << BarcodeFormat::CODABAR; + static LIBZXING_EXPORT const DecodeHintType CODE_39_HINT = 1 << BarcodeFormat::CODE_39; + static LIBZXING_EXPORT const DecodeHintType CODE_93_HINT = 1 << BarcodeFormat::CODE_93; + static LIBZXING_EXPORT const DecodeHintType CODE_128_HINT = 1 << BarcodeFormat::CODE_128; + static LIBZXING_EXPORT const DecodeHintType DATA_MATRIX_HINT = 1 << BarcodeFormat::DATA_MATRIX; + static LIBZXING_EXPORT const DecodeHintType EAN_8_HINT = 1 << BarcodeFormat::EAN_8; + static LIBZXING_EXPORT const DecodeHintType EAN_13_HINT = 1 << BarcodeFormat::EAN_13; + static LIBZXING_EXPORT const DecodeHintType ITF_HINT = 1 << BarcodeFormat::ITF; + static LIBZXING_EXPORT const DecodeHintType MAXICODE_HINT = 1 << BarcodeFormat::MAXICODE; + static LIBZXING_EXPORT const DecodeHintType PDF_417_HINT = 1 << BarcodeFormat::PDF_417; + static LIBZXING_EXPORT const DecodeHintType QR_CODE_HINT = 1 << BarcodeFormat::QR_CODE; + static LIBZXING_EXPORT const DecodeHintType RSS_14_HINT = 1 << BarcodeFormat::RSS_14; + static LIBZXING_EXPORT const DecodeHintType RSS_EXPANDED_HINT = 1 << BarcodeFormat::RSS_EXPANDED; + static LIBZXING_EXPORT const DecodeHintType UPC_A_HINT = 1 << BarcodeFormat::UPC_A; + static LIBZXING_EXPORT const DecodeHintType UPC_E_HINT = 1 << BarcodeFormat::UPC_E; + static LIBZXING_EXPORT const DecodeHintType UPC_EAN_EXTENSION_HINT = 1 << BarcodeFormat::UPC_EAN_EXTENSION; - static const DecodeHintType TRYHARDER_HINT = 1 << 31; - static const DecodeHintType CHARACTER_SET = 1 << 30; - // static const DecodeHintType ALLOWED_LENGTHS = 1 << 29; - // static const DecodeHintType ASSUME_CODE_39_CHECK_DIGIT = 1 << 28; - static const DecodeHintType ASSUME_GS1 = 1 << 27; - // static const DecodeHintType NEED_RESULT_POINT_CALLBACK = 1 << 26; - - static const DecodeHints PRODUCT_HINT; - static const DecodeHints ONED_HINT; - static const DecodeHints DEFAULT_HINT; + static LIBZXING_EXPORT const DecodeHintType TRYHARDER_HINT = 1 << 31; + static LIBZXING_EXPORT const DecodeHintType CHARACTER_SET = 1 << 30; + // static LIBZXING_EXPORT const DecodeHintType ALLOWED_LENGTHS = 1 << 29; + // static LIBZXING_EXPORT const DecodeHintType ASSUME_CODE_39_CHECK_DIGIT = 1 << 28; + static LIBZXING_EXPORT const DecodeHintType ASSUME_GS1 = 1 << 27; + // static LIBZXING_EXPORT const DecodeHintType NEED_RESULT_POINT_CALLBACK = 1 << 26; + + static LIBZXING_EXPORT const DecodeHints PRODUCT_HINT; + static LIBZXING_EXPORT const DecodeHints ONED_HINT; + static LIBZXING_EXPORT const DecodeHints DEFAULT_HINT; DecodeHints(); DecodeHints(DecodeHintType init);