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
9 MACRO(CHECK_INCLUDE_FILE INCLUDE VARIABLE)
10 IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
11 SET(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS})
12 SET(CHECK_INCLUDE_FILE_VAR ${INCLUDE})
13 CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CheckIncludeFile.c.in
14 ${CMAKE_BINARY_DIR}/CMakeTmp/CheckIncludeFile.c IMMEDIATE)
15 MESSAGE(STATUS "Looking for ${INCLUDE}")
17 SET(CMAKE_C_FLAGS_SAVE ${CMAKE_C_FLAGS})
18 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARGV2}")
19 ENDIF(${ARGC} EQUAL 3)
21 TRY_COMPILE(${VARIABLE}
23 ${CMAKE_BINARY_DIR}/CMakeTmp/CheckIncludeFile.c
25 -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS}
26 OUTPUT_VARIABLE OUTPUT)
29 SET(CMAKE_C_FLAGS ${CMAKE_C_FLAGS_SAVE})
30 ENDIF(${ARGC} EQUAL 3)
33 MESSAGE(STATUS "Looking for ${INCLUDE} - found")
34 SET(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}")
35 FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log
36 "Determining if the include file ${INCLUDE} "
37 "exists passed with the following output:\n"
40 MESSAGE(STATUS "Looking for ${INCLUDE} - not found.")
41 SET(${VARIABLE} "" CACHE INTERNAL "Have include ${INCLUDE}")
42 FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
43 "Determining if the include file ${INCLUDE} "
44 "exists failed with the following output:\n"
47 ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$")
48 ENDMACRO(CHECK_INCLUDE_FILE)