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

« back to all changes in this revision

Viewing changes to Modules/CheckTypeSize.cmake

  • Committer: Bazaar Package Importer
  • Author(s): A. Maitland Bottoms
  • Date: 2006-06-18 16:34:11 UTC
  • mfrom: (1.4.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060618163411-pi234s3v6jwlcmof
Tags: 2.4.2-1
* New upstream release (Closes: #338324)
* Put cmake .vim files into /usr/share/vim/addons/plugin/
  where they can be used. (Closes: #366663)
* Install cmake-mode.el so it can be used. (Closes: #366664)
* Ensure cmake FindKDE locates KDE libraries on Debian
  based distributions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
 
1
# - Check sizeof a type
 
2
#  CHECK_TYPE_SIZE(TYPE VARIABLE)
2
3
# Check if the type exists and determine size of type.  if the type
3
4
# exists, the size will be stored to the variable.
4
 
#
5
 
# CHECK_TYPE_SIZE - macro which checks the size of type
6
 
# VARIABLE - variable to store size if the type exists.
7
 
# HAVE_${VARIABLE} - does the variable exists or not
8
 
#
 
5
#  VARIABLE - variable to store size if the type exists.
 
6
#  HAVE_${VARIABLE} - does the variable exists or not
 
7
# The following variables may be set before calling this macro to
 
8
# modify the way the check is run:
 
9
#
 
10
#  CMAKE_REQUIRED_FLAGS = string of compile command line flags
 
11
#  CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
 
12
#  CMAKE_REQUIRED_INCLUDES = list of include directories
 
13
#  CMAKE_REQUIRED_LIBRARIES = list of libraries to link
9
14
 
10
15
MACRO(CHECK_TYPE_SIZE TYPE VARIABLE)
11
16
  SET(CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS 1)
12
17
  IF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$")
 
18
    SET(CHECK_TYPE_SIZE_TYPE "${TYPE}")
13
19
    SET(MACRO_CHECK_TYPE_SIZE_FLAGS 
14
 
      "-DCHECK_TYPE_SIZE_TYPE=\"${TYPE}\" ${CMAKE_REQUIRED_FLAGS}")
 
20
      "${CMAKE_REQUIRED_FLAGS}")
15
21
    FOREACH(def HAVE_SYS_TYPES_H HAVE_STDINT_H HAVE_STDDEF_H)
16
22
      IF("${def}")
17
23
        SET(MACRO_CHECK_TYPE_SIZE_FLAGS 
18
24
          "${MACRO_CHECK_TYPE_SIZE_FLAGS} -D${def}")
19
25
      ENDIF("${def}")
20
26
    ENDFOREACH(def)
 
27
    SET(CHECK_TYPE_SIZE_PREINCLUDE)
21
28
    SET(CHECK_TYPE_SIZE_PREMAIN)
22
29
    FOREACH(def ${CMAKE_EXTRA_INCLUDE_FILES})
23
30
      SET(CHECK_TYPE_SIZE_PREMAIN "${CHECK_TYPE_SIZE_PREMAIN}#include \"${def}\"\n")
24
31
    ENDFOREACH(def)
25
32
    CONFIGURE_FILE("${CMAKE_ROOT}/Modules/CheckTypeSize.c.in"
26
 
      "${CMAKE_BINARY_DIR}/CMakeTmp/CheckTypeSize.c" IMMEDIATE @ONLY)
27
 
    FILE(READ "${CMAKE_BINARY_DIR}/CMakeTmp/CheckTypeSize.c"
 
33
      "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckTypeSize.c" IMMEDIATE @ONLY)
 
34
    FILE(READ "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckTypeSize.c"
28
35
      CHECK_TYPE_SIZE_FILE_CONTENT)
29
36
    MESSAGE(STATUS "Check size of ${TYPE}")
30
37
    IF(CMAKE_REQUIRED_LIBRARIES)
31
38
      SET(CHECK_TYPE_SIZE_ADD_LIBRARIES 
32
39
        "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
 
40
    ELSE(CMAKE_REQUIRED_LIBRARIES)
 
41
      SET(CHECK_TYPE_SIZE_ADD_LIBRARIES)
33
42
    ENDIF(CMAKE_REQUIRED_LIBRARIES)
 
43
    IF(CMAKE_REQUIRED_INCLUDES)
 
44
      SET(CHECK_TYPE_SIZE_ADD_INCLUDES
 
45
        "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
 
46
    ELSE(CMAKE_REQUIRED_INCLUDES)
 
47
      SET(CHECK_TYPE_SIZE_ADD_INCLUDES)
 
48
    ENDIF(CMAKE_REQUIRED_INCLUDES)
34
49
    TRY_RUN(${VARIABLE} HAVE_${VARIABLE}
35
50
      ${CMAKE_BINARY_DIR}
36
 
      "${CMAKE_BINARY_DIR}/CMakeTmp/CheckTypeSize.c"
 
51
      "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckTypeSize.c"
 
52
      COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
37
53
      CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_TYPE_SIZE_FLAGS}
38
54
      "${CHECK_TYPE_SIZE_ADD_LIBRARIES}"
 
55
      "${CHECK_TYPE_SIZE_ADD_INCLUDES}"
39
56
      OUTPUT_VARIABLE OUTPUT)
40
57
    IF(HAVE_${VARIABLE})
41
58
      MESSAGE(STATUS "Check size of ${TYPE} - done")