Imported Upstream version 3.25.0
[platform/upstream/cmake.git] / Modules / TestForANSIForScope.cmake
1 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
3
4 #[=======================================================================[.rst:
5 TestForANSIForScope
6 -------------------
7
8 Check for ANSI for scope support
9
10 Check if the compiler restricts the scope of variables declared in a
11 for-init-statement to the loop body.
12
13 ::
14
15   CMAKE_NO_ANSI_FOR_SCOPE - holds result
16 #]=======================================================================]
17
18 if(NOT DEFINED CMAKE_ANSI_FOR_SCOPE)
19   message(CHECK_START "Check for ANSI scope")
20   try_compile(CMAKE_ANSI_FOR_SCOPE
21     SOURCES ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx
22     OUTPUT_VARIABLE OUTPUT)
23   if (CMAKE_ANSI_FOR_SCOPE)
24     message(CHECK_PASS "found")
25     set (CMAKE_NO_ANSI_FOR_SCOPE 0 CACHE INTERNAL
26       "Does the compiler support ansi for scope.")
27     file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
28       "Determining if the CXX compiler understands ansi for scopes passed with "
29       "the following output:\n${OUTPUT}\n\n")
30   else ()
31     message(CHECK_FAIL "not found")
32     set (CMAKE_NO_ANSI_FOR_SCOPE 1 CACHE INTERNAL
33       "Does the compiler support ansi for scope.")
34     file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
35       "Determining if the CXX compiler understands ansi for scopes failed with "
36       "the following output:\n${OUTPUT}\n\n")
37   endif ()
38 endif()
39
40
41
42
43