[CDRIVER-3041] CMakelists.txt logic causes message to be hidden Created: 26/Mar/19  Updated: 27/Oct/23  Resolved: 05/Aug/20

Status: Closed
Project: C Driver
Component/s: Build, cmake
Affects Version/s: 1.14.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: John Rocha Assignee: Unassigned
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows


Attachments: Text File output.txt    
Issue Links:
Related
is related to CDRIVER-3756 CMakeLists.txt redefines "message" fu... Closed

 Description   

The file mongo-c-driver-r1.14/CMakeLists.txt has logic near the top to suppress mongo test output, that does not appear to work correctly.

The intent appears to be to turn cmake output messages on/off dynamically. However, I've found that once it's turned off, it's just always off.

# Used in MaintainerFlags.cmake to silence errors while testing configs.
set (MESSAGES_ENABLED 1)
 
function (message)
   list (GET ARGV 0 MessageType)
   if (MESSAGES_ENABLED)
      list (REMOVE_AT ARGV 0)
      _message (${MessageType} "${ARGV}")
   endif ()
endfunction ()

This issue can be observed with a simple CMake test file such as the following:

  1. Create the following CMakeLists.txt file in the directory above mongo-c-driver-r1.14

    cmake_minimum_required (VERSION 3.8)
    cmake_policy(SET CMP0011 NEW)
    cmake_policy(SET CMP0010 NEW)
    cmake_policy(SET CMP0022 NEW)
     
    set(CMAKE_SUPPRESS_REGENERATION TRUE)
     
    SET(P_NAME mongo-c-driver)
    PROJECT(${P_NAME})
     
     
    MESSAGE(STATUS "")
    MESSAGE(STATUS "This is before add_subdiretory\n")
    MESSAGE(STATUS "")
     
    add_subdirectory(mongo-c-driver-r1.14)
     
    MESSAGE(STATUS "")
    MESSAGE(STATUS "This is after add_subdiretory\n")
    MESSAGE(STATUS "")
    


  2. Create a sub-directory BUILD In the directory above mongo-c-drvier-r1.14

    mkdir BUILD


    At this point the directory hierarchy will be:

      build-root
        +--CmakeLists.txt
        |
        +--BUILD/
        |
        +--mongo-c-driver-r1.14
             +--CmakeLists.txt
             |
             +--....etc...
             
    

  3. Enter BUILD directory

    cd BUILD

  4. Run cmake

    cmake ..

The end result should be output showing "This is before add_subdirectory", all of the stock mongo-c-driver-r1.14 cmake output (with test output suppressed) followed by the string "This is after add_subdirectory"

However, that doesn't happen. All calls to Message() are suppressed after mongo's overloaded message() function comes into play.

Refer to attachment output.txt for an example of the resulting output.

CMake version 3.11.0-rc1 is in use.

A possible fix is for mongodb to change

original

set (MESSAGES_ENABLED 1)

to

suggestion

option(MESSAGES_ENABLED "turn on message" 1)

Recomm



 Comments   
Comment by Kevin Albertson [ 05/Aug/20 ]

Hi jrrocha. I believe this is resolved with CDRIVER-3756, which removes the override of the message function.

Comment by Kevin Albertson [ 01/Apr/19 ]

Thanks for the detailed report jrrocha. If you'd like to submit a pull request we'd be happy to take a look. Otherwise, we'll look into this when we can.

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