ENH: typo
[cmake.git] / Modules / CheckIncludeFileCXX.cmake
blob548515b9fb872b597cfa1d7d6fcc1013b374c0fd
1 # - Check if the include file exists.
2 #  CHECK_INCLUDE_FILE_CXX(INCLUDE VARIABLE)
4 #  INCLUDE  - name of include file
5 #  VARIABLE - variable to return result
6 #  
7 # An optional third argument is the CFlags to add to the compile line 
8 # or you can use CMAKE_REQUIRED_FLAGS.
10 # The following variables may be set before calling this macro to
11 # modify the way the check is run:
13 #  CMAKE_REQUIRED_FLAGS = string of compile command line flags
14 #  CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
15 #  CMAKE_REQUIRED_INCLUDES = list of include directories
17 MACRO(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE)
18   IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
19     IF(CMAKE_REQUIRED_INCLUDES)
20       SET(CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
21     ELSE(CMAKE_REQUIRED_INCLUDES)
22       SET(CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS)
23     ENDIF(CMAKE_REQUIRED_INCLUDES)
24     SET(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS})
25     SET(CHECK_INCLUDE_FILE_VAR ${INCLUDE})
26     CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in
27       ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx IMMEDIATE)
28     MESSAGE(STATUS "Looking for C++ include ${INCLUDE}")
29     IF(${ARGC} EQUAL 3)
30       SET(CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS})
31       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGV2}")
32     ENDIF(${ARGC} EQUAL 3)
34     TRY_COMPILE(${VARIABLE}
35       ${CMAKE_BINARY_DIR}
36       ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx
37       COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
38       CMAKE_FLAGS 
39       -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS}
40       "${CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS}"
41       OUTPUT_VARIABLE OUTPUT) 
43     IF(${ARGC} EQUAL 3)
44       SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_SAVE})
45     ENDIF(${ARGC} EQUAL 3)
47     IF(${VARIABLE})
48       MESSAGE(STATUS "Looking for C++ include ${INCLUDE} - found")
49       SET(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}")
50       FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log 
51         "Determining if the include file ${INCLUDE} "
52         "exists passed with the following output:\n"
53         "${OUTPUT}\n\n")
54     ELSE(${VARIABLE})
55       MESSAGE(STATUS "Looking for C++ include ${INCLUDE} - not found")
56       SET(${VARIABLE} "" CACHE INTERNAL "Have include ${INCLUDE}")
57       FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 
58         "Determining if the include file ${INCLUDE} "
59         "exists failed with the following output:\n"
60         "${OUTPUT}\n\n")
61     ENDIF(${VARIABLE})
62   ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$")
63 ENDMACRO(CHECK_INCLUDE_FILE_CXX)