Sylwester Lachiewicz created THRIFT-6393:
--------------------------------------------
Summary: C++: the CMake test build fails with WITH_ZLIB=OFF
because UnitTests and TTransportFactoryConfigTest use THeaderTransport
Key: THRIFT-6393
URL: https://issues.apache.org/jira/browse/THRIFT-6393
Project: Thrift
Issue Type: Bug
Components: C++ - Library, Build Process
Reporter: Sylwester Lachiewicz
h2. What happens
With {{-DWITH_ZLIB=OFF}} the library is built without {{libthriftz}}, but two
test executables still use {{THeaderTransport}} and {{THeaderProtocol}}, which
live there:
{noformat}
undefined reference to `apache::thrift::transport::THeaderTransport::flush()'
undefined reference to
`apache::thrift::protocol::THeaderProtocol::readBool(bool&)'
FAILED: bin/UnitTests
FAILED: bin/TTransportFactoryConfigTest
{noformat}
Where the zlib headers are not installed,
[lib/cpp/test/ThrifttReadCheckTests.cpp|https://github.com/apache/thrift/blob/master/lib/cpp/test/ThrifttReadCheckTests.cpp]
already fails to compile on {{#include <zlib.h>}}.
h2. Why
[lib/cpp/test/CMakeLists.txt|https://github.com/apache/thrift/blob/master/lib/cpp/test/CMakeLists.txt]
links {{thriftz}} into both executables only {{if(WITH_ZLIB)}}, but compiles
their THeaderTransport cases unconditionally:
* {{ThrifttReadCheckTests.cpp}} (part of UnitTests): 10 cases, the first added
in
[4da36faee|https://github.com/apache/thrift/commit/4da36faeef0b7db4b1dea560b01eb15957335934],
which is in 0.24.0
* {{TTransportFactoryConfigTest.cpp}}: 4 cases, added in
[0187cf606|https://github.com/apache/thrift/commit/0187cf606bfac2064eb98475c467ae176e0c778e]
and
[a57f8aa94|https://github.com/apache/thrift/commit/a57f8aa941fb0057a401f5d88ca8a16ded05a8c0]
[THRIFT-3663|https://issues.apache.org/jira/browse/THRIFT-3663] fixed the same
problem in 0.10.0. No CI job builds the tests without zlib
([THRIFT-4104|https://issues.apache.org/jira/browse/THRIFT-4104]).
h2. Fix
Compile those cases only when zlib is available, behind a
{{THRIFT_TEST_WITH_ZLIB}} definition that CMake sets together with
{{WITH_ZLIB}}. The autotools test build always links {{libthriftz}} and
{{-lz}}, so it sets the definition unconditionally.
h2. Seen with
master at f82fcec13: Ubuntu 24.04 arm64, GCC 13, {{cmake -GNinja
-DWITH_ZLIB=OFF -DCMAKE_BUILD_TYPE=Release}}; and MSVC 19.16 (the VS2017 v141
toolset) on windows-2022. A Debug build additionally hits
[THRIFT-6213|https://issues.apache.org/jira/browse/THRIFT-6213].
--
This message was sent by Atlassian Jira
(v8.20.10#820010)