Skip to content

Commit 5b743b1

Browse files
authored
CXX-2039 Add VS 2019 support and migrate VS 2017+ to windows-vsCurrent distro (#1082)
* Move VS 2017+ tasks from windows-64-vs2017 to windows-vsCurrent * Move platform specification to CMAKE_GENERATOR_PLATFORM * Forward CMake generator settings to example projects * Rename vs2017 integration variables to avoid conflicts * Remove obsolete MSBUILD path handlers * Migrate most VS 2017 tasks to VS 2019
1 parent cff13ff commit 5b743b1

File tree

9 files changed

+91
-97
lines changed

9 files changed

+91
-97
lines changed

.evergreen/compile.sh

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ set -o pipefail
1919
: "${ENABLE_CODE_COVERAGE:-}"
2020
: "${ENABLE_TESTS:-}"
2121
: "${generator:-}"
22+
: "${platform:-}"
2223
: "${REQUIRED_CXX_STANDARD:-}"
2324
: "${RUN_DISTCHECK:-}"
2425
: "${USE_POLYFILL_BOOST:-}"
@@ -27,23 +28,6 @@ set -o pipefail
2728
: "${USE_SANITIZER_UBSAN:-}"
2829
: "${USE_STATIC_LIBS:-}"
2930

30-
# Add MSBuild.exe to path.
31-
if [[ "${OSTYPE:?}" == "cygwin" ]]; then
32-
case "${generator:-}" in
33-
*2015*)
34-
PATH="/cygdrive/c/cmake/bin:/cygdrive/c/Program Files (x86)/MSBuild/14.0/Bin:$PATH"
35-
;;
36-
*2017*)
37-
PATH="/cygdrive/c/cmake/bin:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2017/Professional/MSBuild/15.0/Bin:$PATH"
38-
;;
39-
*)
40-
echo "missing explicit CMake Generator on Windows distro" 1>&2
41-
exit 1
42-
;;
43-
esac
44-
fi
45-
export PATH
46-
4731
mongoc_prefix="$(pwd)/../mongoc"
4832
echo "mongoc_prefix=${mongoc_prefix:?}"
4933

@@ -123,7 +107,7 @@ case "${OSTYPE:?}" in
123107
cygwin)
124108
case "${generator:-}" in
125109
*2015*) cmake_flags+=("-DBOOST_ROOT=C:/local/boost_1_60_0") ;;
126-
*2017*) cmake_flags+=("-DCMAKE_CXX_STANDARD=17") ;;
110+
*2017*|*2019*) cmake_flags+=("-DCMAKE_CXX_STANDARD=17") ;;
127111
*)
128112
echo "missing explicit CMake Generator on Windows distro" 1>&2
129113
exit 1
@@ -142,6 +126,7 @@ darwin* | linux*)
142126
;;
143127
esac
144128
export CMAKE_GENERATOR="${generator:?}"
129+
export CMAKE_GENERATOR_PLATFORM="${platform:-}"
145130

146131
if [[ "${USE_POLYFILL_STD_EXPERIMENTAL:-}" == "ON" ]]; then
147132
cmake_flags+=(

.evergreen/install_c_driver.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,17 @@ if [[ "${OSTYPE}" == darwin* ]]; then
8383
}
8484
fi
8585

86+
8687
# Default CMake generator to use if not already provided.
87-
declare cmake_generator
88+
declare CMAKE_GENERATOR CMAKE_GENERATOR_PLATFORM
8889
if [[ "${OSTYPE:?}" == "cygwin" ]]; then
89-
cmake_generator=${generator:-"Visual Studio 14 2015 Win64"}
90+
CMAKE_GENERATOR="${generator:-"Visual Studio 14 2015"}"
91+
CMAKE_GENERATOR_PLATFORM="${platform:-"x64"}"
9092
else
91-
cmake_generator=${generator:-"Unix Makefiles"}
93+
CMAKE_GENERATOR="${generator:-"Unix Makefiles"}"
94+
CMAKE_GENERATOR_PLATFORM="${platform:-""}"
9295
fi
93-
: "${cmake_generator:?}"
96+
export CMAKE_GENERATOR CMAKE_GENERATOR_PLATFORM
9497

