From ac4ab213aa2603a7c044f59692120c3bebc78d03 Mon Sep 17 00:00:00 2001 From: axxel Date: Sat, 16 Mar 2024 11:39:16 +0100 Subject: [PATCH] cmake: make the unit test target respect the READER/WRITER options --- CMakeLists.txt | 6 -- core/CMakeLists.txt | 4 +- test/unit/CMakeLists.txt | 82 ++++++++++++--------- test/unit/GTINTest.cpp | 3 - test/unit/TextUtfEncodingTest.cpp | 1 - test/unit/datamatrix/DMEncodeDecodeTest.cpp | 5 -- test/unit/qrcode/QRModeTest.cpp | 1 - 7 files changed, 50 insertions(+), 52 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 83d09f7b12..b602712d79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,12 +58,6 @@ if (NOT (ZXING_READERS OR ZXING_WRITERS)) message(FATAL_ERROR "At least one of ZXING_READERS/ZXING_WRITERS must be enabled.") endif() -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 (ZXING_WRITERS ON) - set (ZXING_READERS ON) -endif() - 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) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index eaa940b8d4..a381899d5d 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -104,6 +104,8 @@ set (COMMON_FILES src/Content.cpp src/ECI.h src/ECI.cpp + src/Error.h + src/Error.cpp src/Flags.h src/GTIN.h src/GTIN.cpp @@ -148,8 +150,6 @@ if (ZXING_READERS) $<$:src/DecodeHints.cpp> # [[deprecated]] src/DecoderResult.h src/DetectorResult.h - src/Error.h - src/Error.cpp src/GlobalHistogramBinarizer.h src/GlobalHistogramBinarizer.cpp src/GridSampler.h diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index b9ab8de452..884c540212 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -10,70 +10,84 @@ if (MSVC) add_compile_options("$<$:/utf-8>") endif() -# Our executable add_executable (UnitTest BarcodeFormatTest.cpp - BitArrayUtility.h BitArrayUtility.cpp - PseudoRandom.h + BitArrayUtility.h BitHacksTest.cpp CharacterSetECITest.cpp - ContentTest.cpp ErrorTest.cpp GTINTest.cpp + PseudoRandom.h + SanitizerSupport.cpp + TextUtfEncodingTest.cpp + ZXAlgorithmsTest.cpp +) + +if (ZXING_READERS) +target_sources (UnitTest PRIVATE GS1Test.cpp PatternTest.cpp - ReedSolomonTest.cpp - SanitizerSupport.cpp TextDecoderTest.cpp - TextEncoderTest.cpp - TextUtfEncodingTest.cpp ThresholdBinarizerTest.cpp - ZXAlgorithmsTest.cpp - aztec/AZDetectorTest.cpp aztec/AZDecoderTest.cpp - aztec/AZEncoderTest.cpp - aztec/AZEncodeDecodeTest.cpp - aztec/AZHighLevelEncoderTest.cpp + aztec/AZDetectorTest.cpp datamatrix/DMDecodedBitStreamParserTest.cpp - datamatrix/DMEncodeDecodeTest.cpp - datamatrix/DMHighLevelEncodeTest.cpp - datamatrix/DMPlacementTest.cpp - datamatrix/DMSymbolInfoTest.cpp - datamatrix/DMWriterTest.cpp maxicode/MCDecoderTest.cpp - oned/ODCodaBarWriterTest.cpp + oned/ODCode128ReaderTest.cpp oned/ODCode39ExtendedModeTest.cpp oned/ODCode39ReaderTest.cpp - oned/ODCode39WriterTest.cpp oned/ODCode93ReaderTest.cpp - oned/ODCode93WriterTest.cpp - oned/ODCode128ReaderTest.cpp - oned/ODCode128WriterTest.cpp - oned/ODDataBarReaderTest.cpp oned/ODDataBarExpandedBitDecoderTest.cpp - oned/ODEAN8WriterTest.cpp - oned/ODEAN13WriterTest.cpp - oned/ODITFWriterTest.cpp - oned/ODUPCAWriterTest.cpp - oned/ODUPCEWriterTest.cpp + oned/ODDataBarReaderTest.cpp + pdf417/PDF417DecoderTest.cpp + pdf417/PDF417ErrorCorrectionTest.cpp + pdf417/PDF417ScanningDecoderTest.cpp qrcode/MQRDecoderTest.cpp qrcode/QRBitMatrixParserTest.cpp qrcode/QRDataMaskTest.cpp qrcode/QRDecodedBitStreamParserTest.cpp - qrcode/QREncoderTest.cpp qrcode/QRErrorCorrectionLevelTest.cpp qrcode/QRFormatInformationTest.cpp qrcode/QRModeTest.cpp qrcode/QRVersionTest.cpp - qrcode/QRWriterTest.cpp qrcode/RMQRDecoderTest.cpp - pdf417/PDF417DecoderTest.cpp - pdf417/PDF417ErrorCorrectionTest.cpp +) +endif() + +if (ZXING_WRITERS MATCHES "ON|OLD|BOTH") +target_sources (UnitTest PRIVATE + aztec/AZEncoderTest.cpp + datamatrix/DMHighLevelEncodeTest.cpp + datamatrix/DMPlacementTest.cpp + datamatrix/DMSymbolInfoTest.cpp + datamatrix/DMWriterTest.cpp + oned/ODCode39WriterTest.cpp + oned/ODCode93WriterTest.cpp + oned/ODEAN13WriterTest.cpp + oned/ODEAN8WriterTest.cpp + oned/ODITFWriterTest.cpp + oned/ODUPCAWriterTest.cpp + oned/ODUPCEWriterTest.cpp pdf417/PDF417HighLevelEncoderTest.cpp - pdf417/PDF417ScanningDecoderTest.cpp pdf417/PDF417WriterTest.cpp + qrcode/QRWriterTest.cpp +) +endif() + +if (ZXING_READERS AND ZXING_WRITERS MATCHES "OLD|ON") +target_sources (UnitTest PRIVATE + ContentTest.cpp + ReedSolomonTest.cpp + TextEncoderTest.cpp + aztec/AZEncodeDecodeTest.cpp + aztec/AZHighLevelEncoderTest.cpp + datamatrix/DMEncodeDecodeTest.cpp + oned/ODCodaBarWriterTest.cpp + oned/ODCode128WriterTest.cpp + qrcode/QREncoderTest.cpp ) +endif() target_include_directories (UnitTest PRIVATE .) diff --git a/test/unit/GTINTest.cpp b/test/unit/GTINTest.cpp index 36f40e7064..2b79508a23 100644 --- a/test/unit/GTINTest.cpp +++ b/test/unit/GTINTest.cpp @@ -5,9 +5,6 @@ #include "GTIN.h" -#include "Barcode.h" -#include "oned/ODUPCEANCommon.h" - #include "gtest/gtest.h" using namespace ZXing; diff --git a/test/unit/TextUtfEncodingTest.cpp b/test/unit/TextUtfEncodingTest.cpp index b406f6d098..e77d332e7a 100644 --- a/test/unit/TextUtfEncodingTest.cpp +++ b/test/unit/TextUtfEncodingTest.cpp @@ -6,7 +6,6 @@ #include "Utf.h" #include "gtest/gtest.h" -#include using namespace ZXing; diff --git a/test/unit/datamatrix/DMEncodeDecodeTest.cpp b/test/unit/datamatrix/DMEncodeDecodeTest.cpp index da64b8c415..33f1587740 100644 --- a/test/unit/datamatrix/DMEncodeDecodeTest.cpp +++ b/test/unit/datamatrix/DMEncodeDecodeTest.cpp @@ -9,11 +9,6 @@ #include "datamatrix/DMDecoder.h" #include "datamatrix/DMWriter.h" -#include -#ifndef NDEBUG -#include -#endif - #include "gtest/gtest.h" using namespace ZXing; diff --git a/test/unit/qrcode/QRModeTest.cpp b/test/unit/qrcode/QRModeTest.cpp index 9b83b15e68..fb951175be 100644 --- a/test/unit/qrcode/QRModeTest.cpp +++ b/test/unit/qrcode/QRModeTest.cpp @@ -8,7 +8,6 @@ #include "qrcode/QRVersion.h" #include "Error.h" -#include #include "gtest/gtest.h" using namespace ZXing;