aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates
diff options
context:
space:
mode:
authorGravatar Nicolas Noble <nicolasnoble@users.noreply.github.com>2016-08-18 16:53:43 -0700
committerGravatar GitHub <noreply@github.com>2016-08-18 16:53:43 -0700
commit6cfc80edaf8ec1e46c9cbbc1f402a0a8a8259f16 (patch)
tree915622d46f8ed57f010aa852bf469dc9a6ed803b /templates
parentf906e5543240efbd0b7dd0763cd8ee8c31755d56 (diff)
parent407dc4f28b1807b1d9e361f6c9e3f43015b7b300 (diff)
Merge pull request #7762 from KindDragon/master
Fix CMake for windows (VS2015)
Diffstat (limited to 'templates')
-rw-r--r--templates/CMakeLists.txt.template33
1 files changed, 24 insertions, 9 deletions
diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template
index 4e4223493b..2b6c0b1a36 100644
--- a/templates/CMakeLists.txt.template
+++ b/templates/CMakeLists.txt.template
@@ -66,6 +66,12 @@
set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/")
project(<%text>${PACKAGE_NAME}</%text> C CXX)
+ if (NOT MSVC)
+ set(gRPC_INSTALL ON CACHE BOOL "Generate installation target")
+ else()
+ set(gRPC_INSTALL OFF CACHE BOOL "Generate installation target")
+ endif()
+
set(gRPC_ZLIB_PROVIDER "module" CACHE STRING "Provider of zlib library")
set_property(CACHE gRPC_ZLIB_PROVIDER PROPERTY STRINGS "module" "package")
@@ -77,6 +83,10 @@
set(gRPC_USE_PROTO_LITE OFF CACHE BOOL "Use the protobuf-lite library")
+ if (MSVC)
+ add_definitions( -D_WIN32_WINNT=0x600 )
+ endif()
+
if (gRPC_USE_PROTO_LITE)
set(_gRPC_PROTOBUF_LIBRARY_NAME "libprotobuf-lite")
add_definitions("-DGRPC_USE_PROTO_LITE")
@@ -116,6 +126,7 @@
set(PROTOBUF_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/protobuf)
endif()
if(EXISTS "<%text>${PROTOBUF_ROOT_DIR}</%text>/cmake/CMakeLists.txt")
+ set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Link static runtime libraries")
add_subdirectory(<%text>${PROTOBUF_ROOT_DIR}</%text>/cmake third_party/protobuf)
if(TARGET <%text>${_gRPC_PROTOBUF_LIBRARY_NAME}</%text>)
set(_gRPC_PROTOBUF_LIBRARIES <%text>${_gRPC_PROTOBUF_LIBRARY_NAME}</%text>)
@@ -255,17 +266,21 @@
</%def>
<%def name="cc_install(tgt)">
- install(TARGETS ${tgt.name} EXPORT gRPCTargets
- RUNTIME DESTINATION <%text>${CMAKE_INSTALL_BINDIR}</%text>
- LIBRARY DESTINATION <%text>${CMAKE_INSTALL_LIBDIR}</%text>
- ARCHIVE DESTINATION <%text>${CMAKE_INSTALL_LIBDIR}</%text>
- )
+ if (gRPC_INSTALL)
+ install(TARGETS ${tgt.name} EXPORT gRPCTargets
+ RUNTIME DESTINATION <%text>${CMAKE_INSTALL_BINDIR}</%text>
+ LIBRARY DESTINATION <%text>${CMAKE_INSTALL_LIBDIR}</%text>
+ ARCHIVE DESTINATION <%text>${CMAKE_INSTALL_LIBDIR}</%text>
+ )
+ endif()
</%def>
- install(EXPORT gRPCTargets
- DESTINATION <%text>${CMAKE_INSTALL_CMAKEDIR}</%text>
- NAMESPACE gRPC::
- )
+ if (gRPC_INSTALL)
+ install(EXPORT gRPCTargets
+ DESTINATION <%text>${CMAKE_INSTALL_CMAKEDIR}</%text>
+ NAMESPACE gRPC::
+ )
+ endif()
foreach(_config gRPCConfig gRPCConfigVersion)
configure_file(tools/cmake/<%text>${_config}</%text>.cmake.in