9598
declare -a configure_flags=(
9699
"-DCMAKE_BUILD_TYPE=Debug"
@@ -131,7 +134,7 @@ fi
131134
# Install libmongoc.
132135
{
133136
echo "Installing C Driver into ${mongoc_dir}..." 1>&2
134-
"${cmake_binary}" -S "${mongoc_idir}" -B "${mongoc_idir}" -G "${cmake_generator}" "${configure_flags[@]}"
137+
"${cmake_binary}" -S "${mongoc_idir}" -B "${mongoc_idir}" "${configure_flags[@]}"
135138
"${cmake_binary}" --build "${mongoc_idir}" --config Debug --target install -- "${compile_flags[@]}"
136139
echo "Installing C Driver into ${mongoc_dir}... done." 1>&2
137140
} >/dev/null

.evergreen/test.sh

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ set -o pipefail
2323
: "${generator:-}"
2424
: "${lib_dir:-}"
2525
: "${MONGODB_API_VERSION:-}"
26+
: "${platform:-}"
2627
: "${TEST_WITH_ASAN:-}"
2728
: "${TEST_WITH_UBSAN:-}"
2829
: "${TEST_WITH_VALGRIND:-}"
@@ -40,23 +41,6 @@ fi
4041
export MONGOCRYPTD_PATH
4142
popd # ..
4243

43-
# Add MSBuild.exe to path.
44-
if [[ "$OSTYPE" == "cygwin" ]]; then
45-
case "${generator}" in
46-
*2015*)
47-
PATH="/cygdrive/c/cmake/bin:/cygdrive/c/Program Files (x86)/MSBuild/14.0/Bin:$PATH"
48-
;;
49-
*2017*)
50-
PATH="/cygdrive/c/cmake/bin:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio/2017/Professional/MSBuild/15.0/Bin:$PATH"
51-
;;
52-
*)
53-
echo "missing explicit CMake Generator on Windows distro" 1>&2
54-
exit 1
55-
;;
56-
esac
57-
fi
58-
export PATH
59-
6044
mongoc_dir="${working_dir:?}/../mongoc"
6145
export mongoc_dir
6246

@@ -111,6 +95,12 @@ fi
11195
export DRIVERS_TOOLS
11296
popd # "${working_dir:?}/../drivers-evergreen-tools"
11397

98+
# shellcheck source=/dev/null
99+
. "${mongoc_dir:?}/.evergreen/scripts/find-cmake-latest.sh"
100+
export cmake_binary
101+
cmake_binary="$(find_cmake_latest)"
102+
command -v "${cmake_binary:?}"
103+
114104
export MONGOCXX_TEST_TLS_CA_FILE="${DRIVERS_TOOLS:?}/.evergreen/x509gen/ca.pem"
115105

116106
if [ "$(uname -m)" == "ppc64le" ]; then
@@ -215,13 +205,13 @@ fi
215205
pushd "${working_dir:?}/build"
216206

217207
if [[ "${OSTYPE:?}" =~ cygwin ]]; then
218-
CTEST_OUTPUT_ON_FAILURE=1 MSBuild.exe /p:Configuration="${build_type:?}" /verbosity:minimal RUN_TESTS.vcxproj
208+
CTEST_OUTPUT_ON_FAILURE=1 "${cmake_binary:?}" --build . --target RUN_TESTS -- /p:Configuration="${build_type:?}" /verbosity:minimal
219209
# Only run examples if MONGODB_API_VERSION is unset. We do not append
220210
# API version to example clients, so examples will fail when requireApiVersion
221211
# is true.
222212
if [[ -z "$MONGODB_API_VERSION" ]]; then
223213
echo "Running examples..."
224-
if ! CTEST_OUTPUT_ON_FAILURE=1 MSBuild.exe /p:Configuration="${build_type:?}" /verbosity:minimal examples/run-examples.vcxproj >|output.txt 2>&1; then
214+
if ! CTEST_OUTPUT_ON_FAILURE=1 "${cmake_binary:?}" --build . --target examples/run-examples -- /p:Configuration="${build_type:?}" /verbosity:minimal >|output.txt 2>&1; then
225215
# Only emit output on failure.
226216
cat output.txt 1>&2
227217
exit 1
@@ -324,6 +314,8 @@ fi
324314
export PKG_CONFIG_PATH
325315

