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
15INCLUDE(CheckCXXSourceCompiles)
16
17MACRO (CHECK_PROTOTYPE_EXISTS _SYMBOL _HEADER _RESULT)
18   SET(_INCLUDE_FILES)
19   FOREACH (it ${_HEADER})
20      SET(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n")
21   ENDFOREACH (it)
22
23   SET(_CHECK_PROTO_EXISTS_SOURCE_CODE "
24${_INCLUDE_FILES}
25int main()
26{
27#ifndef ${_SYMBOL}
28   int i = sizeof(&${_SYMBOL});
29#endif
30  return 0;
31}
32")
33   CHECK_CXX_SOURCE_COMPILES("${_CHECK_PROTO_EXISTS_SOURCE_CODE}" ${_RESULT})
34ENDMACRO (CHECK_PROTOTYPE_EXISTS _SYMBOL _HEADER _RESULT)
35
36