TestForANSIForScope.cmake 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #
  7. # Check for ANSI for scope support
  8. #
  9. # Check if the compiler restricts the scope of variables declared in a
  10. # for-init-statement to the loop body.
  11. #
  12. # ::
  13. #
  14. # CMAKE_NO_ANSI_FOR_SCOPE - holds result
  15. if(NOT DEFINED CMAKE_ANSI_FOR_SCOPE)
  16. message(STATUS "Check for ANSI scope")
  17. try_compile(CMAKE_ANSI_FOR_SCOPE ${CMAKE_BINARY_DIR}
  18. ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx
  19. OUTPUT_VARIABLE OUTPUT)
  20. if (CMAKE_ANSI_FOR_SCOPE)
  21. message(STATUS "Check for ANSI scope - found")
  22. set (CMAKE_NO_ANSI_FOR_SCOPE 0 CACHE INTERNAL
  23. "Does the compiler support ansi for scope.")
  24. file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
  25. "Determining if the CXX compiler understands ansi for scopes passed with "
  26. "the following output:\n${OUTPUT}\n\n")
  27. else ()
  28. message(STATUS "Check for ANSI scope - not found")
  29. set (CMAKE_NO_ANSI_FOR_SCOPE 1 CACHE INTERNAL
  30. "Does the compiler support ansi for scope.")
  31. file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
  32. "Determining if the CXX compiler understands ansi for scopes failed with "
  33. "the following output:\n${OUTPUT}\n\n")
  34. endif ()
  35. endif()