1############################################################################# 2# Copyright (c) 2016 Balabit 3# 4# This library is free software; you can redistribute it and/or 5# modify it under the terms of the GNU Lesser General Public 6# License as published by the Free Software Foundation; either 7# version 2.1 of the License, or (at your option) any later version. 8# 9# This library is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12# Lesser General Public License for more details. 13# 14# You should have received a copy of the GNU Lesser General Public 15# License along with this library; if not, write to the Free Software 16# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17# 18# As an additional exemption you are allowed to compile & link against the 19# OpenSSL libraries as published by the OpenSSL project. See the file 20# COPYING for details. 21# 22############################################################################# 23 24# origin: http://www.opensource.apple.com/source/libarchive/libarchive-32.10.1/libarchive/build/cmake/CheckStructMember.cmake?txt 25# - Check if the given struct or class has the specified member variable 26# CHECK_STRUCT_MEMBER (STRUCT MEMBER HEADER VARIABLE) 27# 28# STRUCT - the name of the struct or class you are interested in 29# MEMBER - the member which existence you want to check 30# HEADER - the header(s) where the prototype should be declared 31# VARIABLE - variable to store the result 32# 33# The following variables may be set before calling this macro to 34# modify the way the check is run: 35# 36# CMAKE_REQUIRED_FLAGS = string of compile command line flags 37# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) 38# CMAKE_REQUIRED_INCLUDES = list of include directories 39 40# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org> 41# 42# Redistribution and use is allowed according to the terms of the BSD license. 43# For details see the accompanying COPYING-CMAKE-SCRIPTS file. 44 45 46INCLUDE(CheckCSourceCompiles) 47 48MACRO (CHECK_STRUCT_MEMBER _STRUCT _MEMBER _HEADER _RESULT) 49 SET(_INCLUDE_FILES) 50 FOREACH (it ${_HEADER}) 51 SET(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n") 52 ENDFOREACH (it) 53 54 SET(_CHECK_STRUCT_MEMBER_SOURCE_CODE " 55${_INCLUDE_FILES} 56int main() 57{ 58 static ${_STRUCT} tmp; 59 if (sizeof(tmp.${_MEMBER})) 60 return 0; 61 return 0; 62} 63") 64 CHECK_C_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT}) 65 66ENDMACRO (CHECK_STRUCT_MEMBER) 67 68