1
0

CMakeTestCXXCompiler.cmake 1.4 KB

12345678910111213141516171819202122232425262728
  1. # This file is used by EnableLanguage in cmGlobalGenerator to
  2. # determine that that selected C++ compiler can actually compile
  3. # and link the most basic of programs. If not, a fatal error
  4. # is set and cmake stops processing commands and will not generate
  5. # any makefiles or projects.
  6. IF(NOT CMAKE_CXX_COMPILER_WORKS)
  7. MESSAGE(STATUS "Check for working CXX compiler: ${CMAKE_CXX_COMPILER}")
  8. FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp/testCXXCompiler.cxx "int main(){return 0;}\n")
  9. TRY_COMPILE(CMAKE_CXX_COMPILER_WORKS ${CMAKE_BINARY_DIR}
  10. ${CMAKE_BINARY_DIR}/CMakeTmp/testCXXCompiler.cxx
  11. OUTPUT_VARIABLE OUTPUT)
  12. ENDIF(NOT CMAKE_CXX_COMPILER_WORKS)
  13. IF(NOT CMAKE_CXX_COMPILER_WORKS)
  14. MESSAGE(STATUS "Check for working CXX compiler: ${CMAKE_CXX_COMPILER} -- broken")
  15. FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
  16. "Determining if the CXX compiler works failed with "
  17. "the following output:\n${OUTPUT}\n\n")
  18. MESSAGE(FATAL_ERROR "The C++ compiler \"${CMAKE_CXX_COMPILER}\" "
  19. "is not able to compile a simple test program.\nIt fails "
  20. "with the following output:\n ${OUTPUT}\n\n"
  21. "CMake will not be able to correctly generate this project.")
  22. ELSE(NOT CMAKE_CXX_COMPILER_WORKS)
  23. MESSAGE(STATUS "Check for working CXX compiler: ${CMAKE_CXX_COMPILER} -- works")
  24. FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log
  25. "Determining if the CXX compiler works passed with "
  26. "the following output:\n${OUTPUT}\n\n")
  27. ENDIF(NOT CMAKE_CXX_COMPILER_WORKS)