diff --git a/.evergreen/compile.sh b/.evergreen/compile.sh index 2973296a2e..a5148cd1b5 100755 --- a/.evergreen/compile.sh +++ b/.evergreen/compile.sh @@ -19,6 +19,7 @@ set -o pipefail : "${ENABLE_CODE_COVERAGE:-}" : "${ENABLE_TESTS:-}" : "${generator:-}" +: "${platform:-}" : "${REQUIRED_CXX_STANDARD:-}" : "${RUN_DISTCHECK:-}" : "${USE_POLYFILL_BOOST:-}" @@ -27,23 +28,6 @@ set -o pipefail : "${USE_SANITIZER_UBSAN:-}" : "${USE_STATIC_LIBS:-}" -# Add MSBuild.exe to path. -if [[ "${OSTYPE:?}" == "cygwin" ]]; then - case "${generator:-}" in - *2015*) - PATH="/cygdrive/c/cmake/bin:/cygdrive/c/Program Files (x86)/MSBuild/14.0/Bin:$PATH" - ;; - *2017*) - PATH="/cygdrive/c/cmake/bin:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2017/Professional/MSBuild/15.0/Bin:$PATH" - ;; - *) - echo "missing explicit CMake Generator on Windows distro" 1>&2 - exit 1 - ;; - esac -fi -export PATH - mongoc_prefix="$(pwd)/../mongoc" echo "mongoc_prefix=${mongoc_prefix:?}" @@ -123,7 +107,7 @@ case "${OSTYPE:?}" in cygwin) case "${generator:-}" in *2015*) cmake_flags+=("-DBOOST_ROOT=C:/local/boost_1_60_0") ;; - *2017*) cmake_flags+=("-DCMAKE_CXX_STANDARD=17") ;; + *2017*|*2019*) cmake_flags+=("-DCMAKE_CXX_STANDARD=17") ;; *) echo "missing explicit CMake Generator on Windows distro" 1>&2 exit 1 @@ -142,6 +126,7 @@ darwin* | linux*) ;; esac export CMAKE_GENERATOR="${generator:?}" +export CMAKE_GENERATOR_PLATFORM="${platform:-}" if [[ "${USE_POLYFILL_STD_EXPERIMENTAL:-}" == "ON" ]]; then cmake_flags+=( diff --git a/.evergreen/install_c_driver.sh b/.evergreen/install_c_driver.sh index 1e2f777d7f..766e7cffb3 100755 --- a/.evergreen/install_c_driver.sh +++ b/.evergreen/install_c_driver.sh @@ -83,14 +83,17 @@ if [[ "${OSTYPE}" == darwin* ]]; then } fi + # Default CMake generator to use if not already provided. -declare cmake_generator +declare CMAKE_GENERATOR CMAKE_GENERATOR_PLATFORM if [[ "${OSTYPE:?}" == "cygwin" ]]; then - cmake_generator=${generator:-"Visual Studio 14 2015 Win64"} + CMAKE_GENERATOR="${generator:-"Visual Studio 14 2015"}" + CMAKE_GENERATOR_PLATFORM="${platform:-"x64"}" else - cmake_generator=${generator:-"Unix Makefiles"} + CMAKE_GENERATOR="${generator:-"Unix Makefiles"}" + CMAKE_GENERATOR_PLATFORM="${platform:-""}" fi -: "${cmake_generator:?}" +export CMAKE_GENERATOR CMAKE_GENERATOR_PLATFORM declare -a configure_flags=( "-DCMAKE_BUILD_TYPE=Debug" @@ -131,7 +134,7 @@ fi # Install libmongoc. { echo "Installing C Driver into ${mongoc_dir}..." 1>&2 - "${cmake_binary}" -S "${mongoc_idir}" -B "${mongoc_idir}" -G "${cmake_generator}" "${configure_flags[@]}" + "${cmake_binary}" -S "${mongoc_idir}" -B "${mongoc_idir}" "${configure_flags[@]}" "${cmake_binary}" --build "${mongoc_idir}" --config Debug --target install -- "${compile_flags[@]}" echo "Installing C Driver into ${mongoc_dir}... done." 1>&2 } >/dev/null diff --git a/.evergreen/test.sh b/.evergreen/test.sh index 97ae5df168..3bb32d6592 100755 --- a/.evergreen/test.sh +++ b/.evergreen/test.sh @@ -23,6 +23,7 @@ set -o pipefail : "${generator:-}" : "${lib_dir:-}" : "${MONGODB_API_VERSION:-}" +: "${platform:-}" : "${TEST_WITH_ASAN:-}" : "${TEST_WITH_UBSAN:-}" : "${TEST_WITH_VALGRIND:-}" @@ -40,23 +41,6 @@ fi export MONGOCRYPTD_PATH popd # .. -# Add MSBuild.exe to path. -if [[ "$OSTYPE" == "cygwin" ]]; then - case "${generator}" in - *2015*) - PATH="/cygdrive/c/cmake/bin:/cygdrive/c/Program Files (x86)/MSBuild/14.0/Bin:$PATH" - ;; - *2017*) - PATH="/cygdrive/c/cmake/bin:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2017/Professional/MSBuild/15.0/Bin:$PATH" - ;; - *) - echo "missing explicit CMake Generator on Windows distro" 1>&2 - exit 1 - ;; - esac -fi -export PATH - mongoc_dir="${working_dir:?}/../mongoc" export mongoc_dir @@ -111,6 +95,12 @@ fi export DRIVERS_TOOLS popd # "${working_dir:?}/../drivers-evergreen-tools" +# shellcheck source=/dev/null +. "${mongoc_dir:?}/.evergreen/scripts/find-cmake-latest.sh" +export cmake_binary +cmake_binary="$(find_cmake_latest)" +command -v "${cmake_binary:?}" + export MONGOCXX_TEST_TLS_CA_FILE="${DRIVERS_TOOLS:?}/.evergreen/x509gen/ca.pem" if [ "$(uname -m)" == "ppc64le" ]; then @@ -215,13 +205,13 @@ fi pushd "${working_dir:?}/build" if [[ "${OSTYPE:?}" =~ cygwin ]]; then - CTEST_OUTPUT_ON_FAILURE=1 MSBuild.exe /p:Configuration="${build_type:?}" /verbosity:minimal RUN_TESTS.vcxproj + CTEST_OUTPUT_ON_FAILURE=1 "${cmake_binary:?}" --build . --target RUN_TESTS -- /p:Configuration="${build_type:?}" /verbosity:minimal # Only run examples if MONGODB_API_VERSION is unset. We do not append # API version to example clients, so examples will fail when requireApiVersion # is true. if [[ -z "$MONGODB_API_VERSION" ]]; then echo "Running examples..." - if ! CTEST_OUTPUT_ON_FAILURE=1 MSBuild.exe /p:Configuration="${build_type:?}" /verbosity:minimal examples/run-examples.vcxproj >|output.txt 2>&1; then + if ! CTEST_OUTPUT_ON_FAILURE=1 "${cmake_binary:?}" --build . --target examples/run-examples -- /p:Configuration="${build_type:?}" /verbosity:minimal >|output.txt 2>&1; then # Only emit output on failure. cat output.txt 1>&2 exit 1 @@ -324,6 +314,8 @@ fi export PKG_CONFIG_PATH # Environment variables used by example projects. +export CMAKE_GENERATOR="${generator:-}" +export CMAKE_GENERATOR_PLATFORM="${platform:-}" export BUILD_TYPE="${build_type:?}" export CXXFLAGS="${example_projects_cxxflags}" export LDFLAGS="${example_projects_ldflags}" @@ -353,11 +345,6 @@ fi # is true. if [[ -z "${MONGODB_API_VERSION:-}" ]]; then echo "Building example projects..." - # shellcheck source=/dev/null - . "${mongoc_dir:?}/.evergreen/scripts/find-cmake-latest.sh" - export cmake_binary - cmake_binary="$(find_cmake_latest)" - command -v "${cmake_binary:?}" .evergreen/build_example_projects.sh echo "Building example projects... done." fi diff --git a/.mci.yml b/.mci.yml index dbde7d36ea..b0df280423 100644 --- a/.mci.yml +++ b/.mci.yml @@ -40,9 +40,15 @@ variables: integration_matrix_expansions_linux: &integration_matrix_expansions_linux build_type: "Debug" ENABLE_CODE_COVERAGE: ON - integration_matrix_expansions_windows: &integration_matrix_expansions_windows + integration_matrix_expansions_windows_vs2017: &integration_matrix_expansions_windows_vs2017 build_type: "Debug" # Same for Windows and Linux - generator: Visual Studio 15 2017 Win64 + generator: Visual Studio 15 2017 + platform: x64 + example_projects_cxx_standard: 17 + integration_matrix_expansions_windows_vs2019: &integration_matrix_expansions_windows_vs2019 + build_type: "Debug" # Same for Windows and Linux + generator: Visual Studio 16 2019 + platform: x64 example_projects_cxx_standard: 17 ####################################### @@ -348,6 +354,7 @@ functions: - ENABLE_CODE_COVERAGE - ENABLE_TESTS - generator + - platform - REQUIRED_CXX_STANDARD - RUN_DISTCHECK - USE_POLYFILL_BOOST @@ -395,6 +402,7 @@ functions: - generator - lib_dir - MONGODB_API_VERSION + - platform - TEST_WITH_ASAN - TEST_WITH_UBSAN - TEST_WITH_VALGRIND @@ -1074,60 +1082,60 @@ buildvariants: <<: *integration_matrix_expansions_linux <<: *integration_matrix_tasks_single - - name: integration-vs2017-latest-single - display_name: "Windows (VS 2017) Debug (MongoDB Latest)" - run_on: windows-64-vs2017-large + - name: integration-vs2019-latest-single + display_name: "Windows (VS 2019) Debug (MongoDB Latest)" + run_on: windows-vsCurrent-large expansions: mongodb_version: "latest" - <<: *integration_matrix_expansions_windows + <<: *integration_matrix_expansions_windows_vs2019 <<: *integration_matrix_tasks_single - - name: integration-vs2017-7.0-single - display_name: "Windows (VS 2017) Debug (MongoDB 7.0)" - run_on: windows-64-vs2017-large + - name: integration-vs2019-7.0-single + display_name: "Windows (VS 2019) Debug (MongoDB 7.0)" + run_on: windows-vsCurrent-large expansions: mongodb_version: "7.0" - <<: *integration_matrix_expansions_windows + <<: *integration_matrix_expansions_windows_vs2019 <<: *integration_matrix_tasks_single - - name: integration-vs2017-6.0-single - display_name: "Windows (VS 2017) Debug (MongoDB 6.0)" - run_on: windows-64-vs2017-large + - name: integration-vs2019-6.0-single + display_name: "Windows (VS 2019) Debug (MongoDB 6.0)" + run_on: windows-vsCurrent-large expansions: mongodb_version: "6.0" - <<: *integration_matrix_expansions_windows + <<: *integration_matrix_expansions_windows_vs2019 <<: *integration_matrix_tasks_single - - name: integration-vs2017-5.0-single - display_name: "Windows (VS 2017) Debug (MongoDB 5.0)" - run_on: windows-64-vs2017-large + - name: integration-vs2019-5.0-single + display_name: "Windows (VS 2019) Debug (MongoDB 5.0)" + run_on: windows-vsCurrent-large expansions: mongodb_version: "5.0" - <<: *integration_matrix_expansions_windows + <<: *integration_matrix_expansions_windows_vs2019 <<: *integration_matrix_tasks_single - - name: integration-vs2017-4.4-single - display_name: "Windows (VS 2017) Debug (MongoDB 4.4)" - run_on: windows-64-vs2017-large + - name: integration-vs2019-4.4-single + display_name: "Windows (VS 2019) Debug (MongoDB 4.4)" + run_on: windows-vsCurrent-large expansions: mongodb_version: "4.4" - <<: *integration_matrix_expansions_windows + <<: *integration_matrix_expansions_windows_vs2019 <<: *integration_matrix_tasks_single - - name: integration-vs2017-4.2-single - display_name: "Windows (VS 2017) Debug (MongoDB 4.2)" - run_on: windows-64-vs2017-large + - name: integration-vs2019-4.2-single + display_name: "Windows (VS 2019) Debug (MongoDB 4.2)" + run_on: windows-vsCurrent-large expansions: mongodb_version: "4.2" - <<: *integration_matrix_expansions_windows + <<: *integration_matrix_expansions_windows_vs2019 <<: *integration_matrix_tasks_single - - name: integration-vs2017-4.0-single - display_name: "Windows (VS 2017) Debug (MongoDB 4.0)" - run_on: windows-64-vs2017-large + - name: integration-vs2019-4.0-single + display_name: "Windows (VS 2019) Debug (MongoDB 4.0)" + run_on: windows-vsCurrent-large expansions: mongodb_version: "4.0" - <<: *integration_matrix_expansions_windows + <<: *integration_matrix_expansions_windows_vs2019 <<: *integration_matrix_tasks_single - name: integration-ubuntu2004-latest-replica @@ -1252,10 +1260,18 @@ buildvariants: - name: integration-auth-vs2017-latest-single display_name: "Windows (VS 2017) Debug Latest Auth" - run_on: windows-64-vs2017-large + run_on: windows-vsCurrent-large + expansions: + mongodb_version: "latest" + <<: *integration_matrix_expansions_windows_vs2017 + <<: *integration_matrix_auth_tasks_single + + - name: integration-auth-vs2019-latest-single + display_name: "Windows (VS 2019) Debug Latest Auth" + run_on: windows-vsCurrent-large expansions: mongodb_version: "latest" - <<: *integration_matrix_expansions_windows + <<: *integration_matrix_expansions_windows_vs2019 <<: *integration_matrix_auth_tasks_single - name: integration-versioned-api-ubuntu2004-latest-single @@ -1266,12 +1282,12 @@ buildvariants: <<: *integration_matrix_expansions_linux <<: *integration_matrix_versioned_api_tasks_single - - name: integration-versioned-api-vs2017-latest-single - display_name: "Windows (VS 2017) Debug Latest Versioned API" - run_on: windows-64-vs2017-large + - name: integration-versioned-api-vs2019-latest-single + display_name: "Windows (VS 2019) Debug Latest Versioned API" + run_on: windows-vsCurrent-large expansions: mongodb_version: "latest" - <<: *integration_matrix_expansions_windows + <<: *integration_matrix_expansions_windows_vs2019 <<: *integration_matrix_versioned_api_tasks_single - name: integration-mongocryptd-ubuntu2004-latest @@ -1833,7 +1849,8 @@ buildvariants: expansions: build_type: "Release" mongodb_version: "4.2" - generator: Visual Studio 14 2015 Win64 + generator: Visual Studio 14 2015 + platform: x64 run_on: - windows-64-vs2015-compile tasks: @@ -1848,7 +1865,8 @@ buildvariants: expansions: build_type: "Debug" mongodb_version: "4.2" - generator: Visual Studio 14 2015 Win64 + generator: Visual Studio 14 2015 + platform: x64 run_on: - windows-64-vs2015-compile tasks: @@ -1860,7 +1878,8 @@ buildvariants: display_name: "Windows (VS 2015) Debug (MongoDB 4.2)" expansions: build_type: "Debug" - generator: Visual Studio 14 2015 Win64 + generator: Visual Studio 14 2015 + platform: x64 mongodb_version: "4.2" run_on: - windows-64-vs2015-compile diff --git a/docs/content/mongocxx-v3/installation/windows.md b/docs/content/mongocxx-v3/installation/windows.md index e60d388924..6c4589d023 100644 --- a/docs/content/mongocxx-v3/installation/windows.md +++ b/docs/content/mongocxx-v3/installation/windows.md @@ -67,7 +67,7 @@ On Windows, the C++ driver is configured as follows (adjusting the path of the C ```sh 'C:\Program Files (x86)\CMake\bin\cmake.exe' .. \ - -G "Visual Studio 14 2015 Win64" \ + -G "Visual Studio 14 2015" -A "x64" \ -DBOOST_ROOT=C:\local\boost_1_60_0 \ -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver ``` @@ -81,7 +81,7 @@ To build with Visual Studio 2017 without a C++17 polyfill, configure as follows: ```sh 'C:\Program Files (x86)\CMake\bin\cmake.exe' .. \ - -G "Visual Studio 15 2017 Win64" \ + -G "Visual Studio 15 2017" -A "x64" \ -DCMAKE_CXX_STANDARD=17 \ -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver \ ``` @@ -94,7 +94,7 @@ To build versions 3.7.0 and older without a C++17 polyfill, it is necessary to c ```sh 'C:\Program Files (x86)\CMake\bin\cmake.exe' .. \ - -G "Visual Studio 15 2017 Win64" \ + -G "Visual Studio 15 2017" -A "x64" \ -DCMAKE_CXX_STANDARD=17 \ -DCMAKE_CXX_FLAGS="/Zc:__cplusplus /EHsc" \ -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver \ diff --git a/examples/projects/bsoncxx/cmake/shared/build.sh b/examples/projects/bsoncxx/cmake/shared/build.sh index 3ce50b5bbe..1e86923671 100755 --- a/examples/projects/bsoncxx/cmake/shared/build.sh +++ b/examples/projects/bsoncxx/cmake/shared/build.sh @@ -13,10 +13,10 @@ if [ -z "$MSVC" ]; then "$CMAKE" --build . --target run else if [ "$CXX_STANDARD" = "17" ]; then - "$CMAKE" -G "Visual Studio 15 2017 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" .. + "$CMAKE" -G "Visual Studio 15 2017" -A "x64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" .. else # Boost is needed for pre-17 Windows polyfill. - "$CMAKE" -G "Visual Studio 14 2015 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DBOOST_ROOT=c:/local/boost_1_60_0 .. + "$CMAKE" -G "Visual Studio 14 2015" -A "x64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DBOOST_ROOT=c:/local/boost_1_60_0 .. fi "$CMAKE" --build . --target run --config "${BUILD_TYPE}" -- /verbosity:minimal fi diff --git a/examples/projects/bsoncxx/cmake/static/build.sh b/examples/projects/bsoncxx/cmake/static/build.sh index 3ce50b5bbe..1e86923671 100755 --- a/examples/projects/bsoncxx/cmake/static/build.sh +++ b/examples/projects/bsoncxx/cmake/static/build.sh @@ -13,10 +13,10 @@ if [ -z "$MSVC" ]; then "$CMAKE" --build . --target run else if [ "$CXX_STANDARD" = "17" ]; then - "$CMAKE" -G "Visual Studio 15 2017 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" .. + "$CMAKE" -G "Visual Studio 15 2017" -A "x64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" .. else # Boost is needed for pre-17 Windows polyfill. - "$CMAKE" -G "Visual Studio 14 2015 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DBOOST_ROOT=c:/local/boost_1_60_0 .. + "$CMAKE" -G "Visual Studio 14 2015" -A "x64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DBOOST_ROOT=c:/local/boost_1_60_0 .. fi "$CMAKE" --build . --target run --config "${BUILD_TYPE}" -- /verbosity:minimal fi diff --git a/examples/projects/mongocxx/cmake/shared/build.sh b/examples/projects/mongocxx/cmake/shared/build.sh index 3ce50b5bbe..1e86923671 100755 --- a/examples/projects/mongocxx/cmake/shared/build.sh +++ b/examples/projects/mongocxx/cmake/shared/build.sh @@ -13,10 +13,10 @@ if [ -z "$MSVC" ]; then "$CMAKE" --build . --target run else if [ "$CXX_STANDARD" = "17" ]; then - "$CMAKE" -G "Visual Studio 15 2017 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" .. + "$CMAKE" -G "Visual Studio 15 2017" -A "x64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" .. else # Boost is needed for pre-17 Windows polyfill. - "$CMAKE" -G "Visual Studio 14 2015 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DBOOST_ROOT=c:/local/boost_1_60_0 .. + "$CMAKE" -G "Visual Studio 14 2015" -A "x64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DBOOST_ROOT=c:/local/boost_1_60_0 .. fi "$CMAKE" --build . --target run --config "${BUILD_TYPE}" -- /verbosity:minimal fi diff --git a/examples/projects/mongocxx/cmake/static/build.sh b/examples/projects/mongocxx/cmake/static/build.sh index 3ce50b5bbe..1e86923671 100755 --- a/examples/projects/mongocxx/cmake/static/build.sh +++ b/examples/projects/mongocxx/cmake/static/build.sh @@ -13,10 +13,10 @@ if [ -z "$MSVC" ]; then "$CMAKE" --build . --target run else if [ "$CXX_STANDARD" = "17" ]; then - "$CMAKE" -G "Visual Studio 15 2017 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" .. + "$CMAKE" -G "Visual Studio 15 2017" -A "x64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" .. else # Boost is needed for pre-17 Windows polyfill. - "$CMAKE" -G "Visual Studio 14 2015 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DBOOST_ROOT=c:/local/boost_1_60_0 .. + "$CMAKE" -G "Visual Studio 14 2015" -A "x64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DBOOST_ROOT=c:/local/boost_1_60_0 .. fi "$CMAKE" --build . --target run --config "${BUILD_TYPE}" -- /verbosity:minimal fi