aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/CMakeLists.txt10
-rw-r--r--cmake/README.md5
-rw-r--r--cmake/libprotobuf-lite.cmake2
-rw-r--r--cmake/libprotobuf.cmake2
-rw-r--r--cmake/libprotoc.cmake2
-rw-r--r--cmake/protobuf-config.cmake.in2
-rw-r--r--cmake/protoc.cmake1
7 files changed, 18 insertions, 6 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 2351392d..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)
@@ -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")
diff --git a/cmake/README.md b/cmake/README.md
index 1e7410d8..305ebb88 100644
--- a/cmake/README.md
+++ b/cmake/README.md
@@ -302,6 +302,11 @@ further disable the option `-Dprotobuf_MSVC_STATIC_RUNTIME=OFF`.
If it reports NOTFOUND for zlib_include or zlib_lib, you might haven't put
the headers or the .lib file in the right directory.
+If you already have ZLIB library and headers at some other location on your system then alternatively you can define following configuration flags to locate them:
+
+ -DZLIB_INCLUDE_DIR=<path to dir containing zlib headers>
+ -DZLIB_LIB=<path to dir containing zlib>
+
Build and testing protobuf as usual.
Notes on Compiler Warnings
diff --git a/cmake/libprotobuf-lite.cmake b/cmake/libprotobuf-lite.cmake
index f5242d4f..2df6a293 100644
--- a/cmake/libprotobuf-lite.cmake
+++ b/cmake/libprotobuf-lite.cmake
@@ -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)
diff --git a/cmake/libprotobuf.cmake b/cmake/libprotobuf.cmake
index 72db915b..65d05c19 100644
--- a/cmake/libprotobuf.cmake
+++ b/cmake/libprotobuf.cmake
@@ -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)
diff --git a/cmake/libprotoc.cmake b/cmake/libprotoc.cmake
index 107c1c52..5f6d078c 100644
--- a/cmake/libprotoc.cmake
+++ b/cmake/libprotoc.cmake
@@ -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)
diff --git a/cmake/protobuf-config.cmake.in b/cmake/protobuf-config.cmake.in
index fd67edc3..acedcc7a 100644
--- a/cmake/protobuf-config.cmake.in
+++ b/cmake/protobuf-config.cmake.in
@@ -110,7 +110,7 @@ function(protobuf_generate)
set(${protobuf_generate_OUT_VAR} ${_generated_srcs_all} PARENT_SCOPE)
endif()
if(protobuf_generate_TARGET)
- target_sources(${protobuf_generate_TARGET} PUBLIC ${_generated_srcs_all})
+ target_sources(${protobuf_generate_TARGET} PRIVATE ${_generated_srcs_all})
endif()
endfunction()
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)