326316
# Environment variables used by example projects.
317+
export CMAKE_GENERATOR="${generator:-}"
318+
export CMAKE_GENERATOR_PLATFORM="${platform:-}"
327319
export BUILD_TYPE="${build_type:?}"
328320
export CXXFLAGS="${example_projects_cxxflags}"
329321
export LDFLAGS="${example_projects_ldflags}"
@@ -353,11 +345,6 @@ fi
353345
# is true.
354346
if [[ -z "${MONGODB_API_VERSION:-}" ]]; then
355347
echo "Building example projects..."
356-
# shellcheck source=/dev/null
357-
. "${mongoc_dir:?}/.evergreen/scripts/find-cmake-latest.sh"
358-
export cmake_binary
359-
cmake_binary="$(find_cmake_latest)"
360-
command -v "${cmake_binary:?}"
361348
.evergreen/build_example_projects.sh
362349
echo "Building example projects... done."
363350
fi

.mci.yml

Lines changed: 58 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,15 @@ variables:
4040
integration_matrix_expansions_linux: &integration_matrix_expansions_linux
4141
build_type: "Debug"
4242
ENABLE_CODE_COVERAGE: ON
43-
integration_matrix_expansions_windows: &integration_matrix_expansions_windows
43+
integration_matrix_expansions_windows_vs2017: &integration_matrix_expansions_windows_vs2017
4444
build_type: "Debug" # Same for Windows and Linux
45-
generator: Visual Studio 15 2017 Win64
45+
generator: Visual Studio 15 2017
46+
platform: x64
47+
example_projects_cxx_standard: 17
48+
integration_matrix_expansions_windows_vs2019: &integration_matrix_expansions_windows_vs2019
49+
build_type: "Debug" # Same for Windows and Linux
50+
generator: Visual Studio 16 2019
51+
platform: x64
4652
example_projects_cxx_standard: 17
4753

4854
#######################################
@@ -348,6 +354,7 @@ functions:
348354
- ENABLE_CODE_COVERAGE
349355
- ENABLE_TESTS
350356
- generator
357+
- platform
351358
- REQUIRED_CXX_STANDARD
352359
- RUN_DISTCHECK
353360
- USE_POLYFILL_BOOST
@@ -395,6 +402,7 @@ functions:
395402
- generator
396403
- lib_dir
397404
- MONGODB_API_VERSION
405+
- platform
398406
- TEST_WITH_ASAN
399407
- TEST_WITH_UBSAN
400408
- TEST_WITH_VALGRIND
@@ -1074,60 +1082,60 @@ buildvariants:
10741082
<<: *integration_matrix_expansions_linux
10751083
<<: *integration_matrix_tasks_single
10761084

1077-
- name: integration-vs2017-latest-single
1078-
display_name: "Windows (VS 2017) Debug (MongoDB Latest)"
1079-
run_on: windows-64-vs2017-large
1085+
- name: integration-vs2019-latest-single
1086+
display_name: "Windows (VS 2019) Debug (MongoDB Latest)"
1087+
run_on: windows-vsCurrent-large
10801088
expansions:
10811089
mongodb_version: "latest"
1082-
<<: *integration_matrix_expansions_windows
1090+
<<: *integration_matrix_expansions_windows_vs2019
10831091
<<: *integration_matrix_tasks_single
10841092

1085-
- name: integration-vs2017-7.0-single
1086-
display_name: "Windows (VS 2017) Debug (MongoDB 7.0)"
1087-
run_on: windows-64-vs2017-large
1093+
- name: integration-vs2019-7.0-single
1094+
display_name: "Windows (VS 2019) Debug (MongoDB 7.0)"
1095+
run_on: windows-vsCurrent-large
10881096
expansions:
10891097
mongodb_version: "7.0"
1090-
<<: *integration_matrix_expansions_windows
1098+
<<: *integration_matrix_expansions_windows_vs2019
10911099
<<: *integration_matrix_tasks_single
10921100

