OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / share / CMake / Modules / CheckIncludeFile.cmake
1 #
2 # Check if the include file exists.
3 #
4 # CHECK_INCLUDE_FILE - macro which checks the include file exists.
5 # INCLUDE - name of include file
6 # VARIABLE - variable to return result
7 #
8
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}
17       ${CMAKE_BINARY_DIR}
18       ${CMAKE_BINARY_DIR}/CMakeTmp/CheckIncludeFile.c
19       CMAKE_FLAGS 
20       -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS}
21       OUTPUT_VARIABLE OUTPUT)
22     IF(${VARIABLE})
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"
28         "${OUTPUT}\n\n")
29     ELSE(${VARIABLE})
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"
35         "${OUTPUT}\n\n")
36     ENDIF(${VARIABLE})
37   ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$")
38 ENDMACRO(CHECK_INCLUDE_FILE)