@@ -338,6 +338,22 @@ if(BUILD_TEST)
338
338
if (NOT CAFFE2_USE_MSVC_STATIC_RUNTIME)
339
339
set (gtest_force_shared_crt ON CACHE BOOL "force shared crt on gtest" FORCE)
340
340
endif ()
341
+ # We need to replace googletest cmake scripts too.
342
+ # Otherwise, it will sometimes break the build.
343
+ # To make the git clean after the build, we make a backup first.
344
+ if (MSVC AND MSVC_Z7_OVERRIDE)
345
+ execute_process (
346
+ COMMAND ${CMAKE_COMMAND}
347
+ "-DFILENAME=${CMAKE_CURRENT_LIST_DIR} /../third_party/googletest/googletest/cmake/internal_utils.cmake"
348
+ "-DBACKUP=${CMAKE_CURRENT_LIST_DIR} /../third_party/googletest/googletest/cmake/internal_utils.cmake.bak"
349
+ "-DREVERT=0"
350
+ "-P"
351
+ "${CMAKE_CURRENT_LIST_DIR} /GoogleTestPatch.cmake"
352
+ RESULT_VARIABLE _exitcode)
353
+ if (NOT ${_exitcode} EQUAL 0)
354
+ message (WARNING "Patching failed for Google Test. The build may fail." )
355
+ endif ()
356
+ endif ()
341
357
342
358
# Add googletest subdirectory but make sure our INCLUDE_DIRECTORIES
343
359
# don't bleed into it. This is because libraries installed into the root conda
@@ -363,6 +379,21 @@ if(BUILD_TEST)
363
379
364
380
# Recover build options.
365
381
set (BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE)
382
+
383
+ # To make the git clean after the build, we revert the changes here.
384
+ if (MSVC AND MSVC_Z7_OVERRIDE)
385
+ execute_process (
386
+ COMMAND ${CMAKE_COMMAND}
387
+ "-DFILENAME=${CMAKE_CURRENT_LIST_DIR} /../third_party/googletest/googletest/cmake/internal_utils.cmake"
388
+ "-DBACKUP=${CMAKE_CURRENT_LIST_DIR} /../third_party/googletest/googletest/cmake/internal_utils.cmake.bak"
389
+ "-DREVERT=1"
390
+ "-P"
391
+ "${CMAKE_CURRENT_LIST_DIR} /GoogleTestPatch.cmake"
392
+ RESULT_VARIABLE _exitcode)
393
+ if (NOT ${_exitcode} EQUAL 0)
394
+ message (WARNING "Reverting changes failed for Google Test. The build may fail." )
395
+ endif ()
396
+ endif ()
366
397
endif ()
367
398
368
399
# ---[ FBGEMM
0 commit comments