[gtest]Re-fix gmock target. (#7887)

This commit is contained in:
JackBoosY 2019-09-04 02:03:10 +08:00 committed by dan-shaw
parent ae2d1b727a
commit ac210b8e8e
4 changed files with 3 additions and 44 deletions

View File

@ -1,4 +1,4 @@
Source: gtest
Version: 2019-08-14-1
Version: 2019-08-14-2
Homepage: https://github.com/google/googletest
Description: GoogleTest and GoogleMock testing frameworks.

View File

@ -1,30 +0,0 @@
diff --git a/googlemock/CMakeLists.txt b/googlemock/CMakeLists.txt
index 9d135ff..0be8a22 100644
--- a/googlemock/CMakeLists.txt
+++ b/googlemock/CMakeLists.txt
@@ -66,6 +66,25 @@ endif()
# call it again here.
config_compiler_and_linker() # from ${gtest_dir}/cmake/internal_utils.cmake
+# Create the CMake package file descriptors.
+if (INSTALL_GTEST)
+ include(CMakePackageConfigHelpers)
+ set(cmake_package_name GMock)
+ set(targets_export_name ${cmake_package_name}Targets CACHE INTERNAL "")
+ set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated" CACHE INTERNAL "")
+ set(cmake_files_install_dir "share/${cmake_package_name}")
+ set(version_file "${generated_dir}/${cmake_package_name}ConfigVersion.cmake")
+ write_basic_package_version_file(${version_file} COMPATIBILITY AnyNewerVersion)
+ install(EXPORT ${targets_export_name}
+ NAMESPACE ${cmake_package_name}::
+ DESTINATION ${cmake_files_install_dir})
+ set(config_file "${generated_dir}/${cmake_package_name}Config.cmake")
+ configure_package_config_file("${gtest_SOURCE_DIR}/cmake/Config.cmake.in"
+ "${config_file}" INSTALL_DESTINATION ${cmake_files_install_dir})
+ install(FILES ${version_file} ${config_file}
+ DESTINATION ${cmake_files_install_dir})
+endif()
+
# Adds Google Mock's and Google Test's header directories to the search path.
set(gmock_build_include_dirs
"${gmock_SOURCE_DIR}/include"

View File

@ -13,7 +13,6 @@ vcpkg_from_github(
PATCHES
0002-Fix-z7-override.patch
fix-main-lib-path.patch
fix-gmock-cmake.patch
)
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "dynamic" GTEST_FORCE_SHARED_CRT)
@ -30,7 +29,6 @@ vcpkg_configure_cmake(
vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/GTest)
vcpkg_fixup_cmake_targets(CONFIG_PATH share/GMock)
file(
INSTALL
@ -52,12 +50,6 @@ file(
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(INSTALL ${SOURCE_PATH}/googletest/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/gtest RENAME copyright)
# Install gmock cmake files.
file(GLOB GMOCK_CMAKE_FILES ${CURRENT_PACKAGES_DIR}/share/gtest/GMock*.cmake)
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/gmock)
file(COPY ${GMOCK_CMAKE_FILES} DESTINATION ${CURRENT_PACKAGES_DIR}/share/gmock)
file(REMOVE ${GMOCK_CMAKE_FILES})
if(EXISTS ${CURRENT_PACKAGES_DIR}/debug/lib/gtest_maind.lib)
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug/lib/manual-link)
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/gtest_maind.lib ${CURRENT_PACKAGES_DIR}/debug/lib/manual-link/gtest_maind.lib)

View File

@ -2,10 +2,7 @@ The package gtest is compatible with built-in CMake targets:
enable_testing()
find_package(GTest MODULE REQUIRED)
target_link_libraries(main PRIVATE GTest::GTest GTest::Main)
find_package(GMock CONFIG REQUIRED)
target_link_libraries(main PRIVATE GMock::gmock GMock::gmock_main)
find_package(GTest CONFIG REQUIRED)
target_link_libraries(main PRIVATE GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main)
add_test(AllTestsInMain main)