TestForANSIForScope.cmake 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. TestForANSIForScope
  5. -------------------
  6. Check for ANSI for scope support
  7. Check if the compiler restricts the scope of variables declared in a
  8. for-init-statement to the loop body.
  9. ::
  10. CMAKE_NO_ANSI_FOR_SCOPE - holds result
  11. #]=======================================================================]
  12. if(NOT DEFINED CMAKE_ANSI_FOR_SCOPE)
  13. message(CHECK_START "Check for ANSI scope")
  14. try_compile(CMAKE_ANSI_FOR_SCOPE
  15. SOURCES ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx
  16. )
  17. if (CMAKE_ANSI_FOR_SCOPE)
  18. message(CHECK_PASS "found")
  19. set (CMAKE_NO_ANSI_FOR_SCOPE 0 CACHE INTERNAL
  20. "Does the compiler support ansi for scope.")
  21. else ()
  22. message(CHECK_FAIL "not found")
  23. set (CMAKE_NO_ANSI_FOR_SCOPE 1 CACHE INTERNAL
  24. "Does the compiler support ansi for scope.")
  25. endif ()
  26. endif()