From 4003d9108c0254fbaafb03b33f011cd63983510f Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Sun, 30 Apr 2006 21:39:02 +0000 Subject: -two cmake modules to check whether a given struct or pointer has a specified member variable Alex svn path=/trunk/KDE/kdelibs/; revision=535981 --- modules/CheckStructMember.cmake | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 modules/CheckStructMember.cmake (limited to 'modules/CheckStructMember.cmake') diff --git a/modules/CheckStructMember.cmake b/modules/CheckStructMember.cmake new file mode 100644 index 00000000..fd5d3461 --- /dev/null +++ b/modules/CheckStructMember.cmake @@ -0,0 +1,36 @@ +# - Check if the given struct or class has the specified member variable +# CHECK_STRUCT_MEMBER (STRUCT MEMBER HEADER VARIABLE) +# +# STRUCT - the name of the struct or class you are interested in +# MEMBER - the member which existence you want to check +# HEADER - the header(s) where the prototype should be declared +# VARIABLE - variable to store the result +# +# The following variables may be set before calling this macro to +# modify the way the check is run: +# +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories + +INCLUDE(CheckCXXSourceCompiles) + +MACRO (CHECK_STRUCT_MEMBER _STRUCT _MEMBER _HEADER _RESULT) + SET(_INCLUDE_FILES) + FOREACH (it ${_HEADER}) + SET(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n") + ENDFOREACH (it) + + SET(_CHECK_STRUCT_MEMBER_SOURCE_CODE " +${_INCLUDE_FILES} +int main() +{ + ${_STRUCT}* tmp; + tmp->${_MEMBER}; + return 0; +} +") + CHECK_CXX_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT}) + +ENDMACRO (CHECK_STRUCT_MEMBER) + -- cgit v1.2.1