Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support for static builds with MSVC #5856

Merged
merged 2 commits into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ cmake_minimum_required(VERSION 3.5)

# Define the project name and where to report bugs.
set(PACKAGE_BUGREPORT "https://github.com/googleapis/google-cloud-cpp/issues")

# Enable support for SelectMSVCRuntime
if (NOT (CMAKE_VERSION VERSION_LESS 3.15))
cmake_policy(SET CMP0091 NEW)
endif ()
project(
google-cloud-cpp
VERSION 1.25.0
Expand All @@ -40,6 +45,9 @@ if (NOT ("${GOOGLE_CLOUD_CPP_CXX_STANDARD}" STREQUAL ""))
"GOOGLE_CLOUD_CPP_CXX_STANDARD is retired, use CMAKE_CXX_STANDARD")
endif ()

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(SelectMSVCRuntime)

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")

# gcc-4.8 is the first release that claims C++11 support.
Expand Down Expand Up @@ -125,7 +133,6 @@ option(GOOGLE_CLOUD_CPP_USE_MASTER_FOR_REFDOC_LINKS
mark_as_advanced(GOOGLE_CLOUD_CPP_USE_MASTER_FOR_REFDOC_LINKS)

set(PROJECT_THIRD_PARTY_DIR "${PROJECT_SOURCE_DIR}/third_party")
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

include(CMakeDependentOption)

Expand Down
3 changes: 1 addition & 2 deletions cmake/SelectMSVCRuntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
if (MSVC)
# TODO(#5852) - if we require CMake >= 3.15 we can remove this conditional
# and the hacks below.
if ((${CMAKE_VERSION} VERSION_GREATER 3.15) OR (${CMAKE_VERSION}
VERSION_EQUAL 3.14))
if (NOT (CMAKE_VERSION VERSION_LESS 3.15))
if (VCPKG_TARGET_TRIPLET MATCHES "-static$")
set(CMAKE_MSVC_RUNTIME_LIBRARY
"MultiThreaded$<$<CONFIG:Debug>:Debug>")
Expand Down