From 3bc0282fb688547de7e4533e865904e3b030d5b2 Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Mon, 29 Jan 2018 15:11:59 +0100 Subject: Add VERSION property to CMake library targets --- cmake/libprotobuf-lite.cmake | 1 + cmake/libprotobuf.cmake | 1 + cmake/libprotoc.cmake | 1 + 3 files changed, 3 insertions(+) (limited to 'cmake') diff --git a/cmake/libprotobuf-lite.cmake b/cmake/libprotobuf-lite.cmake index f5242d4f..423b6c17 100644 --- a/cmake/libprotobuf-lite.cmake +++ b/cmake/libprotobuf-lite.cmake @@ -62,5 +62,6 @@ 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}") diff --git a/cmake/libprotobuf.cmake b/cmake/libprotobuf.cmake index 72db915b..e07340d2 100644 --- a/cmake/libprotobuf.cmake +++ b/cmake/libprotobuf.cmake @@ -125,5 +125,6 @@ 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}") diff --git a/cmake/libprotoc.cmake b/cmake/libprotoc.cmake index 107c1c52..a85dccdf 100644 --- a/cmake/libprotoc.cmake +++ b/cmake/libprotoc.cmake @@ -225,5 +225,6 @@ 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}") -- cgit v1.2.3 From f7a05844eb39daaf057c4048e7acbe40a1c7e0da Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Mon, 29 Jan 2018 15:13:23 +0100 Subject: Add CMake ALIAS targets We follow the findProtobuf.cmake naming convention to ease the use of protobuf as cmake subproject --- cmake/libprotobuf-lite.cmake | 1 + cmake/libprotobuf.cmake | 1 + cmake/libprotoc.cmake | 1 + cmake/protoc.cmake | 1 + 4 files changed, 4 insertions(+) (limited to 'cmake') diff --git a/cmake/libprotobuf-lite.cmake b/cmake/libprotobuf-lite.cmake index 423b6c17..2df6a293 100644 --- a/cmake/libprotobuf-lite.cmake +++ b/cmake/libprotobuf-lite.cmake @@ -65,3 +65,4 @@ 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) diff --git a/cmake/libprotobuf.cmake b/cmake/libprotobuf.cmake index e07340d2..65d05c19 100644 --- a/cmake/libprotobuf.cmake +++ b/cmake/libprotobuf.cmake @@ -128,3 +128,4 @@ set_target_properties(libprotobuf PROPERTIES VERSION ${protobuf_VERSION} OUTPUT_NAME ${LIB_PREFIX}protobuf DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}") +add_library(protobuf::libprotobuf ALIAS libprotobuf) diff --git a/cmake/libprotoc.cmake b/cmake/libprotoc.cmake index a85dccdf..5f6d078c 100644 --- a/cmake/libprotoc.cmake +++ b/cmake/libprotoc.cmake @@ -228,3 +228,4 @@ set_target_properties(libprotoc PROPERTIES VERSION ${protobuf_VERSION} OUTPUT_NAME ${LIB_PREFIX}protoc DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}") +add_library(protobuf::libprotoc ALIAS libprotoc) diff --git a/cmake/protoc.cmake b/cmake/protoc.cmake index 4f07c389..5777b16e 100644 --- a/cmake/protoc.cmake +++ b/cmake/protoc.cmake @@ -4,3 +4,4 @@ set(protoc_files add_executable(protoc ${protoc_files}) target_link_libraries(protoc libprotobuf libprotoc) +add_executable(protobuf::protoc ALIAS protoc) -- cgit v1.2.3 From 8dd0f4e557b7f3c376841a09a0ab0fdd80672c13 Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Mon, 29 Jan 2018 15:16:40 +0100 Subject: Even with MSVC enable zlib support as default behaviour. --- cmake/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'cmake') diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 2351392d..1578fb88 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -24,11 +24,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") -- cgit v1.2.3 From 1ec9beb477a2c8c4e77b6e6c9046ea634019644d Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Mon, 29 Jan 2018 15:31:06 +0100 Subject: Use NEW behaviour for project VERSION variables. cf https://cmake.org/cmake/help/latest/policy/CMP0048.html#policy:CMP0048 --- cmake/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cmake') diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 1578fb88..bf3f8863 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -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) -- cgit v1.2.3