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_C_COMPILER_WORKS)
7 MESSAGE(STATUS "Check for working C compiler: ${CMAKE_C_COMPILER}")
8 FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp/testCCompiler.c
10 "# error \"The CMAKE_C_COMPILER is set to a C++ compiler\"\n"
12 "int main(){return 0;}\n")
13 TRY_COMPILE(CMAKE_C_COMPILER_WORKS ${CMAKE_BINARY_DIR}
14 ${CMAKE_BINARY_DIR}/CMakeTmp/testCCompiler.c
15 OUTPUT_VARIABLE OUTPUT)
17 ENDIF(NOT CMAKE_C_COMPILER_WORKS)
19 IF(NOT CMAKE_C_COMPILER_WORKS)
20 MESSAGE(STATUS "Check for working C compiler: ${CMAKE_C_COMPILER} -- broken")
21 FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
22 "Determining if the C compiler works failed with "
23 "the following output:\n${OUTPUT}\n\n")
24 MESSAGE(FATAL_ERROR "The C compiler \"${CMAKE_C_COMPILER}\" "
25 "is not able to compile a simple test program.\nIt fails "
26 "with the following output:\n ${OUTPUT}\n\n"
27 "CMake will not be able to correctly generate this project.")
28 ELSE(NOT CMAKE_C_COMPILER_WORKS)
30 MESSAGE(STATUS "Check for working C compiler: ${CMAKE_C_COMPILER} -- works")
31 FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log
32 "Determining if the C compiler works passed with "
33 "the following output:\n${OUTPUT}\n\n")
35 SET(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "")
36 ENDIF(NOT CMAKE_C_COMPILER_WORKS)