aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorJon Skeet <skeet@pobox.com>2015-06-19 17:35:01 +0100
committerJon Skeet <skeet@pobox.com>2015-06-19 17:35:01 +0100
commit50a3a809e849fad5a53be5ccbaefaa02a106b535 (patch)
tree8c4441b6abee41b5e960e7013e5aeb6761616a22 /cmake
parent8e9dd12b3a2a30dacf3b782d4062c43ec68ff2f6 (diff)
parent5b3a8e76356ef2dcb4a87c3fa7323bdec01cf7ce (diff)
downloadprotobuf-50a3a809e849fad5a53be5ccbaefaa02a106b535.tar.gz
protobuf-50a3a809e849fad5a53be5ccbaefaa02a106b535.tar.bz2
protobuf-50a3a809e849fad5a53be5ccbaefaa02a106b535.zip
Merge remote-tracking branch 'upstream/master' into proto3-only
Diffstat (limited to 'cmake')
-rw-r--r--cmake/README.md10
-rw-r--r--cmake/extract_includes.bat.in8
-rw-r--r--cmake/libprotobuf-lite.cmake6
-rw-r--r--cmake/libprotobuf.cmake19
-rw-r--r--cmake/tests.cmake49
-rwxr-xr-xcmake/update_file_lists.sh121
6 files changed, 77 insertions, 136 deletions
diff --git a/cmake/README.md b/cmake/README.md
index 1d5c8bc1..0abe078e 100644
--- a/cmake/README.md
+++ b/cmake/README.md
@@ -5,17 +5,17 @@ on your computer before proceeding.
Compiling and Installing
========================
-1. Check whether a gtest directory exists in the upper level directory. If you
- checkout the code from github via "git clone", this gtest directory won't
+1. Check whether a gmock directory exists in the upper level directory. If you
+ checkout the code from github via "git clone", this gmock directory won't
exist and you won't be able to build protobuf unit-tests. Consider using one
of the release tar balls instead:
https://github.com/google/protobuf/releases
These release tar balls are more stable versions of protobuf and already
- have the gtest directory included.
+ have the gmock directory included.
- You can also download gtest by yourself and put it in the right place.
+ You can also download gmock by yourself and put it in the right place.
If you absolutely don't want to build and run protobuf unit-tests, skip
this step and use protobuf at your own risk.
@@ -29,7 +29,7 @@ Compiling and Installing
$ cd build
$ cmake -G "Visual Studio 9 2008" ..
- If you don't have gtest, skip the build of tests by turning off the
+ If you don't have gmock, skip the build of tests by turning off the
BUILD_TESTING option:
$ cmake -G "Visutal Studio 9 2008" -DBUILD_TESTING=OFF ..
diff --git a/cmake/extract_includes.bat.in b/cmake/extract_includes.bat.in
index b2e9444d..4e34d81a 100644
--- a/cmake/extract_includes.bat.in
+++ b/cmake/extract_includes.bat.in
@@ -11,6 +11,7 @@ mkdir include\google\protobuf\compiler\python
mkdir include\google\protobuf\compiler\ruby
mkdir include\google\protobuf\io
mkdir include\google\protobuf\stubs
+mkdir include\google\protobuf\util
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\any.h include\google\protobuf\any.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\any.pb.h include\google\protobuf\any.pb.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\api.pb.h include\google\protobuf\api.pb.h
@@ -88,6 +89,7 @@ copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\common.h include
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\fastmem.h include\google\protobuf\stubs\fastmem.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\hash.h include\google\protobuf\stubs\hash.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\once.h include\google\protobuf\stubs\once.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\pbconfig.h include\google\protobuf\stubs\pbconfig.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\platform_macros.h include\google\protobuf\stubs\platform_macros.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\shared_ptr.h include\google\protobuf\stubs\shared_ptr.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\singleton.h include\google\protobuf\stubs\singleton.h
@@ -98,8 +100,12 @@ copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\text_format.h include\
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\timestamp.pb.h include\google\protobuf\timestamp.pb.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\type.pb.h include\google\protobuf\type.pb.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\unknown_field_set.h include\google\protobuf\unknown_field_set.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\field_comparator.h include\google\protobuf\util\field_comparator.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\json_util.h include\google\protobuf\util\json_util.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\message_differencer.h include\google\protobuf\util\message_differencer.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\type_resolver.h include\google\protobuf\util\type_resolver.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\type_resolver_util.h include\google\protobuf\util\type_resolver_util.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format.h include\google\protobuf\wire_format.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format_lite.h include\google\protobuf\wire_format_lite.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format_lite_inl.h include\google\protobuf\wire_format_lite_inl.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wrappers.pb.h include\google\protobuf\wrappers.pb.h
-copy ${PROTOBUF_BINARY_WIN32_PATH}\google\protobuf\stubs\pbconfig.h include\google\protobuf\stubs\pbconfig.h
diff --git a/cmake/libprotobuf-lite.cmake b/cmake/libprotobuf-lite.cmake
index 32c2d026..db55ea92 100644
--- a/cmake/libprotobuf-lite.cmake
+++ b/cmake/libprotobuf-lite.cmake
@@ -10,9 +10,15 @@ set(libprotobuf_lite_files
${protobuf_source_dir}/src/google/protobuf/repeated_field.cc
${protobuf_source_dir}/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc
${protobuf_source_dir}/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/bytestream.cc
${protobuf_source_dir}/src/google/protobuf/stubs/common.cc
${protobuf_source_dir}/src/google/protobuf/stubs/once.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/status.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/statusor.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/stringpiece.cc
${protobuf_source_dir}/src/google/protobuf/stubs/stringprintf.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/strutil.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/time.cc
${protobuf_source_dir}/src/google/protobuf/wire_format_lite.cc
)
diff --git a/cmake/libprotobuf.cmake b/cmake/libprotobuf.cmake
index b1f2dc3e..53ba3d3e 100644
--- a/cmake/libprotobuf.cmake
+++ b/cmake/libprotobuf.cmake
@@ -24,13 +24,30 @@ set(libprotobuf_files
${protobuf_source_dir}/src/google/protobuf/service.cc
${protobuf_source_dir}/src/google/protobuf/source_context.pb.cc
${protobuf_source_dir}/src/google/protobuf/struct.pb.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/mathlimits.cc
${protobuf_source_dir}/src/google/protobuf/stubs/structurally_valid.cc
- ${protobuf_source_dir}/src/google/protobuf/stubs/strutil.cc
${protobuf_source_dir}/src/google/protobuf/stubs/substitute.cc
${protobuf_source_dir}/src/google/protobuf/text_format.cc
${protobuf_source_dir}/src/google/protobuf/timestamp.pb.cc
${protobuf_source_dir}/src/google/protobuf/type.pb.cc
${protobuf_source_dir}/src/google/protobuf/unknown_field_set.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/field_comparator.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/datapiece.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/default_value_objectwriter.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/error_listener.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/field_mask_utility.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/json_escaping.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/json_objectwriter.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/json_stream_parser.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/object_writer.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectsource.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectwriter.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/type_info.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/type_info_test_helper.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/utility.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/json_util.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/message_differencer.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/type_resolver_util.cc
${protobuf_source_dir}/src/google/protobuf/wire_format.cc
${protobuf_source_dir}/src/google/protobuf/wrappers.pb.cc
)
diff --git a/cmake/tests.cmake b/cmake/tests.cmake
index 8fb5eef1..16c94933 100644
--- a/cmake/tests.cmake
+++ b/cmake/tests.cmake
@@ -1,10 +1,20 @@
+if (NOT EXISTS "${PROJECT_SOURCE_DIR}/../gmock/CMakeLists.txt")
+ message(FATAL_ERROR "Cannot find gmock directory.")
+endif()
+
include_directories(
- ${protobuf_source_dir}/gtest/include
- ${protobuf_source_dir}/gtest)
+ ${protobuf_source_dir}/gmock
+ ${protobuf_source_dir}/gmock/gtest
+ ${protobuf_source_dir}/gmock/gtest/include
+ ${protobuf_source_dir}/gmock/include
+)
-add_library(gtest STATIC ${protobuf_source_dir}/gtest/src/gtest-all.cc)
-add_library(gtest_main STATIC ${protobuf_source_dir}/gtest/src/gtest_main.cc)
-target_link_libraries(gtest_main gtest)
+add_library(gmock STATIC
+ ${protobuf_source_dir}/gmock/src/gmock-all.cc
+ ${protobuf_source_dir}/gmock/gtest/src/gtest-all.cc
+)
+add_library(gmock_main STATIC ${protobuf_source_dir}/gmock/src/gmock_main.cc)
+target_link_libraries(gmock_main gmock)
set(lite_test_protos
google/protobuf/map_lite_unittest.proto
@@ -39,6 +49,15 @@ set(tests_protos
google/protobuf/unittest_preserve_unknown_enum2.proto
google/protobuf/unittest_proto3_arena.proto
google/protobuf/unittest_well_known_types.proto
+ google/protobuf/util/internal/testdata/anys.proto
+ google/protobuf/util/internal/testdata/books.proto
+ google/protobuf/util/internal/testdata/default_value.proto
+ google/protobuf/util/internal/testdata/default_value_test.proto
+ google/protobuf/util/internal/testdata/field_mask.proto
+ google/protobuf/util/internal/testdata/maps.proto
+ google/protobuf/util/internal/testdata/struct.proto
+ google/protobuf/util/internal/testdata/timestamp_duration.proto
+ google/protobuf/util/json_format_proto3.proto
)
macro(compile_proto_file filename)
@@ -46,10 +65,10 @@ macro(compile_proto_file filename)
get_filename_component(basename ${filename} NAME_WE)
add_custom_command(
OUTPUT ${protobuf_source_dir}/src/${dirname}/${basename}.pb.cc
+ DEPENDS protoc ${protobuf_source_dir}/src/${dirname}/${basename}.proto
COMMAND protoc ${protobuf_source_dir}/src/${dirname}/${basename}.proto
--proto_path=${protobuf_source_dir}/src
--cpp_out=${protobuf_source_dir}/src
- DEPENDS protoc
)
endmacro(compile_proto_file)
@@ -113,21 +132,35 @@ set(tests_files
${protobuf_source_dir}/src/google/protobuf/reflection_ops_unittest.cc
${protobuf_source_dir}/src/google/protobuf/repeated_field_reflection_unittest.cc
${protobuf_source_dir}/src/google/protobuf/repeated_field_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/bytestream_unittest.cc
${protobuf_source_dir}/src/google/protobuf/stubs/common_unittest.cc
${protobuf_source_dir}/src/google/protobuf/stubs/once_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/status_test.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/statusor_test.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/stringpiece_unittest.cc
${protobuf_source_dir}/src/google/protobuf/stubs/stringprintf_unittest.cc
${protobuf_source_dir}/src/google/protobuf/stubs/structurally_valid_unittest.cc
${protobuf_source_dir}/src/google/protobuf/stubs/strutil_unittest.cc
${protobuf_source_dir}/src/google/protobuf/stubs/template_util_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/stubs/time_test.cc
${protobuf_source_dir}/src/google/protobuf/stubs/type_traits_unittest.cc
${protobuf_source_dir}/src/google/protobuf/text_format_unittest.cc
${protobuf_source_dir}/src/google/protobuf/unknown_field_set_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/field_comparator_test.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/default_value_objectwriter_test.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/json_objectwriter_test.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/json_stream_parser_test.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectsource_test.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectwriter_test.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/internal/type_info_test_helper.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/json_util_test.cc
+ ${protobuf_source_dir}/src/google/protobuf/util/type_resolver_util_test.cc
${protobuf_source_dir}/src/google/protobuf/well_known_types_unittest.cc
${protobuf_source_dir}/src/google/protobuf/wire_format_unittest.cc
)
add_executable(tests ${tests_files} ${common_test_files} ${tests_proto_files} ${lite_test_proto_files})
-target_link_libraries(tests libprotoc libprotobuf gtest_main)
+target_link_libraries(tests libprotoc libprotobuf gmock_main)
set(test_plugin_files
${protobuf_source_dir}/src/google/protobuf/compiler/mock_code_generator.cc
@@ -137,7 +170,7 @@ set(test_plugin_files
)
add_executable(test_plugin ${test_plugin_files})
-target_link_libraries(test_plugin libprotoc libprotobuf gtest)
+target_link_libraries(test_plugin libprotoc libprotobuf gmock)
set(lite_test_files
${protobuf_source_dir}/src/google/protobuf/arena_test_util.cc
diff --git a/cmake/update_file_lists.sh b/cmake/update_file_lists.sh
deleted file mode 100755
index 4466c021..00000000
--- a/cmake/update_file_lists.sh
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/bin/sh
-
-# This script copies source file lists from src/Makefile.am to cmake files.
-
-get_variable_value() {
- FILENAME=$1
- VARNAME=$2
- awk "
- BEGIN { start = 0; }
- /^$VARNAME =/ { start = 1; }
- { if (start) { print \$0; } }
- /\\\\\$/ { next; }
- { start = 0; }
- " $FILENAME \
- | sed "s/^$VARNAME =//" \
- | sed "s/[ \\]//g" \
- | grep -v "^\\$" \
- | grep -v "^$" \
- | LC_ALL=C sort | uniq
-}
-
-get_source_files() {
- get_variable_value $@ | grep "cc$"
-}
-
-get_proto_files() {
- get_variable_value $@ | grep "pb.cc$" | sed "s/pb.cc/proto/"
-}
-
-set_variable_value() {
- FILENAME=$1
- VARNAME=$2
- PREFIX=$3
- shift
- shift
- shift
- awk -v values="$*" -v prefix="$PREFIX" "
- BEGIN { start = 0; }
- /^set\\($VARNAME/ {
- start = 1;
- print \$0;
- len = split(values, vlist, \" \");
- for (i = 1; i <= len; ++i) {
- printf(\" %s%s\\n\", prefix, vlist[i]);
- }
- next;
- }
- start && /^\\)/ {
- start = 0;
- }
- !start {
- print \$0;
- }
- " $FILENAME > /tmp/$$
- cp /tmp/$$ $FILENAME
-}
-
-sort_files() {
- for FILE in $@; do
- echo $FILE
- done | LC_ALL=C sort | uniq
-}
-
-MAKEFILE=../src/Makefile.am
-CMAKE_DIR=.
-EXTRACT_INCLUDES_BAT=extract_includes.bat.in
-
-[ -f "$MAKEFILE" ] || {
- echo "Cannot find: $MAKEFILE"
- exit 1
-}
-
-[ -d "$CMAKE_DIR" ] || {
- echo "Cannot find: $CMAKE_DIR"
- exit 1
-}
-
-[ -f "$EXTRACT_INCLUDES_BAT" ] || {
- echo "Cannot find: $EXTRACT_INCLUDES_BAT"
- exit 1
-}
-
-# Extract file lists from src/Makefile.am
-GZHEADERS=$(get_variable_value $MAKEFILE GZHEADERS)
-HEADERS=$(get_variable_value $MAKEFILE nobase_include_HEADERS)
-PUBLIC_HEADERS=$(sort_files $GZHEADERS $HEADERS)
-LIBPROTOBUF_LITE_SOURCES=$(get_source_files $MAKEFILE libprotobuf_lite_la_SOURCES)
-LIBPROTOBUF_SOURCES=$(get_source_files $MAKEFILE libprotobuf_la_SOURCES)
-LIBPROTOC_SOURCES=$(get_source_files $MAKEFILE libprotoc_la_SOURCES)
-LITE_PROTOS=$(get_proto_files $MAKEFILE protoc_lite_outputs)
-PROTOS=$(get_proto_files $MAKEFILE protoc_outputs)
-COMMON_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_TEST_SOURCES)
-TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_test_SOURCES)
-LITE_TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_lite_test_SOURCES)
-
-# Replace file lists in cmake files.
-COMMON_PREFIX="\${protobuf_source_dir}/src/"
-set_variable_value $CMAKE_DIR/libprotobuf-lite.cmake libprotobuf_lite_files $COMMON_PREFIX $LIBPROTOBUF_LITE_SOURCES
-set_variable_value $CMAKE_DIR/libprotobuf.cmake libprotobuf_files $COMMON_PREFIX $LIBPROTOBUF_SOURCES
-set_variable_value $CMAKE_DIR/libprotoc.cmake libprotoc_files $COMMON_PREFIX $LIBPROTOC_SOURCES
-set_variable_value $CMAKE_DIR/tests.cmake lite_test_protos "" $LITE_PROTOS
-set_variable_value $CMAKE_DIR/tests.cmake tests_protos "" $PROTOS
-set_variable_value $CMAKE_DIR/tests.cmake common_test_files $COMMON_PREFIX $COMMON_TEST_SOURCES
-set_variable_value $CMAKE_DIR/tests.cmake tests_files $COMMON_PREFIX $TEST_SOURCES
-set_variable_value $CMAKE_DIR/tests.cmake lite_test_files $COMMON_PREFIX $LITE_TEST_SOURCES
-
-# Generate extract_includes.bat
-echo "mkdir include" > $EXTRACT_INCLUDES_BAT
-for HEADER in $PUBLIC_HEADERS; do
- HEADER_DIR=$(dirname $HEADER)
- while [ ! "$HEADER_DIR" = "." ]; do
- echo $HEADER_DIR | sed "s/\\//\\\\/g"
- HEADER_DIR=$(dirname $HEADER_DIR)
- done
-done | sort | uniq | sed "s/^/mkdir include\\\\/" >> $EXTRACT_INCLUDES_BAT
-for HEADER in $PUBLIC_HEADERS; do
- WINPATH=$(echo $HEADER | sed 's;/;\\;g')
- echo "copy \${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\$WINPATH include\\$WINPATH" >> $EXTRACT_INCLUDES_BAT
-done
-# Add pbconfig.h.
-echo "copy \${PROTOBUF_BINARY_WIN32_PATH}\\google\\protobuf\\stubs\\pbconfig.h include\\google\\protobuf\\stubs\\pbconfig.h" >> $EXTRACT_INCLUDES_BAT