Skip to content
This repository was archived by the owner on Dec 8, 2021. It is now read-only.

Commit 5e8063b

Browse files
authored
feat: support quickstart with Windows+CMake+Static builds (#1477)
1 parent 97c1e4f commit 5e8063b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

quickstart/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
2727
# spanner:
2828
find_package(spanner_client REQUIRED)
2929

30+
# MSVC requires some additional code to select the correct runtime library
31+
if (VCPKG_TARGET_TRIPLET MATCHES "-static$")
32+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
33+
else ()
34+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
35+
endif ()
36+
3037
# Define your targets.
3138
add_executable(quickstart quickstart.cc)
3239
target_link_libraries(quickstart googleapis-c++::spanner_client)

quickstart/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ bazel build --copt=-DGRPC_BAZEL_BUILD ...
100100

101101
### Windows
102102

103+
To correctly configure the MSVC runtime you should change the CMake minimum
104+
required version to 3.15 or add `-DCMAKE_POLICY_DEFAULT_CMP0091=NEW` to the
105+
CMake configuration step.
106+
103107
gRPC [requires][grpc-roots-pem-bug] an environment variable to configure the trust store for SSL certificates, you
104108
can download and configure this using:
105109

0 commit comments

Comments
 (0)