aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorCarlos O'Ryan <coryan@users.noreply.github.com>2018-03-26 16:54:32 -0400
committerFeng Xiao <xfxyjwf@gmail.com>2018-03-26 13:54:32 -0700
commit3c5442a95d9608519a76a5db27d21d71dd1137a1 (patch)
tree4dd687999accb76c0bf65fc2178724c5653f1c61 /cmake
parent1156ee7ea73b768bc52f1a42dfcc42120291e268 (diff)
downloadprotobuf-3c5442a95d9608519a76a5db27d21d71dd1137a1.tar.gz
protobuf-3c5442a95d9608519a76a5db27d21d71dd1137a1.tar.bz2
protobuf-3c5442a95d9608519a76a5db27d21d71dd1137a1.zip
Include googletest as a submodule (#3993)
Add googletest as a submodule in third_party/googletest.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/README.md19
-rw-r--r--cmake/tests.cmake20
2 files changed, 15 insertions, 24 deletions
diff --git a/cmake/README.md b/cmake/README.md
index 305ebb88..de14b012 100644
--- a/cmake/README.md
+++ b/cmake/README.md
@@ -55,22 +55,11 @@ Go to the project folder:
C:\Path\to>cd protobuf
C:\Path\to\protobuf>
-Protobuf unit-tests require gmock to build. If you download protobuf source code
-from the *releases* page, the *gmock* directory should already be there. If you checkout
-the code via `git clone`, this *gmock* directory won't exist and you will have to
-download it manually or skip building protobuf unit-tests.
+Remember to update any submodules:
-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 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
-
-If you absolutely don't want to build and run protobuf unit-tests, skip
-this steps and use protobuf at your own risk.
+```console
+C:\Path\to> git submodule update --init --recursive
+```
Now go to *cmake* folder in protobuf sources:
diff --git a/cmake/tests.cmake b/cmake/tests.cmake
index e7c483d4..d7522759 100644
--- a/cmake/tests.cmake
+++ b/cmake/tests.cmake
@@ -1,24 +1,26 @@
-if (NOT EXISTS "${PROJECT_SOURCE_DIR}/../gmock/CMakeLists.txt")
- message(FATAL_ERROR "Cannot find gmock directory.")
+if (NOT EXISTS "${PROJECT_SOURCE_DIR}/../third_party/googletest/CMakeLists.txt")
+ message(FATAL_ERROR "Cannot find third_party/googletest directory.")
endif()
option(protobuf_ABSOLUTE_TEST_PLUGIN_PATH
"Using absolute test_plugin path in tests" ON)
mark_as_advanced(protobuf_ABSOLUTE_TEST_PLUGIN_PATH)
+set(googlemock_source_dir "${protobuf_source_dir}/third_party/googletest/googlemock")
+set(googletest_source_dir "${protobuf_source_dir}/third_party/googletest/googletest")
include_directories(
- ${protobuf_source_dir}/gmock
- ${protobuf_source_dir}/gmock/gtest
- ${protobuf_source_dir}/gmock/gtest/include
- ${protobuf_source_dir}/gmock/include
+ ${googlemock_source_dir}
+ ${googletest_source_dir}
+ ${googletest_source_dir}/include
+ ${googlemock_source_dir}/include
)
add_library(gmock STATIC
- ${protobuf_source_dir}/gmock/src/gmock-all.cc
- ${protobuf_source_dir}/gmock/gtest/src/gtest-all.cc
+ "${googlemock_source_dir}/src/gmock-all.cc"
+ "${googletest_source_dir}/src/gtest-all.cc"
)
target_link_libraries(gmock ${CMAKE_THREAD_LIBS_INIT})
-add_library(gmock_main STATIC ${protobuf_source_dir}/gmock/src/gmock_main.cc)
+add_library(gmock_main STATIC "${googlemock_source_dir}/src/gmock_main.cc")
target_link_libraries(gmock_main gmock)
set(lite_test_protos