Skip to content

Commit

Permalink
cmake: make the unit test target respect the READER/WRITER options
Browse files Browse the repository at this point in the history
  • Loading branch information
axxel committed Mar 16, 2024
1 parent 1c51b11 commit ac4ab21
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 52 deletions.
6 changes: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -148,8 +150,6 @@ if (ZXING_READERS)
$<$<BOOL:${BUILD_SHARED_LIBS}>: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
Expand Down
82 changes: 48 additions & 34 deletions test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,70 +10,84 @@ if (MSVC)
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/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 .)

Expand Down
3 changes: 0 additions & 3 deletions test/unit/GTINTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

#include "GTIN.h"

#include "Barcode.h"
#include "oned/ODUPCEANCommon.h"

#include "gtest/gtest.h"

using namespace ZXing;
Expand Down
1 change: 0 additions & 1 deletion test/unit/TextUtfEncodingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "Utf.h"

#include "gtest/gtest.h"
#include <vector>

using namespace ZXing;

Expand Down
5 changes: 0 additions & 5 deletions test/unit/datamatrix/DMEncodeDecodeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
#include "datamatrix/DMDecoder.h"
#include "datamatrix/DMWriter.h"

#include <algorithm>
#ifndef NDEBUG
#include <fstream>
#endif

#include "gtest/gtest.h"

using namespace ZXing;
Expand Down
1 change: 0 additions & 1 deletion test/unit/qrcode/QRModeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "qrcode/QRVersion.h"
#include "Error.h"

#include <stdexcept>
#include "gtest/gtest.h"

using namespace ZXing;
Expand Down

0 comments on commit ac4ab21

Please sign in to comment.