diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ebebeae7f8..7526282cb0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,8 @@ jobs: - name: Configure run: > cmake -S . -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_SHARED_LIBS=ON - -DBUILD_BLACKBOX_TESTS=ON -DBUILD_UNIT_TESTS=ON -DBUILD_PYTHON_MODULE=ON -DBUILD_C_API=ON + -DZXING_READERS=ON -DZXING_WRITERS=ON + -DZXING_BLACKBOX_TESTS=ON -DZXING_UNIT_TESTS=ON -DZXING_PYTHON_MODULE=ON -DZXING_C_API=ON - name: Build run: cmake --build build -j8 --config ${{env.BUILD_TYPE}} @@ -67,7 +68,8 @@ jobs: - name: Configure run: > cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo - -DBUILD_BLACKBOX_TESTS=ON -DBUILD_UNIT_TESTS=ON -DBUILD_PYTHON_MODULE=OFF -DBUILD_C_API=OFF + -DZXING_READERS=ON -DZXING_WRITERS=ON + -DZXING_BLACKBOX_TESTS=ON -DZXING_UNIT_TESTS=ON -DZXING_PYTHON_MODULE=OFF -DZXING_C_API=OFF -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-march=native -fsanitize=address,undefined -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer" -DCMAKE_C_COMPILER=clang @@ -242,7 +244,7 @@ jobs: run: > cmake -S wrappers/winrt -B build -A ARM64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 -DCMAKE_BUILD_TYPE=Release - -DBUILD_WINRT_LIB=ON -DBUILD_EXAMPLES=OFF -DBUILD_BLACKBOX_TESTS=OFF -DBUILD_C_API=OFF + -DBUILD_WINRT_LIB=ON -DZXING_EXAMPLES=OFF -DZXING_BLACKBOX_TESTS=OFF -DZXING_C_API=OFF -DEXTENSION_SDK_OUTPUT=dist/UAP/v0.8.0.0/ExtensionSDKs/ZXingWinRT/1.0.0.0 - name: Build diff --git a/.github/workflows/publish-winrt.yml b/.github/workflows/publish-winrt.yml index d101766b98..6654f4585b 100644 --- a/.github/workflows/publish-winrt.yml +++ b/.github/workflows/publish-winrt.yml @@ -32,7 +32,7 @@ jobs: - name: Configure CMake shell: cmd working-directory: ${{runner.workspace}}/build - run: cmake ${{github.workspace}}/wrappers/winrt -A ${{matrix.target}} -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 -DCMAKE_BUILD_TYPE=Release -DBUILD_WINRT_LIB=ON -DBUILD_EXAMPLES=OFF -DBUILD_BLACKBOX_TESTS=OFF -DEXTENSION_SDK_OUTPUT=dist/UAP/v0.8.0.0/ExtensionSDKs/ZXingWinRT/1.0.0.0 + run: cmake ${{github.workspace}}/wrappers/winrt -A ${{matrix.target}} -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 -DCMAKE_BUILD_TYPE=Release -DBUILD_WINRT_LIB=ON -DZXING_EXAMPLES=OFF -DZXING_BLACKBOX_TESTS=OFF -DEXTENSION_SDK_OUTPUT=dist/UAP/v0.8.0.0/ExtensionSDKs/ZXingWinRT/1.0.0.0 - name: Build shell: cmd diff --git a/CMakeLists.txt b/CMakeLists.txt index 24b1b52970..83d09f7b12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,17 +2,16 @@ cmake_minimum_required(VERSION 3.15) project(ZXing) -# option (BUILD_WRITERS "Build with writer support (encoders)" ON) -set(BUILD_WRITERS "ON" CACHE STRING "Build with old and/or new writer (encoder) backend (OFF/ON/OLD/NEW/BOTH)") -option (BUILD_READERS "Build with reader support (decoders)" ON) -option (BUILD_EXAMPLES "Build the example barcode reader/writer applications" ON) -option (BUILD_BLACKBOX_TESTS "Build the black box reader/writer tests" OFF) -option (BUILD_UNIT_TESTS "Build the unit tests (don't enable for production builds)" OFF) -option (BUILD_PYTHON_MODULE "Build the python module" OFF) -option (BUILD_C_API "Build the C-API" OFF) -option (BUILD_EXPERIMENTAL_API "Build with experimental API" OFF) -option (ZXING_USE_BUNDLED_ZINT "Use the bundled libzint for barcode creation/generation" ON) -set(BUILD_DEPENDENCIES "AUTO" CACHE STRING "Fetch from github or use locally installed (AUTO/GITHUB/LOCAL)") +option (ZXING_READERS "Build with reader support (decoders)" ON) +set (ZXING_WRITERS "ON" CACHE STRING "Build with old and/or new writer (encoder) backend (OFF/ON/OLD/NEW/BOTH)") +option (ZXING_USE_BUNDLED_ZINT "Use the bundled libzint for barcode creation/writing" ON) +option (ZXING_C_API "Build the C-API" OFF) +option (ZXING_EXPERIMENTAL_API "Build with experimental API" OFF) +option (ZXING_EXAMPLES "Build the example barcode reader/writer applications" ON) +option (ZXING_BLACKBOX_TESTS "Build the black box reader/writer tests" OFF) +option (ZXING_UNIT_TESTS "Build the unit tests (don't enable for production builds)" OFF) +option (ZXING_PYTHON_MODULE "Build the python module" OFF) +set (ZXING_DEPENDENCIES "AUTO" CACHE STRING "Fetch from github or use locally installed (AUTO/GITHUB/LOCAL)") if (WIN32) option (BUILD_SHARED_LIBS "Build and link as shared library" OFF) @@ -22,8 +21,8 @@ endif() if (MSVC) add_definitions (-DUNICODE -D_UNICODE -D_CRT_SECURE_NO_WARNINGS) - option (LINK_CPP_STATICALLY "MSVC only, link standard library statically (/MT and /MTd)" OFF) - if (LINK_CPP_STATICALLY) + option (ZXING_LINK_CPP_STATICALLY "MSVC only, link standard library statically (/MT and /MTd)" OFF) + if (LINK_CPP_STATICALLY OR ZXING_LINK_CPP_STATICALLY) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() endif() @@ -35,26 +34,46 @@ if (NOT CMAKE_BUILD_TYPE) set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() -if (NOT (BUILD_READERS OR BUILD_WRITERS)) - message(FATAL_ERROR "At least one of BUILD_READERS/BUILD_WRITERS must be enabled.") +# provide backward compatibility for deprecated BUILD_... options +if (DEFINED BUILD_READERS) + set (ZXING_READERS ${BUILD_READERS}) +endif() +if (DEFINED BUILD_WRITERS) + set (ZXING_WRITERS ${BUILD_WRITERS}) +endif() +if (DEFINED BUILD_EXAMPLES) + message (WARNING "zxing-cpp cmake options BUILD_... are deprecated, please switch to ZXING_... variant") + set (ZXING_EXAMPLES ${BUILD_EXAMPLES}) +endif() +if (DEFINED BUILD_PYTHON_MODULE) + message (WARNING "zxing-cpp cmake options BUILD_... are deprecated, please switch to ZXING_... variant") + set (ZXING_PYTHON_MODULE ${BUILD_PYTHON_MODULE}) +endif() +if (DEFINED BUILD_DEPENDENCIES) + message (WARNING "zxing-cpp cmake options BUILD_... are deprecated, please switch to ZXING_... variant") + set (ZXING_DEPENDENCIES ${BUILD_DEPENDENCIES}) +endif() + +if (NOT (ZXING_READERS OR ZXING_WRITERS)) + message(FATAL_ERROR "At least one of ZXING_READERS/ZXING_WRITERS must be enabled.") endif() -if (BUILD_UNIT_TESTS AND (NOT BUILD_WRITERS OR NOT BUILD_READERS)) +if (ZXING_UNIT_TESTS AND (NOT ZXING_WRITERS OR NOT ZXING_READERS)) message("Note: To build with unit tests, the library will be build with READERS and WRITERS.") - set (BUILD_WRITERS ON) - set (BUILD_READERS ON) + set (ZXING_WRITERS ON) + set (ZXING_READERS ON) endif() -set(BUILD_WRITERS_LIST OFF ON OLD NEW BOTH) -set_property(CACHE BUILD_WRITERS PROPERTY STRINGS ${BUILD_WRITERS_LIST}) -if(NOT BUILD_WRITERS IN_LIST BUILD_WRITERS_LIST) - message(FATAL_ERROR "BUILD_WRITERS must be one of ${BUILD_WRITERS_LIST}") +set(ZXING_WRITERS_LIST OFF ON OLD NEW BOTH) +set_property(CACHE ZXING_WRITERS PROPERTY STRINGS ${ZXING_WRITERS_LIST}) +if(NOT ZXING_WRITERS IN_LIST ZXING_WRITERS_LIST) + message(FATAL_ERROR "ZXING_WRITERS must be one of ${ZXING_WRITERS_LIST}") endif() -set(BUILD_DEPENDENCIES_LIST AUTO GITHUB LOCAL) -set_property(CACHE BUILD_DEPENDENCIES PROPERTY STRINGS ${BUILD_DEPENDENCIES_LIST}) -if(NOT BUILD_DEPENDENCIES IN_LIST BUILD_DEPENDENCIES_LIST) - message(FATAL_ERROR "BUILD_DEPENDENCIES must be one of ${BUILD_DEPENDENCIES_LIST}") +set(ZXING_DEPENDENCIES_LIST AUTO GITHUB LOCAL) +set_property(CACHE ZXING_DEPENDENCIES PROPERTY STRINGS ${ZXING_DEPENDENCIES_LIST}) +if(NOT ZXING_DEPENDENCIES IN_LIST ZXING_DEPENDENCIES_LIST) + message(FATAL_ERROR "ZXING_DEPENDENCIES must be one of ${ZXING_DEPENDENCIES_LIST}") endif() if (NOT DEFINED CMAKE_CXX_STANDARD) @@ -70,18 +89,18 @@ enable_testing() include(zxing.cmake) -if (BUILD_EXAMPLES) +if (ZXING_EXAMPLES) add_subdirectory (example) endif() -if (BUILD_BLACKBOX_TESTS) +if (ZXING_BLACKBOX_TESTS) add_subdirectory (test/blackbox) endif() -if (BUILD_UNIT_TESTS) +if (ZXING_UNIT_TESTS) add_subdirectory (test/unit) endif() -if (BUILD_PYTHON_MODULE) +if (ZXING_PYTHON_MODULE) add_subdirectory (wrappers/python) endif() -if (BUILD_C_API) +if (ZXING_C_API) add_subdirectory (wrappers/c) endif() diff --git a/README.md b/README.md index 326cfe97f9..5617f43c37 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ These are the generic instructions to build the library on Windows/macOS/Linux. 1. Make sure [CMake](https://cmake.org) version 3.15 or newer is installed. 2. Make sure a C++17 compliant compiler is installed (minimum VS 2019 16.8 / gcc 7 / clang 5). -3. See the cmake `BUILD_...` options to enable the testing code, python wrapper, etc. +3. See the cmake `ZXING_...` options to enable the testing code, python wrapper, etc. ``` git clone https://github.com/zxing-cpp/zxing-cpp.git --single-branch --depth 1 diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 116b42fc9c..18facf5773 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -7,26 +7,35 @@ if (BUILD_SHARED_LIBS) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() -if (NOT DEFINED BUILD_WRITERS) - set (BUILD_WRITERS OFF) +if (DEFINED BUILD_READERS) + set (ZXING_READERS ${BUILD_READERS}) + message (WARNING "zxing-cpp cmake options BUILD_... are deprecated, please switch to ZXING_... variant") +endif() +if (DEFINED BUILD_WRITERS) + set (ZXING_WRITERS ${BUILD_WRITERS}) + message (WARNING "zxing-cpp cmake options BUILD_... are deprecated, please switch to ZXING_... variant") +endif() + +if (NOT DEFINED ZXING_WRITERS) + set (ZXING_WRITERS OFF) endif() -if (NOT DEFINED BUILD_READERS) - set (BUILD_READERS ON) +if (NOT DEFINED ZXING_READERS) + set (ZXING_READERS ON) endif() -set (BUILD_WRITERS_NEW OFF) -set (BUILD_WRITERS_OLD OFF) -if (BUILD_WRITERS MATCHES "OLD|ON") - set (BUILD_WRITERS ON) - set (BUILD_WRITERS_OLD ON) -elseif (BUILD_WRITERS MATCHES "NEW") - set (BUILD_WRITERS ON) - set (BUILD_WRITERS_NEW ON) -elseif (BUILD_WRITERS MATCHES "BOTH") - set (BUILD_WRITERS ON) - set (BUILD_WRITERS_NEW ON) - set (BUILD_WRITERS_OLD ON) +set (ZXING_WRITERS_NEW OFF) +set (ZXING_WRITERS_OLD OFF) +if (ZXING_WRITERS MATCHES "OLD|ON") + set (ZXING_WRITERS ON) + set (ZXING_WRITERS_OLD ON) +elseif (ZXING_WRITERS MATCHES "NEW") + set (ZXING_WRITERS ON) + set (ZXING_WRITERS_NEW ON) +elseif (ZXING_WRITERS MATCHES "BOTH") + set (ZXING_WRITERS ON) + set (ZXING_WRITERS_NEW ON) + set (ZXING_WRITERS_OLD ON) endif() if (BUILD_SHARED_LIBS) @@ -34,7 +43,7 @@ if (BUILD_SHARED_LIBS) endif() set (ZXING_PUBLIC_FLAGS - $<$:-DZXING_BUILD_EXPERIMENTAL_API> + $<$:-DZXING_BUILD_EXPERIMENTAL_API> ) if (WINRT) set (ZXING_PUBLIC_FLAGS ${ZXING_PUBLIC_FLAGS} @@ -48,8 +57,8 @@ if (MSVC) endif() set (ZXING_PRIVATE_FLAGS - $<$:-DZXING_USE_ZINT> - $<$:-DZXING_BUILD_FOR_TEST> + $<$:-DZXING_USE_ZINT> + $<$:-DZXING_BUILD_FOR_TEST> ) if (MSVC) set (ZXING_PRIVATE_FLAGS ${ZXING_PRIVATE_FLAGS} @@ -109,10 +118,10 @@ set (COMMON_FILES src/ZXConfig.h src/ZXTestSupport.h src/ZXVersion.h # [[deprecated]] - $<$:src/ZXingC.h> - $<$:src/ZXingC.cpp> + $<$:src/ZXingC.h> + $<$:src/ZXingC.cpp> ) -if (BUILD_READERS OR BUILD_WRITERS_OLD) +if (ZXING_READERS OR ZXING_WRITERS_OLD) set (COMMON_FILES ${COMMON_FILES} src/BitArray.h src/BitArray.cpp @@ -126,7 +135,7 @@ if (BUILD_READERS OR BUILD_WRITERS_OLD) src/Scope.h ) endif() -if (BUILD_READERS) +if (ZXING_READERS) set (COMMON_FILES ${COMMON_FILES} src/BinaryBitmap.h src/BinaryBitmap.cpp @@ -175,14 +184,14 @@ if (BUILD_READERS) ) endif() -if (BUILD_WRITERS) +if (ZXING_WRITERS) set (COMMON_FILES ${COMMON_FILES} src/WriteBarcode.h src/WriteBarcode.cpp ) endif() -if (BUILD_WRITERS_OLD) +if (ZXING_WRITERS_OLD) set (COMMON_FILES ${COMMON_FILES} src/ByteMatrix.h src/ReedSolomonEncoder.h @@ -212,9 +221,9 @@ set (PUBLIC_HEADERS src/TextUtfEncoding.h # [[deprecated]] src/ZXAlgorithms.h src/ZXVersion.h # [[deprecated]] - $<$:${CMAKE_CURRENT_SOURCE_DIR}/src/ZXingC.h> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/src/ZXingC.h> ) -if (BUILD_READERS) +if (ZXING_READERS) set (PUBLIC_HEADERS ${PUBLIC_HEADERS} src/DecodeHints.h # [[deprecated]] src/ReadBarcode.h @@ -222,12 +231,12 @@ if (BUILD_READERS) src/Result.h # [[deprecated]] ) endif() -if (BUILD_WRITERS) +if (ZXING_WRITERS) set (PUBLIC_HEADERS ${PUBLIC_HEADERS} - $<$:${CMAKE_CURRENT_SOURCE_DIR}/src/WriteBarcode.h> + $<$:${CMAKE_CURRENT_SOURCE_DIR}/src/WriteBarcode.h> ) endif() -if (BUILD_WRITERS_OLD) +if (ZXING_WRITERS_OLD) set (PUBLIC_HEADERS ${PUBLIC_HEADERS} src/BitMatrix.h src/BitMatrixIO.h @@ -238,7 +247,7 @@ if (BUILD_WRITERS_OLD) endif() # end of public header set -if (BUILD_READERS) +if (ZXING_READERS) set (AZTEC_FILES ${AZTEC_FILES} src/aztec/AZDecoder.h src/aztec/AZDecoder.cpp @@ -249,7 +258,7 @@ if (BUILD_READERS) src/aztec/AZReader.cpp ) endif() -if (BUILD_WRITERS_OLD) +if (ZXING_WRITERS_OLD) set (AZTEC_FILES ${AZTEC_FILES} src/aztec/AZEncodingState.h src/aztec/AZEncoder.h @@ -264,7 +273,7 @@ if (BUILD_WRITERS_OLD) endif() -if (BUILD_READERS OR BUILD_WRITERS_OLD) +if (ZXING_READERS OR ZXING_WRITERS_OLD) set (DATAMATRIX_FILES src/datamatrix/DMBitLayout.h src/datamatrix/DMBitLayout.cpp @@ -272,7 +281,7 @@ if (BUILD_READERS OR BUILD_WRITERS_OLD) src/datamatrix/DMVersion.cpp ) endif() -if (BUILD_READERS) +if (ZXING_READERS) set (DATAMATRIX_FILES ${DATAMATRIX_FILES} src/datamatrix/DMDataBlock.h src/datamatrix/DMDataBlock.cpp @@ -284,7 +293,7 @@ if (BUILD_READERS) src/datamatrix/DMReader.cpp ) endif() -if (BUILD_WRITERS_OLD) +if (ZXING_WRITERS_OLD) set (DATAMATRIX_FILES ${DATAMATRIX_FILES} src/datamatrix/DMECEncoder.h src/datamatrix/DMECEncoder.cpp @@ -300,7 +309,7 @@ if (BUILD_WRITERS_OLD) endif() -if (BUILD_READERS) +if (ZXING_READERS) set (MAXICODE_FILES ${MAXICODE_FILES} src/maxicode/MCBitMatrixParser.h src/maxicode/MCBitMatrixParser.cpp @@ -312,7 +321,7 @@ if (BUILD_READERS) endif() -if (BUILD_READERS OR BUILD_WRITERS_OLD) +if (ZXING_READERS OR ZXING_WRITERS_OLD) set (ONED_FILES src/oned/ODUPCEANCommon.h src/oned/ODUPCEANCommon.cpp @@ -320,7 +329,7 @@ if (BUILD_READERS OR BUILD_WRITERS_OLD) src/oned/ODCode128Patterns.cpp ) endif() -if (BUILD_READERS) +if (ZXING_READERS) set (ONED_FILES ${ONED_FILES} src/oned/ODCodabarReader.h src/oned/ODCodabarReader.cpp @@ -349,7 +358,7 @@ if (BUILD_READERS) src/oned/ODRowReader.h ) endif() -if (BUILD_WRITERS_OLD) +if (ZXING_WRITERS_OLD) set (ONED_FILES ${ONED_FILES} src/oned/ODCodabarWriter.h src/oned/ODCodabarWriter.cpp @@ -375,13 +384,13 @@ if (BUILD_WRITERS_OLD) endif() -if (BUILD_READERS OR BUILD_WRITERS_OLD) +if (ZXING_READERS OR ZXING_WRITERS_OLD) set (PDF417_FILES src/pdf417/ZXBigInteger.h src/pdf417/ZXBigInteger.cpp ) endif() -if (BUILD_READERS) +if (ZXING_READERS) set (PDF417_FILES ${PDF417_FILES} src/pdf417/PDFBarcodeMetadata.h src/pdf417/PDFBarcodeValue.h @@ -412,7 +421,7 @@ if (BUILD_READERS) src/pdf417/ZXNullable.h ) endif() -if (BUILD_WRITERS_OLD) +if (ZXING_WRITERS_OLD) set (PDF417_FILES ${PDF417_FILES} src/pdf417/PDFCompaction.h src/pdf417/PDFEncoder.h @@ -425,7 +434,7 @@ if (BUILD_WRITERS_OLD) endif() -if (BUILD_READERS OR BUILD_WRITERS_OLD) +if (ZXING_READERS OR ZXING_WRITERS_OLD) set (QRCODE_FILES src/qrcode/QRCodecMode.h src/qrcode/QRCodecMode.cpp @@ -435,7 +444,7 @@ if (BUILD_READERS OR BUILD_WRITERS_OLD) src/qrcode/QRVersion.cpp ) endif() -if (BUILD_READERS) +if (ZXING_READERS) set (QRCODE_FILES ${QRCODE_FILES} src/qrcode/QRBitMatrixParser.h src/qrcode/QRBitMatrixParser.cpp @@ -453,7 +462,7 @@ if (BUILD_READERS) src/qrcode/QRReader.cpp ) endif() -if (BUILD_WRITERS_OLD) +if (ZXING_WRITERS_OLD) set (QRCODE_FILES ${QRCODE_FILES} src/qrcode/QREncoder.h src/qrcode/QREncoder.cpp @@ -472,10 +481,10 @@ set (LIBZUECI_FILES src/libzueci/zueci.h ) -if (NOT BUILD_READERS) +if (NOT ZXING_READERS) set_source_files_properties(src/libzueci/zueci.c PROPERTIES COMPILE_FLAGS -DZUECI_EMBED_NO_TO_UTF) endif() -if (NOT BUILD_WRITERS_OLD) +if (NOT ZXING_WRITERS_OLD) set_source_files_properties(src/libzueci/zueci.c PROPERTIES COMPILE_FLAGS -DZUECI_EMBED_NO_TO_ECI) endif() @@ -517,7 +526,7 @@ target_compile_features(ZXing PUBLIC cxx_std_17) target_link_libraries (ZXing PRIVATE Threads::Threads) -if (BUILD_WRITERS_NEW) +if (ZXING_WRITERS_NEW) if (ZXING_USE_BUNDLED_ZINT) aux_source_directory(src/libzint LIBZINT_FILES) # manually re-run cmake after adding a new file/symlink set_source_files_properties(${LIBZINT_FILES} PROPERTIES SKIP_PRECOMPILE_HEADERS ON) @@ -547,7 +556,7 @@ endif() set_target_properties(ZXing PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}") set(PRECOMPILE_HEADERS ${PUBLIC_HEADERS}) -list(REMOVE_ITEM PRECOMPILE_HEADERS "$<$:${CMAKE_CURRENT_SOURCE_DIR}/src/ZXingC.h>") +list(REMOVE_ITEM PRECOMPILE_HEADERS "$<$:${CMAKE_CURRENT_SOURCE_DIR}/src/ZXingC.h>") list(REMOVE_ITEM PRECOMPILE_HEADERS src/DecodeHints.h) # [[deprecated]] list(REMOVE_ITEM PRECOMPILE_HEADERS src/Result.h) # [[deprecated]] list(REMOVE_ITEM PRECOMPILE_HEADERS src/ZXVersion.h) # [[deprecated]] @@ -598,8 +607,8 @@ install ( PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/ZXing" ) -set(ZXING_HAS_READERS ${BUILD_READERS}) -set(ZXING_HAS_WRITERS ${BUILD_WRITERS}) +set(ZXING_HAS_READERS ${ZXING_READERS}) +set(ZXING_HAS_WRITERS ${ZXING_WRITERS}) configure_file (Version.h.in Version.h) install ( diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 9a492ca5eb..8f34e72019 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -2,7 +2,7 @@ zxing_add_package_stb() include (GNUInstallDirs) -if (BUILD_WRITERS) +if (ZXING_WRITERS) add_executable (ZXingWriter ZXingWriter.cpp) target_link_libraries (ZXingWriter ZXing::ZXing stb::stb) @@ -12,7 +12,7 @@ if (BUILD_WRITERS) install(TARGETS ZXingWriter DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() -if (BUILD_READERS) +if (ZXING_READERS) add_executable (ZXingReader ZXingReader.cpp) target_link_libraries (ZXingReader ZXing::ZXing stb::stb) @@ -30,7 +30,7 @@ endif() set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -if (BUILD_READERS) +if (ZXING_READERS) if (TARGET Qt::Gui) add_executable (ZXingQtReader ZXingQtReader.cpp ZXingQtReader.h) target_link_libraries(ZXingQtReader ZXing::ZXing Qt::Gui) @@ -51,7 +51,7 @@ if (BUILD_READERS) endif() endif() -if (BUILD_WRITERS) +if (ZXING_WRITERS) if (TARGET Qt::Gui) add_executable (ZXingQtWriter ZXingQtWriter.cpp) target_link_libraries(ZXingQtWriter ZXing::ZXing Qt::Gui) diff --git a/test/blackbox/CMakeLists.txt b/test/blackbox/CMakeLists.txt index b4badb6319..e4b880a10b 100644 --- a/test/blackbox/CMakeLists.txt +++ b/test/blackbox/CMakeLists.txt @@ -1,7 +1,7 @@ zxing_add_package_stb() zxing_add_package(fmt fmtlib https://github.com/fmtlib/fmt.git 10.0.0) -if (BUILD_READERS) +if (ZXING_READERS) add_executable (ReaderTest TestReaderMain.cpp ImageLoader.h @@ -19,7 +19,7 @@ if (BUILD_READERS) add_test(NAME ReaderTest COMMAND ReaderTest ${CMAKE_CURRENT_SOURCE_DIR}/../samples) endif() -if (BUILD_WRITERS) +if (ZXING_WRITERS) add_executable (WriterTest TestWriterMain.cpp) target_link_libraries (WriterTest ZXing::ZXing stb::stb) diff --git a/test/fuzz/CMakeLists.txt b/test/fuzz/CMakeLists.txt index a5202f19a5..2c5d0db406 100644 --- a/test/fuzz/CMakeLists.txt +++ b/test/fuzz/CMakeLists.txt @@ -8,8 +8,8 @@ project (ZXingFuzz) set (CMAKE_CXX_STANDARD 20) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -march=native -fsanitize=address,fuzzer") -set (BUILD_WRITERS ON) -set (BUILD_READERS ON) +set (ZXING_WRITERS OLD) +set (ZXING_READERS ON) add_definitions (-DZXING_BUILD_FOR_TEST) add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR}/../../core ${CMAKE_BINARY_DIR}/ZXing) diff --git a/wrappers/android/zxingcpp/src/main/cpp/CMakeLists.txt b/wrappers/android/zxingcpp/src/main/cpp/CMakeLists.txt index f8b65ae02b..25d5c4dff5 100644 --- a/wrappers/android/zxingcpp/src/main/cpp/CMakeLists.txt +++ b/wrappers/android/zxingcpp/src/main/cpp/CMakeLists.txt @@ -5,8 +5,8 @@ project(ZXingCppAndroid) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(BUILD_READERS ON) -set(BUILD_WRITERS OFF) +set(ZXING_READERS ON) +set(ZXING_WRITERS OFF) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../core ZXing EXCLUDE_FROM_ALL) diff --git a/wrappers/c/CMakeLists.txt b/wrappers/c/CMakeLists.txt index 9754a9f70b..8ecf07c4c9 100644 --- a/wrappers/c/CMakeLists.txt +++ b/wrappers/c/CMakeLists.txt @@ -1,6 +1,6 @@ zxing_add_package_stb() -if (BUILD_READERS) +if (ZXING_READERS) add_executable (ZXingCTest ZXingCTest.c) target_link_libraries (ZXingCTest ZXing::ZXing stb::stb) add_test(NAME ZXingCTest COMMAND ZXingCTest ${CMAKE_SOURCE_DIR}/test/samples/qrcode-1/1.png) diff --git a/wrappers/kn/build.gradle.kts b/wrappers/kn/build.gradle.kts index 4d81075b97..7ce21cba57 100644 --- a/wrappers/kn/build.gradle.kts +++ b/wrappers/kn/build.gradle.kts @@ -101,9 +101,9 @@ krossCompile { buildSharedLibs = false } + CustomCMakeCacheEntries( mapOf( - "BUILD_READERS" to "ON", - "BUILD_WRITERS" to "OFF", - "BUILD_C_API" to "ON", + "ZXING_READERS" to "ON", + "ZXING_WRITERS" to "OFF", + "ZXING_C_API" to "ON", ) )).asCMakeParams buildParams { diff --git a/wrappers/python/CMakeLists.txt b/wrappers/python/CMakeLists.txt index 8e87d7e318..01869ce779 100644 --- a/wrappers/python/CMakeLists.txt +++ b/wrappers/python/CMakeLists.txt @@ -11,10 +11,10 @@ if (NOT hasParent) set(CMAKE_CXX_STANDARD_REQUIRED OFF) option (BUILD_SHARED_LIBS "Link python module to shared lib" OFF) - option (BUILD_READERS "Build with reader support (decoders)" ON) - set(BUILD_WRITERS "NEW" CACHE STRING "Build with old and/or new writer (encoder) backend (OFF/ON/OLD/NEW)") - set(BUILD_DEPENDENCIES "AUTO" CACHE STRING "Fetch from github or use locally installed (AUTO/GITHUB/LOCAL)") - option (BUILD_EXPERIMENTAL_API "Build with experimental API" ON) + option (ZXING_READERS "Build with reader support (decoders)" ON) + set (ZXING_WRITERS "NEW" CACHE STRING "Build with old and/or new writer (encoder) backend (OFF/ON/OLD/NEW)") + set (ZXING_DEPENDENCIES "AUTO" CACHE STRING "Fetch from github or use locally installed (AUTO/GITHUB/LOCAL)") + option (ZXING_EXPERIMENTAL_API "Build with experimental API" ON) option (ZXING_USE_BUNDLED_ZINT "Use the bundled libzint for barcode creation/generation" ON) set(CORE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/core) @@ -39,7 +39,7 @@ zxing_add_package(pybind11 pybind11 https://github.com/pybind/pybind11.git v2.11 pybind11_add_module(zxingcpp zxing.cpp) target_link_libraries(zxingcpp PRIVATE ZXing::ZXing) -if (BUILD_READERS AND BUILD_WRITERS) +if (ZXING_READERS AND ZXING_WRITERS) add_test(NAME PythonTest COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test.py -v) set_property(TEST PythonTest PROPERTY ENVIRONMENT PYTHONPATH=$) endif() diff --git a/wrappers/rust/build.rs b/wrappers/rust/build.rs index 88b4f0774f..8a078fd798 100644 --- a/wrappers/rust/build.rs +++ b/wrappers/rust/build.rs @@ -5,10 +5,10 @@ fn main() -> miette::Result<()> { // Builds the project in the directory located in `core`, installing it into $OUT_DIR let mut dst = cmake::Config::new("core") .define("BUILD_SHARED_LIBS", "OFF") - .define("BUILD_READERS", "ON") - .define("BUILD_WRITERS", "NEW") - .define("BUILD_EXPERIMENTAL_API", "ON") - .define("BUILD_C_API", "ON") + .define("ZXING_READERS", "ON") + .define("ZXING_WRITERS", "NEW") + .define("ZXING_EXPERIMENTAL_API", "ON") + .define("ZXING_C_API", "ON") .define("ZXING_USE_BUNDLED_ZINT", "ON") .define("CMAKE_CXX_STANDARD", "20") .build(); diff --git a/wrappers/wasm/CMakeLists.txt b/wrappers/wasm/CMakeLists.txt index 0bc692da05..205f28fcae 100644 --- a/wrappers/wasm/CMakeLists.txt +++ b/wrappers/wasm/CMakeLists.txt @@ -7,10 +7,20 @@ zxing_add_package_stb() set (CMAKE_CXX_STANDARD 20) -option (BUILD_WRITERS "Build with writer support (encoders)" ON) -option (BUILD_READERS "Build with reader support (decoders)" ON) +option (ZXING_WRITERS "Build with writer support (encoders)" ON) +option (ZXING_READERS "Build with reader support (decoders)" ON) +set (ZXING_EMSCRIPTEN_ENVIRONMENT "web" CACHE STRING "Optimize build for given emscripten runtime environment (web/node/shell/worker)") -set(BUILD_EMSCRIPTEN_ENVIRONMENT "web" CACHE STRING "Optimize build for given emscripten runtime environment (web/node/shell/worker)") +# provide backward compatibility for deprecated BUILD_... options +if (DEFINED BUILD_READERS) + set (ZXING_READERS ${BUILD_READERS}) +endif() +if (DEFINED BUILD_WRITERS) + set (ZXING_WRITERS ${BUILD_WRITERS}) +endif() +if (DEFINED BUILD_EMSCRIPTEN_ENVIRONMENT) + set (ZXING_EMSCRIPTEN_ENVIRONMENT ${BUILD_EMSCRIPTEN_ENVIRONMENT}) +endif() if (NOT CMAKE_BUILD_TYPE) set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE) @@ -20,21 +30,21 @@ add_definitions ("-s DISABLE_EXCEPTION_CATCHING=0") add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR}/../../core ${CMAKE_BINARY_DIR}/ZXing) -set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --bind -s ENVIRONMENT=${BUILD_EMSCRIPTEN_ENVIRONMENT} -s DISABLE_EXCEPTION_CATCHING=0 -s FILESYSTEM=0 -s MODULARIZE=1 -s EXPORT_NAME=ZXing -s EXPORTED_FUNCTIONS=\"['_malloc', '_free']\" -s ALLOW_MEMORY_GROWTH=1") +set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --bind -s ENVIRONMENT=${ZXING_EMSCRIPTEN_ENVIRONMENT} -s DISABLE_EXCEPTION_CATCHING=0 -s FILESYSTEM=0 -s MODULARIZE=1 -s EXPORT_NAME=ZXing -s EXPORTED_FUNCTIONS=\"['_malloc', '_free']\" -s ALLOW_MEMORY_GROWTH=1") -if (BUILD_READERS AND BUILD_WRITERS) +if (ZXING_READERS AND ZXING_WRITERS) add_executable (zxing BarcodeReader.cpp BarcodeWriter.cpp) target_link_libraries (zxing ZXing::ZXing stb::stb) endif() -if (BUILD_READERS) +if (ZXING_READERS) configure_file(demo_cam_reader.html demo_cam_reader.html COPYONLY) configure_file(demo_reader.html demo_reader.html COPYONLY) add_executable (zxing_reader BarcodeReader.cpp) target_link_libraries (zxing_reader ZXing::ZXing stb::stb) endif() -if (BUILD_WRITERS) +if (ZXING_WRITERS) configure_file(demo_writer.html demo_writer.html COPYONLY) add_executable (zxing_writer BarcodeWriter.cpp ) target_link_libraries (zxing_writer ZXing::ZXing stb::stb) diff --git a/zxing.cmake b/zxing.cmake index 1eb55faaf3..facd8bc700 100644 --- a/zxing.cmake +++ b/zxing.cmake @@ -2,10 +2,10 @@ macro(zxing_add_package_stb) unset (STB_FOUND CACHE) - if (BUILD_DEPENDENCIES STREQUAL "AUTO") + if (ZXING_DEPENDENCIES STREQUAL "AUTO") find_package(PkgConfig) pkg_check_modules (STB IMPORTED_TARGET stb) - elseif (BUILD_DEPENDENCIES STREQUAL "LOCAL") + elseif (ZXING_DEPENDENCIES STREQUAL "LOCAL") find_package(PkgConfig REQUIRED) pkg_check_modules (STB REQUIRED IMPORTED_TARGET stb) endif() @@ -25,9 +25,9 @@ endmacro() macro(zxing_add_package name depname git_repo git_rev) unset(${name}_FOUND CACHE) # see https://github.com/zxing-cpp/zxing-cpp/commit/8db14eeead45e0f1961532f55061d5e4dd0f78be#commitcomment-66464026 - if (BUILD_DEPENDENCIES STREQUAL "AUTO") + if (ZXING_DEPENDENCIES STREQUAL "AUTO") find_package (${name} CONFIG) - elseif (BUILD_DEPENDENCIES STREQUAL "LOCAL") + elseif (ZXING_DEPENDENCIES STREQUAL "LOCAL") find_package (${name} REQUIRED CONFIG) endif()