1093-
- name: integration-vs2017-6.0-single
1094-
display_name: "Windows (VS 2017) Debug (MongoDB 6.0)"
1095-
run_on: windows-64-vs2017-large
1101+
- name: integration-vs2019-6.0-single
1102+
display_name: "Windows (VS 2019) Debug (MongoDB 6.0)"
1103+
run_on: windows-vsCurrent-large
10961104
expansions:
10971105
mongodb_version: "6.0"
1098-
<<: *integration_matrix_expansions_windows
1106+
<<: *integration_matrix_expansions_windows_vs2019
10991107
<<: *integration_matrix_tasks_single
11001108

1101-
- name: integration-vs2017-5.0-single
1102-
display_name: "Windows (VS 2017) Debug (MongoDB 5.0)"
1103-
run_on: windows-64-vs2017-large
1109+
- name: integration-vs2019-5.0-single
1110+
display_name: "Windows (VS 2019) Debug (MongoDB 5.0)"
1111+
run_on: windows-vsCurrent-large
11041112
expansions:
11051113
mongodb_version: "5.0"
1106-
<<: *integration_matrix_expansions_windows
1114+
<<: *integration_matrix_expansions_windows_vs2019
11071115
<<: *integration_matrix_tasks_single
11081116

1109-
- name: integration-vs2017-4.4-single
1110-
display_name: "Windows (VS 2017) Debug (MongoDB 4.4)"
1111-
run_on: windows-64-vs2017-large
1117+
- name: integration-vs2019-4.4-single
1118+
display_name: "Windows (VS 2019) Debug (MongoDB 4.4)"
1119+
run_on: windows-vsCurrent-large
11121120
expansions:
11131121
mongodb_version: "4.4"
1114-
<<: *integration_matrix_expansions_windows
1122+
<<: *integration_matrix_expansions_windows_vs2019
11151123
<<: *integration_matrix_tasks_single
11161124

1117-
- name: integration-vs2017-4.2-single
1118-
display_name: "Windows (VS 2017) Debug (MongoDB 4.2)"
1119-
run_on: windows-64-vs2017-large
1125+
- name: integration-vs2019-4.2-single
1126+
display_name: "Windows (VS 2019) Debug (MongoDB 4.2)"
1127+
run_on: windows-vsCurrent-large
11201128
expansions:
11211129
mongodb_version: "4.2"
1122-
<<: *integration_matrix_expansions_windows
1130+
<<: *integration_matrix_expansions_windows_vs2019
11231131
<<: *integration_matrix_tasks_single
11241132

1125-
- name: integration-vs2017-4.0-single
1126-
display_name: "Windows (VS 2017) Debug (MongoDB 4.0)"
1127-
run_on: windows-64-vs2017-large
1133+
- name: integration-vs2019-4.0-single
1134+
display_name: "Windows (VS 2019) Debug (MongoDB 4.0)"
1135+
run_on: windows-vsCurrent-large
11281136
expansions:
11291137
mongodb_version: "4.0"
1130-
<<: *integration_matrix_expansions_windows
1138+
<<: *integration_matrix_expansions_windows_vs2019
11311139
<<: *integration_matrix_tasks_single
11321140

11331141
- name: integration-ubuntu2004-latest-replica
@@ -1252,10 +1260,18 @@ buildvariants:
12521260

12531261
- name: integration-auth-vs2017-latest-single
12541262
display_name: "Windows (VS 2017) Debug Latest Auth"
1255-
run_on: windows-64-vs2017-large
1263+
run_on: windows-vsCurrent-large
1264+
expansions:
1265+
mongodb_version: "latest"
1266+
<<: *integration_matrix_expansions_windows_vs2017
1267+
<<: *integration_matrix_auth_tasks_single
1268+
1269+
- name: integration-auth-vs2019-latest-single
1270+
display_name: "Windows (VS 2019) Debug Latest Auth"
1271+
run_on: windows-vsCurrent-large
12561272
expansions:
12571273
mongodb_version: "latest"
1258-
<<: *integration_matrix_expansions_windows
1274+
<<: *integration_matrix_expansions_windows_vs2019
12591275
<<: *integration_matrix_auth_tasks_single
12601276

12611277
- name: integration-versioned-api-ubuntu2004-latest-single
@@ -1266,12 +1282,12 @@ buildvariants:
12661282
<<: *integration_matrix_expansions_linux
12671283
<<: *integration_matrix_versioned_api_tasks_single
12681284

