Code

Indent support for XSLT extensions output.
[inkscape.git] / CMakeScripts / CheckStructMember.cmake
1 # - Check if the given struct or class has the specified member variable
2 # CHECK_STRUCT_MEMBER (STRUCT MEMBER HEADER VARIABLE)
3 #
4 #  STRUCT - the name of the struct or class you are interested in
5 #  MEMBER - the member which existence you want to check
6 #  HEADER - the header(s) where the prototype should be declared
7 #  VARIABLE - variable to store the result
8 #
9 # The following variables may be set before calling this macro to
10 # modify the way the check is run:
11 #
12 #  CMAKE_REQUIRED_FLAGS = string of compile command line flags
13 #  CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
14 #  CMAKE_REQUIRED_INCLUDES = list of include directories
16 # Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
17 #
18 # Redistribution and use is allowed according to the terms of the BSD license.
19 # Redistribution and use in source and binary forms, with or without
20 # modification, are permitted provided that the following conditions
21 # are met:
22 #
23 # 1. Redistributions of source code must retain the copyright
24 #    notice, this list of conditions and the following disclaimer.
25 # 2. Redistributions in binary form must reproduce the copyright
26 #    notice, this list of conditions and the following disclaimer in the
27 #    documentation and/or other materials provided with the distribution.
28 # 3. The name of the author may not be used to endorse or promote products 
29 #    derived from this software without specific prior written permission.
30 #
31 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
32 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
33 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
34 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
35 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
36 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
40 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 INCLUDE(CheckCXXSourceCompiles)
45 MACRO (CHECK_STRUCT_MEMBER _STRUCT _MEMBER _HEADER _RESULT)
46    SET(_INCLUDE_FILES)
47    FOREACH (it ${_HEADER})
48       SET(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n")
49    ENDFOREACH (it)
51    SET(_CHECK_STRUCT_MEMBER_SOURCE_CODE "
52 ${_INCLUDE_FILES}
53 int main()
54 {
55    ${_STRUCT}* tmp;
56    tmp->${_MEMBER};
57   return 0;
58 }
59 ")
60    CHECK_CXX_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT})
62 ENDMACRO (CHECK_STRUCT_MEMBER)