2 # This file is used by EnableLanguage in cmGlobalGenerator to
3 # determine that that selected C++ compiler can actually compile
4 # and link the most basic of programs. If not, a fatal error
5 # is set and cmake stops processing commands and will not generate
6 # any makefiles or projects.
7 IF(NOT CMAKE_CXX_COMPILER_WORKS)
8 MESSAGE(STATUS "Check for working CXX compiler: ${CMAKE_CXX_COMPILER}")
9 FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXCompiler.cxx
10 "#ifndef __cplusplus\n"
11 "# error \"The CMAKE_CXX_COMPILER is set to a C compiler\"\n"
13 "int main(){return 0;}\n")
14 TRY_COMPILE(CMAKE_CXX_COMPILER_WORKS ${CMAKE_BINARY_DIR}
15 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXCompiler.cxx
16 OUTPUT_VARIABLE OUTPUT)
17 SET(CXX_TEST_WAS_RUN 1)
18 ENDIF(NOT CMAKE_CXX_COMPILER_WORKS)
20 IF(NOT CMAKE_CXX_COMPILER_WORKS)
21 MESSAGE(STATUS "Check for working CXX compiler: ${CMAKE_CXX_COMPILER} -- broken")
22 FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
23 "Determining if the CXX compiler works failed with "
24 "the following output:\n${OUTPUT}\n\n")
25 MESSAGE(FATAL_ERROR "The C++ compiler \"${CMAKE_CXX_COMPILER}\" "
26 "is not able to compile a simple test program.\nIt fails "
27 "with the following output:\n ${OUTPUT}\n\n"
28 "CMake will not be able to correctly generate this project.")
29 ELSE(NOT CMAKE_CXX_COMPILER_WORKS)
31 MESSAGE(STATUS "Check for working CXX compiler: ${CMAKE_CXX_COMPILER} -- works")
32 FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
33 "Determining if the CXX compiler works passed with "
34 "the following output:\n${OUTPUT}\n\n")
35 ENDIF(CXX_TEST_WAS_RUN)
36 SET(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "")
38 IF(CMAKE_CXX_COMPILER_FORCED)
39 # The compiler was forced by the CMAKE_FORCE_CXX_COMPILER macro.
40 # Assume the user has configured all compiler information.
41 ELSE(CMAKE_CXX_COMPILER_FORCED)
42 # Try to identify the ABI and configure it into CMakeCXXCompiler.cmake
43 INCLUDE(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake)
44 CMAKE_DETERMINE_COMPILER_ABI(CXX ${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp)
46 ${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in
47 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCXXCompiler.cmake
48 @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0
50 ENDIF(CMAKE_CXX_COMPILER_FORCED)
51 ENDIF(NOT CMAKE_CXX_COMPILER_WORKS)