CMakeTestCCompiler.cmake 1.2 KB

12345678910111213141516171819202122
  1. # This file is used by EnableLanguage in cmGlobalGenerator to
  2. # determine that that selected C compiler can actually compile
  3. # and like the most basic of programs. If not, a fatel error
  4. # is set and cmake stops processing commands and will not generate
  5. # any makefiles or projects.
  6. IF(NOT CMAKE_C_COMPILER_WORKS)
  7. MESSAGE(STATUS "Check for working C compiler: ${CMAKE_C_COMPILER}")
  8. WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeTmp/testCCompiler.c "int main(){return 0;}")
  9. TRY_COMPILE(CMAKE_C_COMPILER_WORKS ${CMAKE_BINARY_DIR}
  10. ${CMAKE_BINARY_DIR}/CMakeTmp/testCCompiler.c
  11. OUTPUT_VARIABLE OUTPUT)
  12. ENDIF(NOT CMAKE_C_COMPILER_WORKS)
  13. IF(NOT CMAKE_C_COMPILER_WORKS)
  14. MESSAGE(STATUS "Check for working C compiler: ${CMAKE_C_COMPILER} -- broken")
  15. MESSAGE(FATAL_ERROR "The C compiler \"${CMAKE_C_COMPILER}\" "
  16. "is not able to compile a simple tests program.\nIt fails "
  17. "with the following output:\n ${OUTPUT}\n\n"
  18. "CMake will not be able to correctly generate this project.")
  19. ELSE(NOT CMAKE_C_COMPILER_WORKS)
  20. MESSAGE(STATUS "Check for working C compiler: ${CMAKE_C_COMPILER} -- works")
  21. ENDIF(NOT CMAKE_C_COMPILER_WORKS)