| 1 |
# - Check if the system has the specified type |
| 2 |
# CHECK_TYPE_EXISTS (TYPE HEADER VARIABLE) |
| 3 |
# |
| 4 |
# TYPE - the name of the type or struct or class you are interested in |
| 5 |
# HEADER - the header(s) where the prototype should be declared |
| 6 |
# VARIABLE - variable to store the result |
| 7 |
# |
| 8 |
# The following variables may be set before calling this macro to |
| 9 |
# modify the way the check is run: |
| 10 |
# |
| 11 |
# CMAKE_REQUIRED_FLAGS = string of compile command line flags |
| 12 |
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) |
| 13 |
# CMAKE_REQUIRED_INCLUDES = list of include directories |
| 14 |
# Copyright (c) 2009, Michihiro NAKAJIMA |
| 15 |
# Copyright (c) 2006, Alexander Neundorf, <[email protected]> |
| 16 |
# |
| 17 |
# Redistribution and use is allowed according to the terms of the BSD license. |
| 18 |
# For details see the accompanying COPYING-CMAKE-SCRIPTS file. |
| 19 |
|
| 20 |
|
| 21 |
INCLUDE(CheckCSourceCompiles) |
| 22 |
|
| 23 |
MACRO (CHECK_TYPE_EXISTS _TYPE _HEADER _RESULT) |
| 24 |
SET(_INCLUDE_FILES) |
| 25 |
FOREACH (it ${_HEADER}) |
| 26 |
SET(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n") |
| 27 |
ENDFOREACH (it) |
| 28 |
|
| 29 |
SET(_CHECK_TYPE_EXISTS_SOURCE_CODE " |
| 30 |
${_INCLUDE_FILES} |
| 31 |
int main() |
| 32 |
{ |
| 33 |
static ${_TYPE} tmp; |
| 34 |
if (sizeof(tmp)) |
| 35 |
return 0; |
| 36 |
return 0; |
| 37 |
} |
| 38 |
") |
| 39 |
CHECK_C_SOURCE_COMPILES("${_CHECK_TYPE_EXISTS_SOURCE_CODE}" ${_RESULT}) |
| 40 |
|
| 41 |
ENDMACRO (CHECK_TYPE_EXISTS) |
| 42 |
|