Blame cmake/CheckStructMember.cmake

Packit 0b5880
# - Check if the given struct or class has the specified member variable
Packit 0b5880
# CHECK_STRUCT_MEMBER (STRUCT MEMBER HEADER VARIABLE)
Packit 0b5880
#
Packit 0b5880
#  STRUCT - the name of the struct or class you are interested in
Packit 0b5880
#  MEMBER - the member which existence you want to check
Packit 0b5880
#  HEADER - the header(s) where the prototype should be declared
Packit 0b5880
#  VARIABLE - variable to store the result
Packit 0b5880
#
Packit 0b5880
# The following variables may be set before calling this macro to
Packit 0b5880
# modify the way the check is run:
Packit 0b5880
#
Packit 0b5880
#  CMAKE_REQUIRED_FLAGS = string of compile command line flags
Packit 0b5880
#  CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
Packit 0b5880
#  CMAKE_REQUIRED_INCLUDES = list of include directories
Packit 0b5880
Packit 0b5880
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
Packit 0b5880
#
Packit 0b5880
# Redistribution and use is allowed according to the terms of the BSD license.
Packit 0b5880
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
Packit 0b5880
Packit 0b5880
Packit 0b5880
INCLUDE(CheckCSourceCompiles)
Packit 0b5880
Packit 0b5880
MACRO (CHECK_STRUCT_MEMBER _STRUCT _MEMBER _HEADER _RESULT)
Packit 0b5880
   SET(_INCLUDE_FILES)
Packit 0b5880
   FOREACH (it ${_HEADER})
Packit 0b5880
      SET(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n")
Packit 0b5880
   ENDFOREACH (it)
Packit 0b5880
Packit 0b5880
   SET(_CHECK_STRUCT_MEMBER_SOURCE_CODE "
Packit 0b5880
${_INCLUDE_FILES}
Packit 0b5880
int main()
Packit 0b5880
{
Packit 0b5880
   static ${_STRUCT} tmp;
Packit 0b5880
   if (sizeof(tmp.${_MEMBER}))
Packit 0b5880
      return 0;
Packit 0b5880
  return 0;
Packit 0b5880
}
Packit 0b5880
")
Packit 0b5880
   CHECK_C_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT})
Packit 0b5880
Packit 0b5880
ENDMACRO (CHECK_STRUCT_MEMBER)
Packit 0b5880