Jens Geyer created THRIFT-6224:
----------------------------------
Summary: CMake: zlib and libevent are only detected when WITH_CPP
is on, so a c_glib-only build fails
Key: THRIFT-6224
URL: https://issues.apache.org/jira/browse/THRIFT-6224
Project: Thrift
Issue Type: Bug
Components: C glib - Library, Build Process
Reporter: Jens Geyer
h2. What happens
With {{-DWITH_CPP=OFF -DWITH_C_GLIB=ON -DBUILD_TESTING=ON}} (other languages
off), configuration succeeds but the build does not link:
{noformat}
test/c_glib/src/test_server.c:173: undefined reference to
`thrift_zlib_transport_factory_get_type'
{noformat}
Adding {{-DWITH_ZLIB=ON}} fails at configure time instead:
{noformat}
CMake Error at lib/c_glib/test/CMakeLists.txt:149 (include_directories):
include_directories given empty-string as include directory.
{noformat}
The same configuration with {{-DWITH_CPP=ON}} builds, including the c_glib zlib
tests.
h2. Why
{{build/cmake/DefineOptions.cmake}} runs {{find_package(ZLIB)}},
{{find_package(Libevent)}} and {{find_package(Qt5)}} inside {{if(WITH_CPP)}}.
Its own comment says these options are C++ specific "but in future other
libraries might reuse them" -- c_glib does. With {{WITH_CPP=OFF}} zlib is never
looked for, so {{WITH_ZLIB}} stays off, and forcing it on leaves
{{ZLIB_INCLUDE_DIRS}} empty.
h2. Suggested fix
Move the zlib (and libevent) detection into a block that also covers c_glib,
like the {{if(WITH_CPP OR WITH_C_GLIB)}} block a few lines further down.
_Drafted with AI assistance (Claude Opus 5); reviewed and filed by Jens Geyer._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)