From d98739ceaac1c477879b9c4fba89ea76dba2d539 Mon Sep 17 00:00:00 2001 From: axxel Date: Sun, 22 Sep 2024 22:39:11 +0200 Subject: [PATCH] cmake: switch to c++-20 by default for the core library I finally accept the incurred performance penalty from the position independent DataMatrix detection by default. This is finally fixing #386. It also (sufficiently) fixes #822 and thereby supersedes #836. --- .github/workflows/ci.yml | 2 +- CMakeLists.txt | 4 +++- README.md | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cdffa23307..4691012156 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,7 +74,7 @@ jobs: - name: Configure run: > cmake -S . -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_SHARED_LIBS=ON - -DZXING_READERS=ON -DZXING_WRITERS=NEW -DZXING_EXPERIMENTAL_API=ON -DCMAKE_CXX_STANDARD=20 + -DZXING_READERS=ON -DZXING_WRITERS=NEW -DZXING_EXPERIMENTAL_API=ON -DZXING_BLACKBOX_TESTS=ON -DZXING_UNIT_TESTS=OFF -DZXING_PYTHON_MODULE=OFF -DZXING_C_API=ON - name: Build diff --git a/CMakeLists.txt b/CMakeLists.txt index b602712d79..fee4c68cdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,7 +71,9 @@ if(NOT ZXING_DEPENDENCIES IN_LIST ZXING_DEPENDENCIES_LIST) endif() if (NOT DEFINED CMAKE_CXX_STANDARD) - set (CMAKE_CXX_STANDARD 17) + set (CMAKE_CXX_STANDARD 20) + # Allow the fallback to earlier versions if the compiler does not support it. + set(CMAKE_CXX_STANDARD_REQUIRED OFF) endif() if (NOT DEFINED CMAKE_CXX_EXTENSIONS) set (CMAKE_CXX_EXTENSIONS OFF) diff --git a/README.md b/README.md index 19a7d0e908..863557d957 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Thanks a lot for your contribution! ## Features -* Written in pure C++17 (/C++20), no third-party dependencies (for the library itself) +* Written in pure C++20 (/C++17), no third-party dependencies (for the library itself) * Thread safe * Wrappers/Bindings for: * [Android](wrappers/android/README.md) @@ -47,7 +47,7 @@ Thanks a lot for your contribution! [Note:] * DataBar used to be called RSS. * DataBar, DX Film Edge, MaxiCode, Micro QR Code and rMQR Code are not supported for writing. - * Building with C++20 (see [CMakeLists.txt](https://github.com/zxing-cpp/zxing-cpp/blob/d4b0f502775857f257d13efd25fb840ece1bca3e/CMakeLists.txt#L45)) changes the behaviour of the library: it then supports multi-symbol and position independent detection for DataMatrix. This comes at a noticable performace cost. C++20 is enabled by default for the Android, iOS, Python and WASM wrappers. + * Building with only C++17 (see [CMakeLists.txt](https://github.com/zxing-cpp/zxing-cpp/blob/d4b0f502775857f257d13efd25fb840ece1bca3e/CMakeLists.txt#L45)) changes the behaviour of the library: it then lacks supports multi-symbol and position independent detection for DataMatrix. ## Getting Started