[CXX-2419] Wrong CMAKE configuration for std::experimental build Created: 10/Dec/21  Updated: 27/Oct/23  Resolved: 07/Apr/22

Status: Closed
Project: C++ Driver
Component/s: API
Affects Version/s: 3.6.5
Fix Version/s: None

Type: Bug Priority: Unknown
Reporter: Dariusz D Assignee: Roberto Sanchez
Resolution: Works as Designed Votes: 0
Labels: needs-first-responder
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Summary

Unable to install it via vcpkg install mongo-cxx-driver[std-experimental] due to CMAKE_CXX_STANDARD  set to 11 instead of 14+

https://github.com/microsoft/vcpkg/issues/21877

 

Environment

WIndows 10x64

msvc2019

How to Reproduce

vcpkg install mongo-cxx-driver[std-experimental]

Additional Background

https://github.com/microsoft/vcpkg/issues/21877

 



 Comments   
Comment by Roberto Sanchez [ 07/Apr/22 ]

dariusz1989@gmail.com, you're welcome.

The problem is that the vcpkg portfile is not setting the proper c++ standards version when building with the std::experimental polyfill. If you point the vcpkg maintainers at the patch I suggested in my last comment, they should be able to fix the mongo-cxx-driver build in vcpkg. You can also built with the default Boost polyfill and bypass the failure you are experiencing that way.

As far as compiling mongodb, note that mongo-c-driver and mongo-cxx-driver are drivers that allow you build programs to interact with the MongoDB server. Neither of those are the server itself. If you require further assistance, the best place to request it is in the Community Forums.

Comment by Dariusz D [ 07/Apr/22 ]

Hey @Roberto Sanchez

Thanks for checking out this issue.

I'm not sure, I do not configure anything. I just try to install mongodb via vcpkg. Here is my post on githun issue > https://github.com/microsoft/vcpkg/issues/21877

They told me its mongodb issue and to ask here before > https://github.com/microsoft/vcpkg/issues/21877#issuecomment-989440957

So, is it mongo cmake issue or is it vcpkg issue? Who is maintaining what here? 

Also, I'd like to finally get mongodb compiled... 

Regards

Dariusz

 

Comment by Roberto Sanchez [ 07/Apr/22 ]

dariusz1989@gmail.com, the issue you have reported is not a bug in the C++ driver build. Rather, when choosing the std::experimental polyfill it is necessary to ensure that the correct C++ standard level is set. The error message at the end of the failed build clearly states that CMAKE_CXX_STANDARD must have a value of 14 or higher when building with the std::experimental polyfill.

The C++ driver build defaults to C++11 for the benefit of older compilers which are supported for building the project. Additionally, the std::experimental polyfill carries the caveat "Note that this polyfill is not recommended and is unsupported" in the installation documentation.

I recommend updating the mongo-cxx-driver portfile with the following changes to allow the std-experimental variant of your port to successfully build:

diff --git a/ports/mongo-cxx-driver/portfile.cmake b/ports/mongo-cxx-driver/portfile.cmake
index 1b208519e..4b03c74d3 100644
--- a/ports/mongo-cxx-driver/portfile.cmake
+++ b/ports/mongo-cxx-driver/portfile.cmake
@@ -2,6 +2,7 @@ set(VERSION_MAJOR 3)
 set(VERSION_MINOR 6)
 set(VERSION_PATCH 5)
 set(VERSION_FULL ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
+set(BSONCXX_STANDARD 11)
 
 vcpkg_from_github(
     OUT_SOURCE_PATH SOURCE_PATH
@@ -29,6 +30,7 @@ elseif ("boost" IN_LIST FEATURES)
     set(BSONCXX_POLY BOOST)
 elseif("std-experimental" IN_LIST FEATURES)
     set(BSONCXX_POLY STD_EXPERIMENTAL)
+    set(BSONCXX_STANDARD 17)
 else()
   if (NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
     set(BSONCXX_POLY BOOST)
@@ -43,6 +45,7 @@ vcpkg_cmake_configure(
         -DMONGOCXX_HEADER_INSTALL_DIR=include
         -DBSONCXX_HEADER_INSTALL_DIR=include
         -DBSONCXX_POLY_USE_${BSONCXX_POLY}=1
+        -DCMAKE_CXX_STANDARD=${BSONCXX_STANDARD}
         -DBUILD_VERSION=${VERSION_FULL}
 )
 

If we can be of further assistance, please

Comment by Kevin Albertson [ 12/Dec/21 ]

Hi dariusz1989@gmail.com, thank you for the report. We will look into this soon.

Generated at Wed Feb 07 22:05:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.