Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-3041

CMakelists.txt logic causes message to be hidden

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.14.0
    • Component/s: Build, cmake
    • None
    • Environment:
      Windows

      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

        1. output.txt
          3 kB
          John Rocha

            Assignee:
            Unassigned Unassigned
            Reporter:
            jrrocha John Rocha
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: