mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Modules/CMakeTest*Compiler: use try_compile(NO_CACHE)
Instead of manually doing the cache dance manually, just skip the cache in the first place.
This commit is contained in:
@@ -55,11 +55,9 @@ if(NOT CMAKE_C_COMPILER_WORKS)
|
||||
# Puts test result in cache variable.
|
||||
try_compile(CMAKE_C_COMPILER_WORKS
|
||||
SOURCE_FROM_VAR testCCompiler.c __TestCompiler_testCCompilerSource
|
||||
NO_CACHE
|
||||
OUTPUT_VARIABLE __CMAKE_C_COMPILER_OUTPUT)
|
||||
unset(__TestCompiler_testCCompilerSource)
|
||||
# Move result from cache to normal variable.
|
||||
set(CMAKE_C_COMPILER_WORKS ${CMAKE_C_COMPILER_WORKS})
|
||||
unset(CMAKE_C_COMPILER_WORKS CACHE)
|
||||
__TestCompiler_restoreTryCompileTargetType()
|
||||
if(NOT CMAKE_C_COMPILER_WORKS)
|
||||
PrintTestCompilerResult(CHECK_FAIL "broken")
|
||||
|
||||
@@ -33,12 +33,10 @@ if(NOT CMAKE_CSharp_COMPILER_WORKS)
|
||||
# Puts test result in cache variable.
|
||||
try_compile(CMAKE_CSharp_COMPILER_WORKS
|
||||
SOURCE_FROM_VAR testCSharpCompiler.cs __TestCompiler_testCSharpCompilerSource
|
||||
NO_CACHE
|
||||
OUTPUT_VARIABLE __CMAKE_CSharp_COMPILER_OUTPUT
|
||||
)
|
||||
unset(__TestCompiler_testCSharpCompilerSource)
|
||||
# Move result from cache to normal variable.
|
||||
set(CMAKE_CSharp_COMPILER_WORKS ${CMAKE_CSharp_COMPILER_WORKS})
|
||||
unset(CMAKE_CSharp_COMPILER_WORKS CACHE)
|
||||
set(CSharp_TEST_WAS_RUN 1)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -47,12 +47,10 @@ if(NOT CMAKE_CUDA_COMPILER_WORKS)
|
||||
# Puts test result in cache variable.
|
||||
try_compile(CMAKE_CUDA_COMPILER_WORKS
|
||||
SOURCE_FROM_VAR main.cu __TestCompiler_testCudaCompilerSource
|
||||
NO_CACHE
|
||||
OUTPUT_VARIABLE __CMAKE_CUDA_COMPILER_OUTPUT)
|
||||
unset(__TestCompiler_testCudaCompilerSource)
|
||||
|
||||
# Move result from cache to normal variable.
|
||||
set(CMAKE_CUDA_COMPILER_WORKS ${CMAKE_CUDA_COMPILER_WORKS})
|
||||
unset(CMAKE_CUDA_COMPILER_WORKS CACHE)
|
||||
if(NOT CMAKE_CUDA_COMPILER_WORKS)
|
||||
PrintTestCompilerResult(CHECK_FAIL "broken")
|
||||
string(REPLACE "\n" "\n " _output "${__CMAKE_CUDA_COMPILER_OUTPUT}")
|
||||
|
||||
@@ -55,6 +55,7 @@ if(NOT CMAKE_CXX_COMPILER_WORKS)
|
||||
# Puts test result in cache variable.
|
||||
try_compile(CMAKE_CXX_COMPILER_WORKS
|
||||
SOURCE_FROM_VAR testCXXCompiler.cxx __TestCompiler_testCXXCompilerSource
|
||||
NO_CACHE
|
||||
OUTPUT_VARIABLE __CMAKE_CXX_COMPILER_OUTPUT)
|
||||
if(DEFINED __CMAKE_SAVED_CXX_SCAN_FOR_MODULES)
|
||||
set(CMAKE_CXX_SCAN_FOR_MODULES "${__CMAKE_SAVED_CXX_SCAN_FOR_MODULES}")
|
||||
@@ -63,9 +64,6 @@ if(NOT CMAKE_CXX_COMPILER_WORKS)
|
||||
unset(CMAKE_CXX_SCAN_FOR_MODULES)
|
||||
endif()
|
||||
unset(__TestCompiler_testCXXCompilerSource)
|
||||
# Move result from cache to normal variable.
|
||||
set(CMAKE_CXX_COMPILER_WORKS ${CMAKE_CXX_COMPILER_WORKS})
|
||||
unset(CMAKE_CXX_COMPILER_WORKS CACHE)
|
||||
__TestCompiler_restoreTryCompileTargetType()
|
||||
if(NOT CMAKE_CXX_COMPILER_WORKS)
|
||||
PrintTestCompilerResult(CHECK_FAIL "broken")
|
||||
|
||||
@@ -48,11 +48,9 @@ if(NOT CMAKE_Fortran_COMPILER_WORKS)
|
||||
# Puts test result in cache variable.
|
||||
try_compile(CMAKE_Fortran_COMPILER_WORKS
|
||||
SOURCE_FROM_VAR testFortranCompiler.f __TestCompiler_testFortranCompilerSource
|
||||
NO_CACHE
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
unset(__TestCompiler_testFortranCompilerSource)
|
||||
# Move result from cache to normal variable.
|
||||
set(CMAKE_Fortran_COMPILER_WORKS ${CMAKE_Fortran_COMPILER_WORKS})
|
||||
unset(CMAKE_Fortran_COMPILER_WORKS CACHE)
|
||||
if(NOT CMAKE_Fortran_COMPILER_WORKS)
|
||||
PrintTestCompilerResult(CHECK_FAIL "broken")
|
||||
string(REPLACE "\n" "\n " _output "${OUTPUT}")
|
||||
|
||||
@@ -61,11 +61,9 @@ if(NOT CMAKE_HIP_COMPILER_WORKS)
|
||||
# Puts test result in cache variable.
|
||||
try_compile(CMAKE_HIP_COMPILER_WORKS
|
||||
SOURCE_FROM_VAR testHIPCompiler.hip __TestCompiler_testHIPCompilerSource
|
||||
NO_CACHE
|
||||
OUTPUT_VARIABLE __CMAKE_HIP_COMPILER_OUTPUT)
|
||||
unset(__TestCompiler_testHIPCompilerSource)
|
||||
# Move result from cache to normal variable.
|
||||
set(CMAKE_HIP_COMPILER_WORKS ${CMAKE_HIP_COMPILER_WORKS})
|
||||
unset(CMAKE_HIP_COMPILER_WORKS CACHE)
|
||||
__TestCompiler_restoreTryCompileTargetType()
|
||||
if(NOT CMAKE_HIP_COMPILER_WORKS)
|
||||
PrintTestCompilerResult(CHECK_FAIL "broken")
|
||||
|
||||
@@ -52,11 +52,9 @@ if(NOT CMAKE_OBJC_COMPILER_WORKS)
|
||||
# Puts test result in cache variable.
|
||||
try_compile(CMAKE_OBJC_COMPILER_WORKS
|
||||
SOURCE_FROM_VAR testObjCCompiler.m __TestCompiler_testObjCCompilerSource
|
||||
NO_CACHE
|
||||
OUTPUT_VARIABLE __CMAKE_OBJC_COMPILER_OUTPUT)
|
||||
unset(__TestCompiler_testObjCCompilerSource)
|
||||
# Move result from cache to normal variable.
|
||||
set(CMAKE_OBJC_COMPILER_WORKS ${CMAKE_OBJC_COMPILER_WORKS})
|
||||
unset(CMAKE_OBJC_COMPILER_WORKS CACHE)
|
||||
__TestCompiler_restoreTryCompileTargetType()
|
||||
if(NOT CMAKE_OBJC_COMPILER_WORKS)
|
||||
PrintTestCompilerResult(CHECK_FAIL "broken")
|
||||
|
||||
@@ -51,11 +51,9 @@ if(NOT CMAKE_OBJCXX_COMPILER_WORKS)
|
||||
# Puts test result in cache variable.
|
||||
try_compile(CMAKE_OBJCXX_COMPILER_WORKS
|
||||
SOURCE_FROM_VAR testObjCXXCompiler.mm __TestCompiler_testObjCXXCompilerSource
|
||||
NO_CACHE
|
||||
OUTPUT_VARIABLE __CMAKE_OBJCXX_COMPILER_OUTPUT)
|
||||
unset(__TestCompiler_testObjCXXCompilerSource)
|
||||
# Move result from cache to normal variable.
|
||||
set(CMAKE_OBJCXX_COMPILER_WORKS ${CMAKE_OBJCXX_COMPILER_WORKS})
|
||||
unset(CMAKE_OBJCXX_COMPILER_WORKS CACHE)
|
||||
__TestCompiler_restoreTryCompileTargetType()
|
||||
if(NOT CMAKE_OBJCXX_COMPILER_WORKS)
|
||||
PrintTestCompilerResult(CHECK_FAIL "broken")
|
||||
|
||||
@@ -30,10 +30,8 @@ if(NOT CMAKE_Swift_COMPILER_WORKS)
|
||||
"}")
|
||||
try_compile(CMAKE_Swift_COMPILER_WORKS
|
||||
SOURCE_FROM_VAR main.swift __CMAKE_Swift_TEST_SOURCE
|
||||
NO_CACHE
|
||||
OUTPUT_VARIABLE __CMAKE_Swift_COMPILER_OUTPUT)
|
||||
# Move result from cache to normal variable.
|
||||
set(CMAKE_Swift_COMPILER_WORKS ${CMAKE_Swift_COMPILER_WORKS})
|
||||
unset(CMAKE_Swift_COMPILER_WORKS CACHE)
|
||||
set(Swift_TEST_WAS_RUN 1)
|
||||
endif()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user