1269-
- name: integration-versioned-api-vs2017-latest-single
1270-
display_name: "Windows (VS 2017) Debug Latest Versioned API"
1271-
run_on: windows-64-vs2017-large
1285+
- name: integration-versioned-api-vs2019-latest-single
1286+
display_name: "Windows (VS 2019) Debug Latest Versioned API"
1287+
run_on: windows-vsCurrent-large
12721288
expansions:
12731289
mongodb_version: "latest"
1274-
<<: *integration_matrix_expansions_windows
1290+
<<: *integration_matrix_expansions_windows_vs2019
12751291
<<: *integration_matrix_versioned_api_tasks_single
12761292

12771293
- name: integration-mongocryptd-ubuntu2004-latest
@@ -1833,7 +1849,8 @@ buildvariants:
18331849
expansions:
18341850
build_type: "Release"
18351851
mongodb_version: "4.2"
1836-
generator: Visual Studio 14 2015 Win64
1852+
generator: Visual Studio 14 2015
1853+
platform: x64
18371854
run_on:
18381855
- windows-64-vs2015-compile
18391856
tasks:
@@ -1848,7 +1865,8 @@ buildvariants:
18481865
expansions:
18491866
build_type: "Debug"
18501867
mongodb_version: "4.2"
1851-
generator: Visual Studio 14 2015 Win64
1868+
generator: Visual Studio 14 2015
1869+
platform: x64
18521870
run_on:
18531871
- windows-64-vs2015-compile
18541872
tasks:
@@ -1860,7 +1878,8 @@ buildvariants:
18601878
display_name: "Windows (VS 2015) Debug (MongoDB 4.2)"
18611879
expansions:
18621880
build_type: "Debug"
1863-
generator: Visual Studio 14 2015 Win64
1881+
generator: Visual Studio 14 2015
1882+
platform: x64
18641883
mongodb_version: "4.2"
18651884
run_on:
18661885
- windows-64-vs2015-compile

docs/content/mongocxx-v3/installation/windows.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ On Windows, the C++ driver is configured as follows (adjusting the path of the C
6767

6868
```sh
6969
'C:\Program Files (x86)\CMake\bin\cmake.exe' .. \
70-
-G "Visual Studio 14 2015 Win64" \
70+
-G "Visual Studio 14 2015" -A "x64" \
7171
-DBOOST_ROOT=C:\local\boost_1_60_0 \
7272
-DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver
7373
```
@@ -81,7 +81,7 @@ To build with Visual Studio 2017 without a C++17 polyfill, configure as follows:
8181

8282
```sh
8383
'C:\Program Files (x86)\CMake\bin\cmake.exe' .. \
84-
-G "Visual Studio 15 2017 Win64" \
84+
-G "Visual Studio 15 2017" -A "x64" \
8585
-DCMAKE_CXX_STANDARD=17 \
8686
-DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver \
8787
```
@@ -94,7 +94,7 @@ To build versions 3.7.0 and older without a C++17 polyfill, it is necessary to c
9494

9595
```sh
9696
'C:\Program Files (x86)\CMake\bin\cmake.exe' .. \
97-
-G "Visual Studio 15 2017 Win64" \
97+
-G "Visual Studio 15 2017" -A "x64" \
9898
-DCMAKE_CXX_STANDARD=17 \
9999
-DCMAKE_CXX_FLAGS="/Zc:__cplusplus /EHsc" \
100100
-DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver \

examples/projects/bsoncxx/cmake/shared/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ if [ -z "$MSVC" ]; then
1313
"$CMAKE" --build . --target run
1414
else
1515
if [ "$CXX_STANDARD" = "17" ]; then
16-
"$CMAKE" -G "Visual Studio 15 2017 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" ..
16+
"$CMAKE" -G "Visual Studio 15 2017" -A "x64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" ..
1717
else
1818
# Boost is needed for pre-17 Windows polyfill.
19-
"$CMAKE" -G "Visual Studio 14 2015 Win64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DBOOST_ROOT=c:/local/boost_1_60_0 ..
19+
"$CMAKE" -G "Visual Studio 14 2015" -A "x64" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DBOOST_ROOT=c:/local/boost_1_60_0 ..
2020
fi
2121
"$CMAKE" --build . --target run --config "${BUILD_TYPE}" -- /verbosity:minimal
2222
fi

0 commit comments

Comments
 (0)