TestForANSIForScope.cmake 1.9 KB

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