zibbr

Random 3d and p2p stuff that was originally the beginnings of an overly ambitious p2p virtual world thingy
git clone https://code.literati.org/zibbr.git
Log | Files | Refs

CheckType.cmake (1101B)


      1 # - Check if the given struct or class has the specified member variable
      2 # CHECK_TYPE (TYPE RESULT INCLUDES)
      3 #
      4 #  TYPE - The variable you want to test
      5 #  HEADER - Headers included in the test
      6 #  RESULT - True if found
      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 
     15 # Copyright (c) 2008, Andrew Fenn <andrewfenn@gmail.com>
     16 #
     17 # Redistribution and use is allowed according to the terms of the BSD license.
     18 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
     19 
     20 MACRO (CHECK_TYPE _TYPE _HEADER _RESULT)
     21    SET(_INCLUDE_FILES)
     22    FOREACH (it ${_HEADER})
     23       SET(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n")
     24    ENDFOREACH (it)
     25 
     26    SET(_CHECK_STRUCT_MEMBER_SOURCE_CODE "
     27 ${_INCLUDE_FILES}
     28 int main()
     29 {
     30    ${_TYPE}* tmp;
     31   return 0;
     32 }
     33 ")
     34    
     35 CHECK_CXX_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT})
     36 ENDMACRO (CHECK_TYPE)
     37