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}")
16 TRY_COMPILE(${VARIABLE}
18 ${CMAKE_BINARY_DIR}/CMakeTmp/CheckIncludeFile.c
20 -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS}
21 OUTPUT_VARIABLE OUTPUT)
23 MESSAGE(STATUS "Looking for ${INCLUDE} - found")
24 SET(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}")
25 FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log
26 "Determining if the include file ${INCLUDE} "
27 "exists passed with the following output:\n"
30 MESSAGE(STATUS "Looking for ${INCLUDE} - not found.")
31 SET(${VARIABLE} "" CACHE INTERNAL "Have include ${INCLUDE}")
32 FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
33 "Determining if the include file ${INCLUDE} "
34 "exists failed with the following output:\n"
37 ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$")
38 ENDMACRO(CHECK_INCLUDE_FILE)