~ubuntu-branches/ubuntu/jaunty/cmake/jaunty-security

« back to all changes in this revision

Viewing changes to Modules/CheckIncludeFileCXX.cmake

  • Committer: Bazaar Package Importer
  • Author(s): A. Maitland Bottoms
  • Date: 2005-03-02 09:22:44 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050302092244-y6o9j8wr27vqcqvx
Tags: 2.0.5-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
# OPTIONAL - a third argument can be extra flags which are passed to the compiler
 
8
#
 
9
 
 
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)
 
20
 
 
21
    TRY_COMPILE(${VARIABLE}
 
22
      ${CMAKE_BINARY_DIR}
 
23
      ${CMAKE_BINARY_DIR}/CMakeTmp/CheckIncludeFile.cxx
 
24
      OUTPUT_VARIABLE OUTPUT)
 
25
 
 
26
    IF(${ARGC} EQUAL 3)
 
27
      SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_SAVE})
 
28
    ENDIF(${ARGC} EQUAL 3)
 
29
 
 
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)