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

libbson cmake: pthreads not correctly compiled in

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.7.0
    • Affects Version/s: 1.7.0
    • Component/s: None
    • None

      Our CMake check for pthreads is incorrect.
      The way we add the build flags is also incorrect, we only link against it with -lpthread, but we are missing the more important part, compiling libbson using -pthread.

      cmake 3.1 adds a easy way to do this: https://cmake.org/cmake/help/latest/module/FindThreads.html

      set(THREADS_PREFER_PTHREAD_FLAG ON)
      find_package(Threads REQUIRED)
      target_link_libraries(bson_shared Threads::Threads)
      target_link_libraries(bson_static Threads::Threads)
      

      The c++ driver requires cmake 3.2, so I think it would be fine if we bump our dependency to 3.1.

            Assignee:
            bjori Hannes Magnusson
            Reporter:
            bjori Hannes Magnusson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: