diff options
author | Jie Luo <anandolee@gmail.com> | 2016-05-11 16:07:43 -0700 |
---|---|---|
committer | Jie Luo <anandolee@gmail.com> | 2016-05-11 16:07:43 -0700 |
commit | e1f588ae3c5efc7e297e1cb76d42f46d0d4eb3ca (patch) | |
tree | 903944637fd62784dfc1c844eb5af96bdffe9863 /cmake | |
parent | c61207492efa36244ffa16cc5b394e71888e4c0f (diff) | |
parent | 71dd9c4a5ed5c0fb3eff12cddd17116432db9faf (diff) | |
download | protobuf-e1f588ae3c5efc7e297e1cb76d42f46d0d4eb3ca.tar.gz protobuf-e1f588ae3c5efc7e297e1cb76d42f46d0d4eb3ca.tar.bz2 protobuf-e1f588ae3c5efc7e297e1cb76d42f46d0d4eb3ca.zip |
Merge pull request #1 from google/beta-3
Beta 3
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/CMakeLists.txt | 114 | ||||
-rw-r--r-- | cmake/README.md | 25 | ||||
-rw-r--r-- | cmake/extract_includes.bat.in | 4 | ||||
-rw-r--r-- | cmake/libprotobuf-lite.cmake | 12 | ||||
-rw-r--r-- | cmake/libprotobuf.cmake | 13 | ||||
-rw-r--r-- | cmake/libprotoc.cmake | 15 | ||||
-rw-r--r-- | cmake/tests.cmake | 18 |
7 files changed, 137 insertions, 64 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 33e069fe..f32a0e4e 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -4,39 +4,65 @@ cmake_minimum_required(VERSION 2.8) # Project project(protobuf C CXX) +# CMake policies +cmake_policy(SET CMP0022 NEW) + # Options -option(BUILD_TESTING "Build tests" ON) -option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF) +option(protobuf_VERBOSE "Enable for verbose output" OFF) +option(protobuf_BUILD_TESTS "Build tests" ON) +if (BUILD_SHARED_LIBS) + set(protobuf_BUILD_SHARED_LIBS_DEFAULT ON) +else (BUILD_SHARED_LIBS) + set(protobuf_BUILD_SHARED_LIBS_DEFAULT OFF) +endif (BUILD_SHARED_LIBS) +option(protobuf_BUILD_SHARED_LIBS "Build Shared Libraries" ${protobuf_BUILD_SHARED_LIBS_DEFAULT}) +option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON) if (MSVC) - option(ZLIB "Build with zlib support" OFF) + set(protobuf_WITH_ZLIB_DEFAULT OFF) +else (MSVC) + set(protobuf_WITH_ZLIB_DEFAULT ON) endif (MSVC) +option(protobuf_WITH_ZLIB "Build with zlib support" ${protobuf_WITH_ZLIB_DEFAULT}) +set(protobuf_DEBUG_POSTFIX "d" + CACHE STRING "Default debug postfix") # Path to main configure script set(protobuf_CONFIGURE_SCRIPT "../configure.ac") -# Parse version from configure script -file(STRINGS "${protobuf_CONFIGURE_SCRIPT}" protobuf_VERSION_LINE - LIMIT_COUNT 1 - REGEX "^AC_INIT") -# Replace special characters -string(REPLACE "(" "_" protobuf_VERSION_LINE ${protobuf_VERSION_LINE}) -string(REPLACE ")" "_" protobuf_VERSION_LINE ${protobuf_VERSION_LINE}) -string(REPLACE "[" "_" protobuf_VERSION_LINE ${protobuf_VERSION_LINE}) -string(REPLACE "]" "_" protobuf_VERSION_LINE ${protobuf_VERSION_LINE}) -# Parse version string -string(REGEX REPLACE "^AC_INIT__Protocol Buffers_,_([^_]+).*$" "\\1" - protobuf_VERSION_STRING "${protobuf_VERSION_LINE}") +# Parse configure script +set(protobuf_AC_INIT_REGEX + "^AC_INIT\\(\\[([^]]+)\\],\\[([^]]+)\\],\\[([^]]+)\\],\\[([^]]+)\\]\\)$") +file(STRINGS "${protobuf_CONFIGURE_SCRIPT}" protobuf_AC_INIT_LINE + LIMIT_COUNT 1 REGEX "^AC_INIT") +# Description +string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\1" + protobuf_DESCRIPTION "${protobuf_AC_INIT_LINE}") +# Version +string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\2" + protobuf_VERSION_STRING "${protobuf_AC_INIT_LINE}") +# Contact +string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\3" + protobuf_CONTACT "${protobuf_AC_INIT_LINE}") # Parse version tweaks -string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$" "\\1" +set(protobuf_VERSION_REGEX "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$") +string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\1" protobuf_VERSION_MAJOR "${protobuf_VERSION_STRING}") -string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$" "\\2" +string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\2" protobuf_VERSION_MINOR "${protobuf_VERSION_STRING}") -string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$" "\\3" +string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\3" protobuf_VERSION_PATCH "${protobuf_VERSION_STRING}") # Package version set(protobuf_VERSION "${protobuf_VERSION_MAJOR}.${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}") +if(protobuf_VERBOSE) + message(STATUS "Configuration script parsing status [") + message(STATUS " Description : ${protobuf_DESCRIPTION}") + message(STATUS " Version : ${protobuf_VERSION} (${protobuf_VERSION_STRING})") + message(STATUS " Contact : ${protobuf_CONTACT}") + message(STATUS "]") +endif() + add_definitions(-DGOOGLE_PROTOBUF_CMAKE_BUILD) find_package(Threads REQUIRED) @@ -44,18 +70,17 @@ 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) +if (protobuf_WITH_ZLIB) find_package(ZLIB) if (ZLIB_FOUND) set(HAVE_ZLIB 1) + # FindZLIB module define ZLIB_INCLUDE_DIRS variable + # Set ZLIB_INCLUDE_DIRECTORIES for compatible + set(ZLIB_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIRECTORIES} ${ZLIB_INCLUDE_DIRS}) + # Using imported target if exists + if (TARGET ZLIB::ZLIB) + set(ZLIB_LIBRARIES ZLIB::ZLIB) + endif (TARGET ZLIB::ZLIB) else (ZLIB_FOUND) set(HAVE_ZLIB 0) # Explicitly set these to empty (override NOT_FOUND) so cmake doesn't @@ -63,21 +88,22 @@ else (MSVC) set(ZLIB_INCLUDE_DIRECTORIES) set(ZLIB_LIBRARIES) endif (ZLIB_FOUND) -endif (MSVC) +endif (protobuf_WITH_ZLIB) 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 +if (protobuf_BUILD_SHARED_LIBS) + set(protobuf_SHARED_OR_STATIC "SHARED") +else (protobuf_BUILD_SHARED_LIBS) + set(protobuf_SHARED_OR_STATIC "STATIC") + # 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 + if (MSVC AND protobuf_MSVC_STATIC_RUNTIME) foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) @@ -85,11 +111,15 @@ if (MSVC) 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) + endif (MSVC AND protobuf_MSVC_STATIC_RUNTIME) +endif (protobuf_BUILD_SHARED_LIBS) if (MSVC) + # Build with multiple processes + add_definitions(/MP) + add_definitions(/wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305) + # Allow big object + add_definitions(/bigobj) 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) @@ -116,8 +146,8 @@ include(libprotobuf.cmake) include(libprotoc.cmake) include(protoc.cmake) -if (BUILD_TESTING) +if (protobuf_BUILD_TESTS) include(tests.cmake) -endif (BUILD_TESTING) +endif (protobuf_BUILD_TESTS) include(install.cmake) diff --git a/cmake/README.md b/cmake/README.md index 4cd049e6..1e7410d8 100644 --- a/cmake/README.md +++ b/cmake/README.md @@ -28,11 +28,11 @@ Create a folder where protobuf headers/libraries/binaries will be installed afte C:\Path\to>mkdir install -If *cmake* coomand is not avaliable from *Command Promt*, add it to system *PATH* variable: +If *cmake* command is not available from *Command Prompt*, add it to system *PATH* variable: C:\Path\to>set PATH=%PATH%;C:\Program Files (x86)\CMake\bin -If *git* coomand is not avaliable from *Command Promt*, add it to system *PATH* variable: +If *git* command is not available from *Command Prompt*, add it to system *PATH* variable: C:\Path\to>set PATH=%PATH%;C:\Program Files\Git\cmd @@ -64,7 +64,7 @@ You can download gmock as follows: C:\Path\to\protobuf>git clone -b release-1.7.0 https://github.com/google/googlemock.git gmock -Then go to *gmock* folder and downdload gtest: +Then go to *gmock* folder and download gtest: C:\Path\to\protobuf>cd gmock C:\Path\to\protobuf\gmock>git clone -b release-1.7.0 https://github.com/google/googletest.git gtest @@ -123,12 +123,12 @@ It will generate *nmake* *Makefile* in current directory. To create *Visual Studio* solution file: - C:\Path\to\protobuf\cmake>mkdir solution & cd solution - C:\Path\to\protobuf\cmake\solution>cmake -G "Visual Studio 12 2013 Win64" ^ + C:\Path\to\protobuf\cmake\build>mkdir solution & cd solution + C:\Path\to\protobuf\cmake\build\solution>cmake -G "Visual Studio 12 2013 Win64" ^ -DCMAKE_INSTALL_PREFIX=../../../../install ^ ../.. -It will generate *Visual Studion* solution file *protobuf.sln* in current directory. +It will generate *Visual Studio* solution file *protobuf.sln* in current directory. If the *gmock* directory does not exist, and you do not want to build protobuf unit tests, you need to add *cmake* command argument `-Dprotobuf_BUILD_TESTS=OFF` to disable testing. @@ -146,24 +146,25 @@ or And wait for the compilation to finish. -You prefer to use the IDE: +If you prefer to use the IDE: * Open the generated protobuf.sln file in Microsoft Visual Studio. * Choose "Debug" or "Release" configuration as desired. * From the Build menu, choose "Build Solution". -wait for the compilation to finish. +And wait for the compilation to finish. Testing ======= -To run unit-tests: +To run unit-tests, first you must compile protobuf as described above. +Then run: C:\Path\to\protobuf\cmake\build\release>nmake check or - C:\Path\to\protobuf\cmake\build\debug>nmake check + C:\Path\to\protobuf\cmake\build\debug>nmake check You can also build project *check* from Visual Studio solution. Yes, it may sound strange, but it works. @@ -211,14 +212,14 @@ To install protobuf to the specified *install* folder: or - C:\Path\to\protobuf\cmake\build\debug>nmake install + C:\Path\to\protobuf\cmake\build\debug>nmake install You can also build project *INSTALL* from Visual Studio solution. It sounds not so strange and it works. This will create the following folders under the *install* location: * bin - that contains protobuf *protoc.exe* compiler; - * inclue - that contains C++ headers and protobuf *.proto files; + * include - that contains C++ headers and protobuf *.proto files; * lib - that contains linking libraries and *CMake* configuration files for *protobuf* package. Now you can if needed: diff --git a/cmake/extract_includes.bat.in b/cmake/extract_includes.bat.in index eaf97583..b593e0c9 100644 --- a/cmake/extract_includes.bat.in +++ b/cmake/extract_includes.bat.in @@ -6,6 +6,7 @@ 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\js mkdir include\google\protobuf\compiler\objectivec mkdir include\google\protobuf\compiler\python mkdir include\google\protobuf\compiler\ruby @@ -26,6 +27,7 @@ copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\importer.h in 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\js\js_generator.h include\google\protobuf\compiler\js\js_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 @@ -72,7 +74,6 @@ copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\source_context.pb.h in 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 @@ -81,6 +82,7 @@ copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_intern 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_power.h include\google\protobuf\stubs\atomicops_internals_power.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 diff --git a/cmake/libprotobuf-lite.cmake b/cmake/libprotobuf-lite.cmake index 9fafc316..036b0517 100644 --- a/cmake/libprotobuf-lite.cmake +++ b/cmake/libprotobuf-lite.cmake @@ -24,9 +24,15 @@ set(libprotobuf_lite_files ${protobuf_source_dir}/src/google/protobuf/wire_format_lite.cc ) -add_library(libprotobuf-lite ${libprotobuf_lite_files}) +add_library(libprotobuf-lite ${protobuf_SHARED_OR_STATIC} + ${libprotobuf_lite_files}) target_link_libraries(libprotobuf-lite ${CMAKE_THREAD_LIBS_INIT}) target_include_directories(libprotobuf-lite PUBLIC ${protobuf_source_dir}/src) +if(MSVC AND protobuf_BUILD_SHARED_LIBS) + target_compile_definitions(libprotobuf-lite + PUBLIC PROTOBUF_USE_DLLS + PRIVATE LIBPROTOBUF_EXPORTS) +endif() set_target_properties(libprotobuf-lite PROPERTIES - COMPILE_DEFINITIONS LIBPROTOBUF_EXPORTS - OUTPUT_NAME ${LIB_PREFIX}protobuf-lite) + OUTPUT_NAME ${LIB_PREFIX}protobuf-lite + DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}") diff --git a/cmake/libprotobuf.cmake b/cmake/libprotobuf.cmake index 64a9cae0..8930c1ca 100644 --- a/cmake/libprotobuf.cmake +++ b/cmake/libprotobuf.cmake @@ -40,6 +40,7 @@ set(libprotobuf_files ${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/proto_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 @@ -53,9 +54,15 @@ set(libprotobuf_files ${protobuf_source_dir}/src/google/protobuf/wrappers.pb.cc ) -add_library(libprotobuf ${libprotobuf_lite_files} ${libprotobuf_files}) +add_library(libprotobuf ${protobuf_SHARED_OR_STATIC} + ${libprotobuf_lite_files} ${libprotobuf_files}) target_link_libraries(libprotobuf ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES}) target_include_directories(libprotobuf PUBLIC ${protobuf_source_dir}/src) +if(MSVC AND protobuf_BUILD_SHARED_LIBS) + target_compile_definitions(libprotobuf + PUBLIC PROTOBUF_USE_DLLS + PRIVATE LIBPROTOBUF_EXPORTS) +endif() set_target_properties(libprotobuf PROPERTIES - COMPILE_DEFINITIONS LIBPROTOBUF_EXPORTS - OUTPUT_NAME ${LIB_PREFIX}protobuf) + OUTPUT_NAME ${LIB_PREFIX}protobuf + DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}") diff --git a/cmake/libprotoc.cmake b/cmake/libprotoc.cmake index 35e5faf2..8df8986a 100644 --- a/cmake/libprotoc.cmake +++ b/cmake/libprotoc.cmake @@ -24,11 +24,11 @@ set(libprotoc_files ${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_reflection_class.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 @@ -37,6 +37,7 @@ set(libprotoc_files ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field_lite.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_lite.cc ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_extension.cc + ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_extension_lite.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 @@ -70,6 +71,7 @@ set(libprotoc_files ${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/js/js_generator.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 @@ -90,8 +92,15 @@ set(libprotoc_files ${protobuf_source_dir}/src/google/protobuf/compiler/zip_writer.cc ) -add_library(libprotoc ${libprotoc_files}) +add_library(libprotoc ${protobuf_SHARED_OR_STATIC} + ${libprotoc_files}) target_link_libraries(libprotoc libprotobuf) +if(MSVC AND protobuf_BUILD_SHARED_LIBS) + target_compile_definitions(libprotoc + PUBLIC PROTOBUF_USE_DLLS + PRIVATE LIBPROTOC_EXPORTS) +endif() set_target_properties(libprotoc PROPERTIES COMPILE_DEFINITIONS LIBPROTOC_EXPORTS - OUTPUT_NAME ${LIB_PREFIX}protoc) + OUTPUT_NAME ${LIB_PREFIX}protoc + DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}") diff --git a/cmake/tests.cmake b/cmake/tests.cmake index 65feca21..76fdf8ef 100644 --- a/cmake/tests.cmake +++ b/cmake/tests.cmake @@ -2,6 +2,9 @@ if (NOT EXISTS "${PROJECT_SOURCE_DIR}/../gmock/CMakeLists.txt") message(FATAL_ERROR "Cannot find gmock directory.") endif() +option(protobuf_ABSOLUTE_TEST_PLUGIN_PATH + "Using absolute test_plugin path in tests" ON) + include_directories( ${protobuf_source_dir}/gmock ${protobuf_source_dir}/gmock/gtest @@ -49,6 +52,8 @@ set(tests_protos google/protobuf/unittest_preserve_unknown_enum.proto google/protobuf/unittest_preserve_unknown_enum2.proto google/protobuf/unittest_proto3_arena.proto + google/protobuf/unittest_proto3_arena_lite.proto + google/protobuf/unittest_proto3_lite.proto google/protobuf/unittest_well_known_types.proto google/protobuf/util/internal/testdata/anys.proto google/protobuf/util/internal/testdata/books.proto @@ -60,6 +65,7 @@ set(tests_protos google/protobuf/util/internal/testdata/struct.proto google/protobuf/util/internal/testdata/timestamp_duration.proto google/protobuf/util/json_format_proto3.proto + google/protobuf/util/message_differencer_unittest.proto ) macro(compile_proto_file filename) @@ -112,6 +118,7 @@ set(tests_files ${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/cpp/metadata_test.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 @@ -136,7 +143,9 @@ set(tests_files ${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_lite_unittest.cc ${protobuf_source_dir}/src/google/protobuf/proto3_arena_unittest.cc + ${protobuf_source_dir}/src/google/protobuf/proto3_lite_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 @@ -164,12 +173,17 @@ set(tests_files ${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/message_differencer_unittest.cc ${protobuf_source_dir}/src/google/protobuf/util/time_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 ) +if(protobuf_ABSOLUTE_TEST_PLUGIN_PATH) + add_compile_options(-DGOOGLE_PROTOBUF_TEST_PLUGIN_PATH="$<TARGET_FILE:test_plugin>") +endif() + add_executable(tests ${tests_files} ${common_test_files} ${tests_proto_files} ${lite_test_proto_files}) target_link_libraries(tests libprotoc libprotobuf gmock_main) @@ -194,3 +208,7 @@ set(lite_arena_test_files ) add_executable(lite-arena-test ${lite_arena_test_files} ${common_lite_test_files} ${lite_test_proto_files}) target_link_libraries(lite-arena-test libprotobuf-lite gmock_main) + +add_custom_target(check + COMMAND tests + WORKING_DIRECTORY ${protobuf_source_dir}) |