STYLE: Nightly Version update
[cmake.git] / Modules / CheckIncludeFileCXX.cmake
blob5f5811ae4adc310c13065b63fb2a607f825656c0
2 # Check if the include file exists.
4 # CHECK_INCLUDE_FILE - macro which checks the include file exists.
5 # INCLUDE - name of include file
6 # VARIABLE - variable to return result
7 # OPTIONAL - a third argument can be extra flags which are passed to the compiler
10 MACRO(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE)
11   IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
12     MESSAGE(STATUS "Checking for CXX include file ${INCLUDE}")
13     SET(CHECK_INCLUDE_FILE_VAR ${INCLUDE})
14     CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in
15       ${CMAKE_BINARY_DIR}/CMakeTmp/CheckIncludeFile.cxx IMMEDIATE)
16     IF(${ARGC} EQUAL 3)
17       SET(CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS})
18       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGV2}")
19     ENDIF(${ARGC} EQUAL 3)
21     TRY_COMPILE(${VARIABLE}
22       ${CMAKE_BINARY_DIR}
23       ${CMAKE_BINARY_DIR}/CMakeTmp/CheckIncludeFile.cxx
24       OUTPUT_VARIABLE OUTPUT)
26     IF(${ARGC} EQUAL 3)
27       SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_SAVE})
28     ENDIF(${ARGC} EQUAL 3)
30     IF(${VARIABLE})
31       MESSAGE(STATUS "Checking for CXX include file ${INCLUDE} -- found")
32       SET(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}")
33       FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log 
34         "Determining if the include file ${INCLUDE} "
35         "exists passed with the following output:\n"
36         "${OUTPUT}\n\n")
37     ELSE(${VARIABLE})
38       MESSAGE(STATUS "Checking for CXX include file ${INCLUDE} -- not found")
39       SET(${VARIABLE} "" CACHE INTERNAL "Have include ${INCLUDE}")
40       FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log 
41         "Determining if the include file ${INCLUDE} "
42         "exists failed with the following output:\n"
43         "${OUTPUT}\n\n")
44     ENDIF(${VARIABLE})
45   ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$")
46 ENDMACRO(CHECK_INCLUDE_FILE_CXX)