aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorDan O'Reilly <oreilldf@gmail.com>2015-08-12 23:57:46 -0400
committerDan O'Reilly <oreilldf@gmail.com>2015-08-12 23:57:46 -0400
commite47cdd5a559f488ba52756927ce68f4cf93874fa (patch)
tree8ce2723e822808baf58e96f569c86035717ea351 /cmake
parentdaeaa6a28b81195f24d89222e649d79c9555af8b (diff)
parent38a56ee4b19d72c2e9d81a08b018704d1addf561 (diff)
downloadprotobuf-e47cdd5a559f488ba52756927ce68f4cf93874fa.tar.gz
protobuf-e47cdd5a559f488ba52756927ce68f4cf93874fa.tar.bz2
protobuf-e47cdd5a559f488ba52756927ce68f4cf93874fa.zip
Merge remote-tracking branch 'upstream/master' into py2_py3_straddle
Conflicts: python/google/protobuf/descriptor_pool.py python/google/protobuf/internal/api_implementation_default_test.py python/google/protobuf/internal/cpp_message.py python/google/protobuf/internal/descriptor_database_test.py python/google/protobuf/internal/descriptor_pool_test.py python/google/protobuf/internal/descriptor_python_test.py python/google/protobuf/internal/descriptor_test.py python/google/protobuf/internal/generator_test.py python/google/protobuf/internal/message_factory_python_test.py python/google/protobuf/internal/message_factory_test.py python/google/protobuf/internal/message_test.py python/google/protobuf/internal/proto_builder_test.py python/google/protobuf/internal/python_message.py python/google/protobuf/internal/reflection_test.py python/google/protobuf/internal/service_reflection_test.py python/google/protobuf/internal/symbol_database_test.py python/google/protobuf/internal/text_encoding_test.py python/google/protobuf/internal/text_format_test.py python/google/protobuf/internal/unknown_fields_test.py python/google/protobuf/internal/wire_format_test.py python/google/protobuf/pyext/descriptor_cpp2_test.py python/google/protobuf/pyext/message_factory_cpp2_test.py python/google/protobuf/pyext/reflection_cpp2_generated_test.py python/setup.py ruby/lib/google/protobuf/message_exts.rb
Diffstat (limited to 'cmake')
-rw-r--r--cmake/CMakeLists.txt91
-rw-r--r--cmake/README.md139
-rw-r--r--cmake/extract_includes.bat.in120
-rw-r--r--cmake/libprotobuf-lite.cmake30
-rw-r--r--cmake/libprotobuf.cmake60
-rw-r--r--cmake/libprotoc.cmake95
-rw-r--r--cmake/protoc.cmake6
-rw-r--r--cmake/tests.cmake182
8 files changed, 723 insertions, 0 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
new file mode 100644
index 00000000..6c91e137
--- /dev/null
+++ b/cmake/CMakeLists.txt
@@ -0,0 +1,91 @@
+cmake_minimum_required(VERSION 2.8)
+
+project(protobuf C CXX)
+
+option(BUILD_TESTING "Build tests" ON)
+option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
+if (MSVC)
+ option(ZLIB "Build with zlib support" OFF)
+endif (MSVC)
+
+add_definitions(-DGOOGLE_PROTOBUF_CMAKE_BUILD)
+
+find_package(Threads REQUIRED)
+if (CMAKE_USE_PTHREADS_INIT)
+ add_definitions(-DHAVE_PTHREAD)
+endif (CMAKE_USE_PTHREADS_INIT)
+
+if (MSVC)
+ if (ZLIB)
+ set(HAVE_ZLIB 1)
+ find_path(ZLIB_INCLUDE_DIRECTORIES zlib.h ${protobuf_SOURCE_DIR})
+ find_library(ZLIB_LIBRARIES zdll ${protobuf_SOURCE_DIR})
+ else (ZLIB)
+ set(HAVE_ZLIB 0)
+ endif (ZLIB)
+else (MSVC)
+ find_package(ZLIB)
+ if (ZLIB_FOUND)
+ set(HAVE_ZLIB 1)
+ else (ZLIB_FOUND)
+ set(HAVE_ZLIB 0)
+ # Explicitly set these to empty (override NOT_FOUND) so cmake doesn't
+ # complain when we use them later.
+ set(ZLIB_INCLUDE_DIRECTORIES)
+ set(ZLIB_LIBRARIES)
+ endif (ZLIB_FOUND)
+endif (MSVC)
+
+if (HAVE_ZLIB)
+ add_definitions(-DHAVE_ZLIB)
+endif (HAVE_ZLIB)
+
+if (MSVC)
+ if (BUILD_SHARED_LIBS)
+ add_definitions(-DPROTOBUF_USE_DLLS)
+ else (BUILD_SHARED_LIBS)
+ # In case we are building static libraries, link also the runtime library statically
+ # so that MSVCR*.DLL is not required at runtime.
+ # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
+ # This is achieved by replacing msvc option /MD with /MT and /MDd with /MTd
+ # http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
+ foreach(flag_var
+ CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+ if(${flag_var} MATCHES "/MD")
+ string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
+ endif(${flag_var} MATCHES "/MD")
+ endforeach(flag_var)
+ endif (BUILD_SHARED_LIBS)
+ add_definitions(/wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305)
+endif (MSVC)
+
+if (MSVC)
+ string(REPLACE "/" "\\" PROTOBUF_SOURCE_WIN32_PATH ${protobuf_SOURCE_DIR})
+ string(REPLACE "/" "\\" PROTOBUF_BINARY_WIN32_PATH ${protobuf_BINARY_DIR})
+ configure_file(extract_includes.bat.in extract_includes.bat)
+endif (MSVC)
+
+get_filename_component(protobuf_source_dir ${protobuf_SOURCE_DIR} PATH)
+
+include_directories(
+ ${ZLIB_INCLUDE_DIRECTORIES}
+ ${protobuf_BINARY_DIR}
+ ${protobuf_source_dir}/src)
+
+if (MSVC)
+ # Add the "lib" prefix for generated .lib outputs.
+ set(LIB_PREFIX lib)
+else (MSVC)
+ # When building with "make", "lib" prefix will be added automatically by
+ # the build tool.
+ set(LIB_PREFIX)
+endif (MSVC)
+
+include(libprotobuf-lite.cmake)
+include(libprotobuf.cmake)
+include(libprotoc.cmake)
+include(protoc.cmake)
+if (BUILD_TESTING)
+ include(tests.cmake)
+endif (BUILD_TESTING)
diff --git a/cmake/README.md b/cmake/README.md
new file mode 100644
index 00000000..c68defd8
--- /dev/null
+++ b/cmake/README.md
@@ -0,0 +1,139 @@
+This directory contains cmake files that can be used to generate MSVC project
+files in order to build protobuf on windows. You need to have cmake installed
+on your computer before proceeding.
+
+Compiling and Installing
+========================
+
+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 gmock directory included.
+
+ 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.
+
+2. Use cmake to generate MSVC project files. Running the following commands
+ in a command shell will generate project files for Visual Studio 2008 in
+ a sub-directory named "build".
+
+ $ cd path/to/protobuf/cmake
+ $ mkdir build
+ $ cd build
+ $ cmake -G "Visual Studio 9 2008" ..
+
+ If you don't have gmock, skip the build of tests by turning off the
+ BUILD_TESTING option:
+
+ $ cmake -G "Visual Studio 9 2008" -DBUILD_TESTING=OFF ..
+
+3. Open the generated protobuf.sln file in Microsoft Visual Studio.
+4. Choose "Debug" or "Release" configuration as desired.
+5. From the Build menu, choose "Build Solution". Wait for compiling to finish.
+6. If you have built tests, run tests.exe and lite-test.exe from a command
+ shell and check that all tests pass. Make sure you have changed the working
+ directory to the output directory because tests.exe will try to find and run
+ test_plugin.exe in the working directory.
+7. Run extract_includes.bat to copy all the public headers into a separate
+ "include" directory. This batch script can be found along with the generated
+ protobuf.sln file in the same directory.
+8. Copy the contents of the include directory to wherever you want to put
+ headers.
+9. Copy protoc.exe wherever you put build tools (probably somewhere in your
+ PATH).
+10. Copy libprotobuf.lib, libprotobuf-lite.lib, and libprotoc.lib wherever you
+ put libraries.
+
+ To avoid conflicts between the MSVC debug and release runtime libraries, when
+ compiling a debug build of your application, you may need to link against a
+ debug build of libprotobuf.lib. Similarly, release builds should link against
+ release libs.
+
+DLLs vs. static linking
+=======================
+
+Static linking is now the default for the Protocol Buffer libraries. Due to
+issues with Win32's use of a separate heap for each DLL, as well as binary
+compatibility issues between different versions of MSVC's STL library, it is
+recommended that you use static linkage only. However, it is possible to
+build libprotobuf and libprotoc as DLLs if you really want. To do this,
+do the following:
+
+ 1. Add an additional flag "-DBUILD_SHARED_LIBS=ON" when invoking cmake:
+
+ $ cmake -G "Visual Studio 9 2008" -DBUILD_SHARED_LIBS=ON ..
+
+ 2. Follow the same steps as described in the above section.
+ 3. When compiling your project, make sure to #define PROTOBUF_USE_DLLS.
+
+When distributing your software to end users, we strongly recommend that you
+do NOT install libprotobuf.dll or libprotoc.dll to any shared location.
+Instead, keep these libraries next to your binaries, in your application's
+own install directory. C++ makes it very difficult to maintain binary
+compatibility between releases, so it is likely that future versions of these
+libraries will *not* be usable as drop-in replacements.
+
+If your project is itself a DLL intended for use by third-party software, we
+recommend that you do NOT expose protocol buffer objects in your library's
+public interface, and that you statically link protocol buffers into your
+library.
+
+ZLib support
+============
+
+If you want to include GzipInputStream and GzipOutputStream
+(google/protobuf/io/gzip_stream.h) in libprotobuf, you will need to do a few
+additional steps:
+
+1. Obtain a copy of the zlib library. The pre-compiled DLL at zlib.net works.
+2. Make sure zlib's two headers are in your include path and that the .lib file
+ is in your library path. You could place all three files directly into this
+ cmake directory to compile libprotobuf, but they need to be visible to
+ your own project as well, so you should probably just put them into the
+ VC shared icnlude and library directories.
+3. Add flag "-DZLIB=ON" when invoking cmake:
+
+ $ cmake -G "Visual Studio 9 2008" -DZLIB=ON ..
+
+ 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.
+4) Open the generated protobuf.sln file and build as usual.
+
+Notes on Compiler Warnings
+==========================
+
+The following warnings have been disabled while building the protobuf libraries
+and compiler. You may have to disable some of them in your own project as
+well, or live with them.
+
+* C4018 - 'expression' : signed/unsigned mismatch
+* C4146 - unary minus operator applied to unsigned type, result still unsigned
+* C4244 - Conversion from 'type1' to 'type2', possible loss of data.
+* C4251 - 'identifier' : class 'type' needs to have dll-interface to be used by
+ clients of class 'type2'
+* C4267 - Conversion from 'size_t' to 'type', possible loss of data.
+* C4305 - 'identifier' : truncation from 'type1' to 'type2'
+* C4355 - 'this' : used in base member initializer list
+* C4800 - 'type' : forcing value to bool 'true' or 'false' (performance warning)
+* C4996 - 'function': was declared deprecated
+
+C4251 is of particular note, if you are compiling the Protocol Buffer library
+as a DLL (see previous section). The protocol buffer library uses templates in
+its public interfaces. MSVC does not provide any reasonable way to export
+template classes from a DLL. However, in practice, it appears that exporting
+templates is not necessary anyway. Since the complete definition of any
+template is available in the header files, anyone importing the DLL will just
+end up compiling instances of the templates into their own binary. The
+Protocol Buffer implementation does not rely on static template members being
+unique, so there should be no problem with this, but MSVC prints warning
+nevertheless. So, we disable it. Unfortunately, this warning will also be
+produced when compiling code which merely uses protocol buffers, meaning you
+may have to disable it in your code too.
+
diff --git a/cmake/extract_includes.bat.in b/cmake/extract_includes.bat.in
new file mode 100644
index 00000000..853332ae
--- /dev/null
+++ b/cmake/extract_includes.bat.in
@@ -0,0 +1,120 @@
+mkdir include
+mkdir include\google
+mkdir include\google\protobuf
+mkdir include\google\protobuf\compiler
+mkdir include\google\protobuf\compiler\cpp
+mkdir include\google\protobuf\compiler\csharp
+mkdir include\google\protobuf\compiler\java
+mkdir include\google\protobuf\compiler\javanano
+mkdir include\google\protobuf\compiler\objectivec
+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
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arena.h include\google\protobuf\arena.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arenastring.h include\google\protobuf\arenastring.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\code_generator.h include\google\protobuf\compiler\code_generator.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\command_line_interface.h include\google\protobuf\compiler\command_line_interface.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\cpp_generator.h include\google\protobuf\compiler\cpp\cpp_generator.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_generator.h include\google\protobuf\compiler\csharp\csharp_generator.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_names.h include\google\protobuf\compiler\csharp\csharp_names.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\importer.h include\google\protobuf\compiler\importer.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_generator.h include\google\protobuf\compiler\java\java_generator.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_names.h include\google\protobuf\compiler\java\java_names.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\javanano\javanano_generator.h include\google\protobuf\compiler\javanano\javanano_generator.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_generator.h include\google\protobuf\compiler\objectivec\objectivec_generator.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_helpers.h include\google\protobuf\compiler\objectivec\objectivec_helpers.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\parser.h include\google\protobuf\compiler\parser.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.h include\google\protobuf\compiler\plugin.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.pb.h include\google\protobuf\compiler\plugin.pb.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\python\python_generator.h include\google\protobuf\compiler\python\python_generator.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\ruby\ruby_generator.h include\google\protobuf\compiler\ruby\ruby_generator.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.h include\google\protobuf\descriptor.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.pb.h include\google\protobuf\descriptor.pb.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor_database.h include\google\protobuf\descriptor_database.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\duration.pb.h include\google\protobuf\duration.pb.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\dynamic_message.h include\google\protobuf\dynamic_message.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\empty.pb.h include\google\protobuf\empty.pb.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\extension_set.h include\google\protobuf\extension_set.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\field_mask.pb.h include\google\protobuf\field_mask.pb.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_reflection.h include\google\protobuf\generated_enum_reflection.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_util.h include\google\protobuf\generated_enum_util.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_reflection.h include\google\protobuf\generated_message_reflection.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_util.h include\google\protobuf\generated_message_util.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\coded_stream.h include\google\protobuf\io\coded_stream.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\gzip_stream.h include\google\protobuf\io\gzip_stream.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\printer.h include\google\protobuf\io\printer.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\strtod.h include\google\protobuf\io\strtod.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\tokenizer.h include\google\protobuf\io\tokenizer.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream.h include\google\protobuf\io\zero_copy_stream.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream_impl.h include\google\protobuf\io\zero_copy_stream_impl.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream_impl_lite.h include\google\protobuf\io\zero_copy_stream_impl_lite.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map.h include\google\protobuf\map.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_entry.h include\google\protobuf\map_entry.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_entry_lite.h include\google\protobuf\map_entry_lite.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field.h include\google\protobuf\map_field.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field_inl.h include\google\protobuf\map_field_inl.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field_lite.h include\google\protobuf\map_field_lite.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_type_handler.h include\google\protobuf\map_type_handler.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\message.h include\google\protobuf\message.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\message_lite.h include\google\protobuf\message_lite.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\metadata.h include\google\protobuf\metadata.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\reflection.h include\google\protobuf\reflection.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\reflection_ops.h include\google\protobuf\reflection_ops.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\repeated_field.h include\google\protobuf\repeated_field.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\repeated_field_reflection.h include\google\protobuf\repeated_field_reflection.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\service.h include\google\protobuf\service.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\source_context.pb.h include\google\protobuf\source_context.pb.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\struct.pb.h include\google\protobuf\struct.pb.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomic_sequence_num.h include\google\protobuf\stubs\atomic_sequence_num.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops.h include\google\protobuf\stubs\atomicops.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_aix.h include\google\protobuf\stubs\atomicops_internals_aix.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm64_gcc.h include\google\protobuf\stubs\atomicops_internals_arm64_gcc.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm_gcc.h include\google\protobuf\stubs\atomicops_internals_arm_gcc.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm_qnx.h include\google\protobuf\stubs\atomicops_internals_arm_qnx.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_atomicword_compat.h include\google\protobuf\stubs\atomicops_internals_atomicword_compat.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_generic_gcc.h include\google\protobuf\stubs\atomicops_internals_generic_gcc.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_macosx.h include\google\protobuf\stubs\atomicops_internals_macosx.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_mips_gcc.h include\google\protobuf\stubs\atomicops_internals_mips_gcc.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_pnacl.h include\google\protobuf\stubs\atomicops_internals_pnacl.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_solaris.h include\google\protobuf\stubs\atomicops_internals_solaris.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_tsan.h include\google\protobuf\stubs\atomicops_internals_tsan.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_x86_gcc.h include\google\protobuf\stubs\atomicops_internals_x86_gcc.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_x86_msvc.h include\google\protobuf\stubs\atomicops_internals_x86_msvc.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\bytestream.h include\google\protobuf\stubs\bytestream.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\callback.h include\google\protobuf\stubs\callback.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\casts.h include\google\protobuf\stubs\casts.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\common.h include\google\protobuf\stubs\common.h
+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\logging.h include\google\protobuf\stubs\logging.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\macros.h include\google\protobuf\stubs\macros.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\mutex.h include\google\protobuf\stubs\mutex.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\platform_macros.h include\google\protobuf\stubs\platform_macros.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\port.h include\google\protobuf\stubs\port.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\scoped_ptr.h include\google\protobuf\stubs\scoped_ptr.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
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\status.h include\google\protobuf\stubs\status.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\stl_util.h include\google\protobuf\stubs\stl_util.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\stringpiece.h include\google\protobuf\stubs\stringpiece.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\template_util.h include\google\protobuf\stubs\template_util.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\type_traits.h include\google\protobuf\stubs\type_traits.h
+copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\text_format.h include\google\protobuf\text_format.h
+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
diff --git a/cmake/libprotobuf-lite.cmake b/cmake/libprotobuf-lite.cmake
new file mode 100644
index 00000000..e323840a
--- /dev/null
+++ b/cmake/libprotobuf-lite.cmake
@@ -0,0 +1,30 @@
+set(libprotobuf_lite_files
+ ${protobuf_source_dir}/src/google/protobuf/arena.cc
+ ${protobuf_source_dir}/src/google/protobuf/arenastring.cc
+ ${protobuf_source_dir}/src/google/protobuf/extension_set.cc
+ ${protobuf_source_dir}/src/google/protobuf/generated_message_util.cc
+ ${protobuf_source_dir}/src/google/protobuf/io/coded_stream.cc
+ ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.cc
+ ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
+ ${protobuf_source_dir}/src/google/protobuf/message_lite.cc
+ ${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
+)
+
+add_library(libprotobuf-lite ${libprotobuf_lite_files})
+target_link_libraries(libprotobuf-lite ${CMAKE_THREAD_LIBS_INIT})
+target_include_directories(libprotobuf-lite PUBLIC ${protobuf_source_dir}/src)
+set_target_properties(libprotobuf-lite PROPERTIES
+ COMPILE_DEFINITIONS LIBPROTOBUF_EXPORTS
+ OUTPUT_NAME ${LIB_PREFIX}protobuf-lite)
diff --git a/cmake/libprotobuf.cmake b/cmake/libprotobuf.cmake
new file mode 100644
index 00000000..31fb1fb2
--- /dev/null
+++ b/cmake/libprotobuf.cmake
@@ -0,0 +1,60 @@
+set(libprotobuf_files
+ ${protobuf_source_dir}/src/google/protobuf/any.cc
+ ${protobuf_source_dir}/src/google/protobuf/any.pb.cc
+ ${protobuf_source_dir}/src/google/protobuf/api.pb.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/importer.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/parser.cc
+ ${protobuf_source_dir}/src/google/protobuf/descriptor.cc
+ ${protobuf_source_dir}/src/google/protobuf/descriptor.pb.cc
+ ${protobuf_source_dir}/src/google/protobuf/descriptor_database.cc
+ ${protobuf_source_dir}/src/google/protobuf/duration.pb.cc
+ ${protobuf_source_dir}/src/google/protobuf/dynamic_message.cc
+ ${protobuf_source_dir}/src/google/protobuf/empty.pb.cc
+ ${protobuf_source_dir}/src/google/protobuf/extension_set_heavy.cc
+ ${protobuf_source_dir}/src/google/protobuf/field_mask.pb.cc
+ ${protobuf_source_dir}/src/google/protobuf/generated_message_reflection.cc
+ ${protobuf_source_dir}/src/google/protobuf/io/gzip_stream.cc
+ ${protobuf_source_dir}/src/google/protobuf/io/printer.cc
+ ${protobuf_source_dir}/src/google/protobuf/io/strtod.cc
+ ${protobuf_source_dir}/src/google/protobuf/io/tokenizer.cc
+ ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.cc
+ ${protobuf_source_dir}/src/google/protobuf/map_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/message.cc
+ ${protobuf_source_dir}/src/google/protobuf/reflection_ops.cc
+ ${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/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
+)
+
+add_library(libprotobuf ${libprotobuf_lite_files} ${libprotobuf_files})
+target_link_libraries(libprotobuf ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES})
+target_include_directories(libprotobuf PUBLIC ${protobuf_source_dir}/src)
+set_target_properties(libprotobuf PROPERTIES
+ COMPILE_DEFINITIONS LIBPROTOBUF_EXPORTS
+ OUTPUT_NAME ${LIB_PREFIX}protobuf)
diff --git a/cmake/libprotoc.cmake b/cmake/libprotoc.cmake
new file mode 100644
index 00000000..f8fa7adb
--- /dev/null
+++ b/cmake/libprotoc.cmake
@@ -0,0 +1,95 @@
+set(libprotoc_files
+ ${protobuf_source_dir}/src/google/protobuf/compiler/code_generator.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/command_line_interface.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_enum.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_extension.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_file.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_generator.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_helpers.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_map_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_message.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_message_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_service.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_string_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_enum.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_enum_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_field_base.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_generator.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_helpers.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_map_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_message.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_message_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_context.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_doc_comment.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field_lite.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_extension.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_file.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_generator.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_generator_factory.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_helpers.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_lazy_message_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_map_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_map_field_lite.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_builder.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_builder_lite.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_field_lite.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_lite.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_name_resolver.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_primitive_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_service.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_shared_code_generator.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_string_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_string_field_lite.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_enum.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_enum_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_extension.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_file.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_generator.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_helpers.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_map_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_message.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_message_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_extension.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_file.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/plugin.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/plugin.pb.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/python/python_generator.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/ruby/ruby_generator.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/subprocess.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/zip_writer.cc
+)
+
+add_library(libprotoc ${libprotoc_files})
+target_link_libraries(libprotoc libprotobuf)
+set_target_properties(libprotoc PROPERTIES
+ COMPILE_DEFINITIONS LIBPROTOC_EXPORTS
+ OUTPUT_NAME ${LIB_PREFIX}protoc)
diff --git a/cmake/protoc.cmake b/cmake/protoc.cmake
new file mode 100644
index 00000000..4f07c389
--- /dev/null
+++ b/cmake/protoc.cmake
@@ -0,0 +1,6 @@
+set(protoc_files
+ ${protobuf_source_dir}/src/google/protobuf/compiler/main.cc
+)
+
+add_executable(protoc ${protoc_files})
+target_link_libraries(protoc libprotobuf libprotoc)
diff --git a/cmake/tests.cmake b/cmake/tests.cmake
new file mode 100644
index 00000000..16c94933
--- /dev/null
+++ b/cmake/tests.cmake
@@ -0,0 +1,182 @@
+if (NOT EXISTS "${PROJECT_SOURCE_DIR}/../gmock/CMakeLists.txt")
+ message(FATAL_ERROR "Cannot find gmock directory.")
+endif()
+
+include_directories(
+ ${protobuf_source_dir}/gmock
+ ${protobuf_source_dir}/gmock/gtest
+ ${protobuf_source_dir}/gmock/gtest/include
+ ${protobuf_source_dir}/gmock/include
+)
+
+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
+ google/protobuf/unittest_import_lite.proto
+ google/protobuf/unittest_import_public_lite.proto
+ google/protobuf/unittest_lite.proto
+)
+
+set(tests_protos
+ google/protobuf/any_test.proto
+ google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto
+ google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto
+ google/protobuf/map_proto2_unittest.proto
+ google/protobuf/map_unittest.proto
+ google/protobuf/unittest.proto
+ google/protobuf/unittest_arena.proto
+ google/protobuf/unittest_custom_options.proto
+ google/protobuf/unittest_drop_unknown_fields.proto
+ google/protobuf/unittest_embed_optimize_for.proto
+ google/protobuf/unittest_empty.proto
+ google/protobuf/unittest_enormous_descriptor.proto
+ google/protobuf/unittest_import.proto
+ google/protobuf/unittest_import_public.proto
+ google/protobuf/unittest_lite_imports_nonlite.proto
+ google/protobuf/unittest_mset.proto
+ google/protobuf/unittest_no_arena.proto
+ google/protobuf/unittest_no_arena_import.proto
+ google/protobuf/unittest_no_field_presence.proto
+ google/protobuf/unittest_no_generic_services.proto
+ google/protobuf/unittest_optimize_for.proto
+ google/protobuf/unittest_preserve_unknown_enum.proto
+ 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)
+ get_filename_component(dirname ${filename} PATH)
+ 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
+ )
+endmacro(compile_proto_file)
+
+set(lite_test_proto_files)
+foreach(proto_file ${lite_test_protos})
+ compile_proto_file(${proto_file})
+ string(REPLACE .proto .pb.cc pb_file ${proto_file})
+ set(lite_test_proto_files ${lite_test_proto_files}
+ ${protobuf_source_dir}/src/${pb_file})
+endforeach(proto_file)
+
+set(tests_proto_files)
+foreach(proto_file ${tests_protos})
+ compile_proto_file(${proto_file})
+ string(REPLACE .proto .pb.cc pb_file ${proto_file})
+ set(tests_proto_files ${tests_proto_files}
+ ${protobuf_source_dir}/src/${pb_file})
+endforeach(proto_file)
+
+set(common_test_files
+ ${protobuf_source_dir}/src/google/protobuf/arena_test_util.cc
+ ${protobuf_source_dir}/src/google/protobuf/map_test_util.cc
+ ${protobuf_source_dir}/src/google/protobuf/test_util.cc
+ ${protobuf_source_dir}/src/google/protobuf/testing/file.cc
+ ${protobuf_source_dir}/src/google/protobuf/testing/googletest.cc
+)
+
+set(tests_files
+ ${protobuf_source_dir}/src/google/protobuf/any_test.cc
+ ${protobuf_source_dir}/src/google/protobuf/arena_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/arenastring_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/command_line_interface_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/importer_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_doc_comment_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_plugin_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/mock_code_generator.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/parser_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/python/python_plugin_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/descriptor_database_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/descriptor_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/drop_unknown_fields_test.cc
+ ${protobuf_source_dir}/src/google/protobuf/dynamic_message_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/extension_set_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/generated_message_reflection_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/io/coded_stream_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/io/printer_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/io/tokenizer_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/map_field_test.cc
+ ${protobuf_source_dir}/src/google/protobuf/map_test.cc
+ ${protobuf_source_dir}/src/google/protobuf/message_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/no_field_presence_test.cc
+ ${protobuf_source_dir}/src/google/protobuf/preserve_unknown_enum_test.cc
+ ${protobuf_source_dir}/src/google/protobuf/proto3_arena_unittest.cc
+ ${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 gmock_main)
+
+set(test_plugin_files
+ ${protobuf_source_dir}/src/google/protobuf/compiler/mock_code_generator.cc
+ ${protobuf_source_dir}/src/google/protobuf/testing/file.cc
+ ${protobuf_source_dir}/src/google/protobuf/testing/file.h
+ ${protobuf_source_dir}/src/google/protobuf/compiler/test_plugin.cc
+)
+
+add_executable(test_plugin ${test_plugin_files})
+target_link_libraries(test_plugin libprotoc libprotobuf gmock)
+
+set(lite_test_files
+ ${protobuf_source_dir}/src/google/protobuf/arena_test_util.cc
+ ${protobuf_source_dir}/src/google/protobuf/lite_unittest.cc
+ ${protobuf_source_dir}/src/google/protobuf/map_lite_test_util.cc
+ ${protobuf_source_dir}/src/google/protobuf/test_util_lite.cc
+)
+add_executable(lite-test ${lite_test_files} ${lite_test_proto_files})
+target_link_libraries(lite-test libprotobuf-lite)