mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
[submodule] Update gtest to v1.17.0 (#153618)
And remove some outdated CMake code. Pull Request resolved: https://github.com/pytorch/pytorch/pull/153618 Approved by: https://github.com/malfet
This commit is contained in:
@ -21,7 +21,7 @@ if(BUILD_TEST)
|
||||
else()
|
||||
add_executable(${test_name} "${test_src}")
|
||||
endif()
|
||||
target_link_libraries(${test_name} ${C10_CUDA_LIB} ${C10_LIB} gtest_main)
|
||||
target_link_libraries(${test_name} ${C10_CUDA_LIB} ${C10_LIB} gmock gtest gtest_main)
|
||||
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
|
||||
if(INSTALL_TEST)
|
||||
set_target_properties(${test_name} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${_rpath_portable_origin}/../lib")
|
||||
|
@ -11,7 +11,7 @@ if(BUILD_TEST)
|
||||
get_filename_component(test_file_name ${test_src} NAME_WE)
|
||||
set(test_name "c10_xpu_${test_file_name}")
|
||||
add_executable(${test_name} "${test_src}")
|
||||
target_link_libraries(${test_name} ${C10_XPU_LIB} gtest_main)
|
||||
target_link_libraries(${test_name} ${C10_XPU_LIB} gmock gtest gtest_main)
|
||||
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
|
||||
if(INSTALL_TEST)
|
||||
set_target_properties(${test_name} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${_rpath_portable_origin}/../lib")
|
||||
|
@ -1763,7 +1763,7 @@ if(BUILD_STATIC_RUNTIME_BENCHMARK)
|
||||
add_executable(static_runtime_bench "${STATIC_RUNTIME_BENCHMARK_SRCS}")
|
||||
add_executable(static_runtime_test "${STATIC_RUNTIME_TEST_SRCS}")
|
||||
target_link_libraries(static_runtime_bench torch_library benchmark)
|
||||
target_link_libraries(static_runtime_test torch_library gtest_main)
|
||||
target_link_libraries(static_runtime_test torch_library gtest_main gtest)
|
||||
endif()
|
||||
|
||||
if(BUILD_MOBILE_BENCHMARK)
|
||||
@ -1834,7 +1834,7 @@ if(BUILD_TEST)
|
||||
foreach(test_src ${Caffe2_CPU_TEST_SRCS})
|
||||
get_filename_component(test_name ${test_src} NAME_WE)
|
||||
add_executable(${test_name} "${test_src}")
|
||||
target_link_libraries(${test_name} torch_library gtest_main)
|
||||
target_link_libraries(${test_name} torch_library gtest_main gtest gmock)
|
||||
if(NOT MSVC)
|
||||
target_link_libraries(${test_name} stdc++)
|
||||
endif()
|
||||
|
@ -620,39 +620,8 @@ if(BUILD_TEST OR BUILD_MOBILE_BENCHMARK OR BUILD_MOBILE_TEST)
|
||||
# need to install it.
|
||||
set(INSTALL_GTEST OFF CACHE BOOL "Install gtest." FORCE)
|
||||
set(BUILD_GMOCK ON CACHE BOOL "Build gmock." FORCE)
|
||||
# For Windows, we will check the runtime used is correctly passed in.
|
||||
if(NOT CAFFE2_USE_MSVC_STATIC_RUNTIME)
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "force shared crt on gtest" FORCE)
|
||||
endif()
|
||||
# We need to replace googletest cmake scripts too.
|
||||
# Otherwise, it will sometimes break the build.
|
||||
# To make the git clean after the build, we make a backup first.
|
||||
if((MSVC AND MSVC_Z7_OVERRIDE) OR USE_CUDA)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
"-DFILENAME=${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest/googletest/cmake/internal_utils.cmake"
|
||||
"-DBACKUP=${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest/googletest/cmake/internal_utils.cmake.bak"
|
||||
"-DREVERT=0"
|
||||
"-P"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/GoogleTestPatch.cmake"
|
||||
RESULT_VARIABLE _exitcode)
|
||||
if(NOT _exitcode EQUAL 0)
|
||||
message(WARNING "Patching failed for Google Test. The build may fail.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Add googletest subdirectory but make sure our INCLUDE_DIRECTORIES
|
||||
# don't bleed into it. This is because libraries installed into the root conda
|
||||
# env (e.g. MKL) add a global /opt/conda/include directory, and if there's
|
||||
# gtest installed in conda, the third_party/googletest/**.cc source files
|
||||
# would try to include headers from /opt/conda/include/gtest/**.h instead of
|
||||
# its own. Once we have proper target-based include directories,
|
||||
# this shouldn't be necessary anymore.
|
||||
get_property(INC_DIR_temp DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
|
||||
set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "")
|
||||
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest)
|
||||
set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES ${INC_DIR_temp})
|
||||
|
||||
include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest/googletest/include)
|
||||
include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest/googlemock/include)
|
||||
|
||||
@ -675,30 +644,6 @@ if(BUILD_TEST OR BUILD_MOBILE_BENCHMARK OR BUILD_MOBILE_TEST)
|
||||
|
||||
# Recover build options.
|
||||
set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE)
|
||||
|
||||
# To make the git clean after the build, we revert the changes here.
|
||||
if(MSVC AND MSVC_Z7_OVERRIDE)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
"-DFILENAME=${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest/googletest/cmake/internal_utils.cmake"
|
||||
"-DBACKUP=${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest/googletest/cmake/internal_utils.cmake.bak"
|
||||
"-DREVERT=1"
|
||||
"-P"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/GoogleTestPatch.cmake"
|
||||
RESULT_VARIABLE _exitcode)
|
||||
if(NOT _exitcode EQUAL 0)
|
||||
message(WARNING "Reverting changes failed for Google Test. The build may fail.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Cacheing variables to enable incremental build.
|
||||
# Without this is cross compiling we end up having to blow build directory
|
||||
# and rebuild from scratch.
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
if(COMPILE_HAVE_STD_REGEX)
|
||||
set(RUN_HAVE_STD_REGEX 0 CACHE INTERNAL "Cache RUN_HAVE_STD_REGEX output for cross-compile.")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# ---[ FBGEMM
|
||||
|
@ -1,24 +0,0 @@
|
||||
# CMake file to replace the string contents in Google Test and Google Mock
|
||||
# Usage example:
|
||||
# Patch the cmake file
|
||||
# cmake -DFILENAME=internal_utils.cmake
|
||||
# -DBACKUP=internal_utils.cmake.bak
|
||||
# -DREVERT=0
|
||||
# -P GoogleTestPatch.cmake
|
||||
# Revert the changes
|
||||
# cmake -DFILENAME=internal_utils.cmake
|
||||
# -DBACKUP=internal_utils.cmake.bak
|
||||
# -DREVERT=1
|
||||
# -P GoogleTestPatch.cmake
|
||||
|
||||
|
||||
if(REVERT)
|
||||
file(READ ${BACKUP} content)
|
||||
file(WRITE ${FILENAME} "${content}")
|
||||
file(REMOVE ${BACKUP})
|
||||
else(REVERT)
|
||||
file(READ ${FILENAME} content)
|
||||
file(WRITE ${BACKUP} "${content}")
|
||||
string(REGEX REPLACE "[-/]Z[iI]" "/Z7" content "${content}")
|
||||
file(WRITE ${FILENAME} "${content}")
|
||||
endif(REVERT)
|
@ -50,7 +50,7 @@ endif()
|
||||
|
||||
add_executable(test_api ${TORCH_API_TEST_SOURCES})
|
||||
target_include_directories(test_api PRIVATE ${ATen_CPU_INCLUDE})
|
||||
target_link_libraries(test_api PRIVATE torch gtest)
|
||||
target_link_libraries(test_api PRIVATE torch gtest gmock)
|
||||
|
||||
if(USE_CUDA)
|
||||
target_compile_definitions(test_api PRIVATE "USE_CUDA")
|
||||
|
@ -125,7 +125,7 @@ if(USE_MKLDNN)
|
||||
target_link_libraries(test_jit PRIVATE caffe2::mkldnn)
|
||||
endif()
|
||||
|
||||
set(JIT_TEST_DEPENDENCIES torch gtest jitbackend_test backend_with_compiler)
|
||||
set(JIT_TEST_DEPENDENCIES torch gtest jitbackend_test backend_with_compiler gmock)
|
||||
|
||||
if(MSVC)
|
||||
list(APPEND JIT_TEST_DEPENDENCIES onnx_library)
|
||||
|
2
third_party/googletest
vendored
2
third_party/googletest
vendored
Submodule third_party/googletest updated: b514bdc898...52eb8108c5
Reference in New Issue
Block a user