TestForANSIForScope.cmake 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #.rst:
  2. # TestForANSIForScope
  3. # -------------------
  4. #
  5. # Check for ANSI for scope support
  6. #
  7. # Check if the compiler restricts the scope of variables declared in a
  8. # for-init-statement to the loop body.
  9. #
  10. # ::
  11. #
  12. # CMAKE_NO_ANSI_FOR_SCOPE - holds result
  13. #=============================================================================
  14. # Copyright 2002-2009 Kitware, Inc.
  15. #
  16. # Distributed under the OSI-approved BSD License (the "License");
  17. # see accompanying file Copyright.txt for details.
  18. #
  19. # This software is distributed WITHOUT ANY WARRANTY; without even the
  20. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  21. # See the License for more information.
  22. #=============================================================================
  23. # (To distribute this file outside of CMake, substitute the full
  24. # License text for the above reference.)
  25. if(NOT DEFINED CMAKE_ANSI_FOR_SCOPE)
  26. message(STATUS "Check for ANSI scope")
  27. try_compile(CMAKE_ANSI_FOR_SCOPE ${CMAKE_BINARY_DIR}
  28. ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx
  29. OUTPUT_VARIABLE OUTPUT)
  30. if (CMAKE_ANSI_FOR_SCOPE)
  31. message(STATUS "Check for ANSI scope - found")
  32. set (CMAKE_NO_ANSI_FOR_SCOPE 0 CACHE INTERNAL
  33. "Does the compiler support ansi for scope.")
  34. file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
  35. "Determining if the CXX compiler understands ansi for scopes passed with "
  36. "the following output:\n${OUTPUT}\n\n")
  37. else ()
  38. message(STATUS "Check for ANSI scope - not found")
  39. set (CMAKE_NO_ANSI_FOR_SCOPE 1 CACHE INTERNAL
  40. "Does the compiler support ansi for scope.")
  41. file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
  42. "Determining if the CXX compiler understands ansi for scopes failed with "
  43. "the following output:\n${OUTPUT}\n\n")
  44. endif ()
  45. endif()