Debian Codegraph @

cmake/CheckPrototypeExists.cmake

raw
1 # - Check if the prototype for a function exists.
2 # CHECK_PROTOTYPE_EXISTS (FUNCTION HEADER VARIABLE)
3 #
4 # FUNCTION - the name of the function you are looking for
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
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_PROTOTYPE_EXISTS _SYMBOL _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_PROTO_EXISTS_SOURCE_CODE "
30 ${_INCLUDE_FILES}
31 int main()
32 {
33 #ifndef ${_SYMBOL}
34 int i = sizeof(&${_SYMBOL});
35 #endif
36 return 0;
37 }
38 ")
39
40 CHECK_C_SOURCE_COMPILES("${_CHECK_PROTO_EXISTS_SOURCE_CODE}" ${_RESULT})
41 ENDMACRO (CHECK_PROTOTYPE_EXISTS _SYMBOL _HEADER _RESULT)