xref: /aosp_15_r20/external/pytorch/cmake/GoogleTestPatch.cmake (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1# CMake file to replace the string contents in Google Test and Google Mock
2# Usage example:
3# Patch the cmake file
4#   cmake -DFILENAME=internal_utils.cmake
5#         -DBACKUP=internal_utils.cmake.bak
6#         -DREVERT=0
7#         -P GoogleTestPatch.cmake
8# Revert the changes
9#   cmake -DFILENAME=internal_utils.cmake
10#         -DBACKUP=internal_utils.cmake.bak
11#         -DREVERT=1
12#         -P GoogleTestPatch.cmake
13
14
15if(REVERT)
16  file(READ ${BACKUP} content)
17  file(WRITE ${FILENAME} "${content}")
18  file(REMOVE ${BACKUP})
19else(REVERT)
20  file(READ ${FILENAME} content)
21  file(WRITE ${BACKUP} "${content}")
22  string(REGEX REPLACE "[-/]Z[iI]" "/Z7" content "${content}")
23  file(WRITE ${FILENAME} "${content}")
24endif(REVERT)
25