TestForANSIForScope.cmake 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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(STATUS "Check for ANSI scope")
  14. try_compile(CMAKE_ANSI_FOR_SCOPE ${CMAKE_BINARY_DIR}
  15. ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx
  16. OUTPUT_VARIABLE OUTPUT)
  17. if (CMAKE_ANSI_FOR_SCOPE)
  18. message(STATUS "Check for ANSI scope - found")
  19. set (CMAKE_NO_ANSI_FOR_SCOPE 0 CACHE INTERNAL
  20. "Does the compiler support ansi for scope.")
  21. file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
  22. "Determining if the CXX compiler understands ansi for scopes passed with "
  23. "the following output:\n${OUTPUT}\n\n")
  24. else ()
  25. message(STATUS "Check for ANSI scope - not found")
  26. set (CMAKE_NO_ANSI_FOR_SCOPE 1 CACHE INTERNAL
  27. "Does the compiler support ansi for scope.")
  28. file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
  29. "Determining if the CXX compiler understands ansi for scopes failed with "
  30. "the following output:\n${OUTPUT}\n\n")
  31. endif ()
  32. endif()