lower cmake version requirement in FindSanitizer.cmake (#97073)

As indicated by the last comment from PR #93147, we should replace CheckSourceRuns in **cmake/Modules/FindSanitizer.cmake**  with older versions to avoid dependency on CMake 3.19+
Pull Request resolved: https://github.com/pytorch/pytorch/pull/97073
Approved by: https://github.com/vfdev-5, https://github.com/Skylion007
This commit is contained in:
cyy
2023-04-22 02:02:14 +00:00
committed by PyTorch MergeBot
parent 93d0a9c1b5
commit 2b7161e2bf

View File

@ -53,10 +53,18 @@ foreach(sanitizer_name IN ITEMS address thread undefined leak memory)
set(CMAKE_REQUIRED_QUIET ON)
set(_run_res 0)
include(CheckSourceRuns)
include(CheckCSourceRuns)
include(CheckCXXSourceRuns)
foreach(lang IN LISTS languages)
if(lang STREQUAL CXX OR lang STREQUAL C)
check_source_runs(${lang} "${_source_code}"
if(lang STREQUAL C)
check_c_source_runs("${_source_code}"
__${lang}_${sanitizer_name}_res)
if(__${lang}_${sanitizer_name}_res)
set(_run_res 1)
endif()
endif()
if(lang STREQUAL CXX)
check_cxx_source_runs("${_source_code}"
__${lang}_${sanitizer_name}_res)
if(__${lang}_${sanitizer_name}_res)
set(_run_res 1)