Merge pull request #4259 from Mizux/master

Various CMake Update
This commit is contained in:
Feng Xiao 2018-02-02 11:47:31 -08:00 committed by GitHub
commit 82e0231607
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 5 deletions

View File

@ -8,6 +8,10 @@ endif()
# CMake policies
cmake_policy(SET CMP0022 NEW)
if(POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif()
# Project
project(protobuf C CXX)
@ -24,11 +28,7 @@ option(protobuf_BUILD_SHARED_LIBS "Build Shared Libraries" ${protobuf_BUILD_SHAR
include(CMakeDependentOption)
cmake_dependent_option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON
"NOT protobuf_BUILD_SHARED_LIBS" OFF)
if (MSVC)
set(protobuf_WITH_ZLIB_DEFAULT OFF)
else (MSVC)
set(protobuf_WITH_ZLIB_DEFAULT ON)
endif (MSVC)
set(protobuf_WITH_ZLIB_DEFAULT ON)
option(protobuf_WITH_ZLIB "Build with zlib support" ${protobuf_WITH_ZLIB_DEFAULT})
set(protobuf_DEBUG_POSTFIX "d"
CACHE STRING "Default debug postfix")

View File

@ -62,5 +62,7 @@ if(MSVC AND protobuf_BUILD_SHARED_LIBS)
PRIVATE LIBPROTOBUF_EXPORTS)
endif()
set_target_properties(libprotobuf-lite PROPERTIES
VERSION ${protobuf_VERSION}
OUTPUT_NAME ${LIB_PREFIX}protobuf-lite
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
add_library(protobuf::libprotobuf-lite ALIAS libprotobuf-lite)

View File

@ -125,5 +125,7 @@ if(MSVC AND protobuf_BUILD_SHARED_LIBS)
PRIVATE LIBPROTOBUF_EXPORTS)
endif()
set_target_properties(libprotobuf PROPERTIES
VERSION ${protobuf_VERSION}
OUTPUT_NAME ${LIB_PREFIX}protobuf
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
add_library(protobuf::libprotobuf ALIAS libprotobuf)

View File

@ -225,5 +225,7 @@ if(MSVC AND protobuf_BUILD_SHARED_LIBS)
endif()
set_target_properties(libprotoc PROPERTIES
COMPILE_DEFINITIONS LIBPROTOC_EXPORTS
VERSION ${protobuf_VERSION}
OUTPUT_NAME ${LIB_PREFIX}protoc
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
add_library(protobuf::libprotoc ALIAS libprotoc)

View File

@ -4,3 +4,4 @@ set(protoc_files
add_executable(protoc ${protoc_files})
target_link_libraries(protoc libprotobuf libprotoc)
add_executable(protobuf::protoc ALIAS protoc)