[CDRIVER-2324] CMake config doesn't set MONGOC_ENABLE_COMPRESSION in mongoc-config.h Created: 12/Oct/17  Updated: 28/Oct/23  Resolved: 28/Oct/17

Status: Closed
Project: C Driver
Component/s: Build, cmake, libmongoc
Affects Version/s: 1.8.0
Fix Version/s: 1.8.2, 1.9.0

Type: Bug Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: A. Jesse Jiryu Davis
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by CXX-1448 Compression related build issues on E... Closed
Duplicate
is duplicated by CDRIVER-2368 Test is broken for windows, using ver... Closed

 Description   

In CMakeLists.txt for libmongoc, we first generate mongoc-config.h:

configure_file (
   "${SOURCE_DIR}/src/mongoc/mongoc-config.h.in"
   "${PROJECT_BINARY_DIR}/src/mongoc/mongoc-config.h"
)

and then handle MONGOC_ENABLE_COMPRESSION:

if (ENABLE_SNAPPY STREQUAL "bundled")
   set (MONGOC_ENABLE_COMPRESSION 1)
   set (MONGOC_ENABLE_COMPRESSION_SNAPPY 1)
   include(FindSnappy)
endif ()

The configure_file call must come after all the variables it needs are set.



 Comments   
Comment by Githook User [ 28/Oct/17 ]

Author:

{'email': 'jesse@mongodb.com', 'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis'}

Message: CDRIVER-2324 CMakeLists bundled zlib/snappy fix
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/a92ce5b0e3208cb88cd6e61df5e2bda8b3b6be6a

Comment by Githook User [ 28/Oct/17 ]

Author:

{'email': 'jesse@mongodb.com', 'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis'}

Message: CDRIVER-2324 CMakeLists bundled zlib/snappy fix
Branch: r1.8
https://github.com/mongodb/mongo-c-driver/commit/baf5040a6b92cce0c395c5b177e7d4bc19f7f019

Comment by Githook User [ 16/Oct/17 ]

Author:

{'email': 'github@derickrethans.nl', 'name': 'Derick Rethans', 'username': 'derickr'}

Message: CDRIVER-2324 Test file 'test-mongoc-topology.c' does not compile if ENABLE_COMPRESSION is not set
Branch: r1.8
https://github.com/mongodb/mongo-c-driver/commit/7c33882cb45a49b58937b969e691245c03f5d335

Comment by Derick Rethans [ 13/Oct/17 ]

I've added a PR for the latter part of this ticket: https://github.com/mongodb/mongo-c-driver/pull/457

Comment by Derick Rethans [ 13/Oct/17 ]

I have tried the suggestion to set -DENABLE_SNAPPY=no -DENABLE_ZLIB=no, but the result is still the same:

 [2017/10/12 16:45:55.006]          C:\data\mci\dc11bbd2c02378da8e4ffafe0b38aa62\mongo-cxx-driver\mongo-c-driver-1.8.1\tests\test-mongoc-topology.c(348): error C2039: 'compressors': is not a member of '_mongoc_server_description_t' [C:\data\mci\dc11bbd2c02378da8e4ffafe0b38aa62\mongo-cxx-driver\mongo-c-driver-1.8.1\test-libmongoc.vcxproj]
 [2017/10/12 16:45:55.006]          C:\data\mci\dc11bbd2c02378da8e4ffafe0b38aa62\mongo-cxx-driver\mongo-c-driver-1.8.1\tests\test-mongoc-topology.c(348): error C2198: 'bson_get_data': too few arguments for call [C:\data\mci\dc11bbd2c02378da8e4ffafe0b38aa62\mongo-cxx-driver\mongo-c-driver-1.8.1\test-libmongoc.vcxproj]

If I look at the test file (test-mongoc-topology.c), I actually see:

 345    BSON_ASSERT (bson_empty (&sd->hosts));
 346    BSON_ASSERT (bson_empty (&sd->passives));
 347    BSON_ASSERT (bson_empty (&sd->arbiters));
 348    BSON_ASSERT (bson_empty (&sd->compressors));
 349 
 350    mongoc_server_stream_cleanup (server_stream);

As you can see, there is no guard around the test for compressors - assuming that it always exists, whereas the definition in mongoc/mongoc-server-description-private.h looks like:

 78 #ifdef MONGOC_ENABLE_COMPRESSION
 79    bson_t compressors;
 80 #endif

I believe this guard should be around the use in the test file (tests\test-mongoc-topology.c) too.

Comment by A. Jesse Jiryu Davis [ 12/Oct/17 ]

derick this will break C++ builds on platforms with neither snappy or zlib available on the system, I believe.

Generated at Wed Feb 07 21:14:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.