[CMake] typedef vs. macro

George Neill georgen at neillnet.com
Tue Feb 3 02:33:37 EST 2009


Hi All,

I have ran in to some third party header code which looks like this
(shortened for this example)

#ifdef OPTION
  #define SOMETYPE int
#else
  typedef int SOMETYPE;
#endif

Here is what I have come up with,

CHECK_SYMBOL_EXISTS(SOMETYPE "type.h" HAVE_SOMETYPE_DEFINE)
CHECK_TYPE_SIZE(SOMETYPE SOMETYPE_TYPEDEF)

IF(HAVE_SOMETYPE_DEFINE OR HAVE_SOMETYPE_TYPEDEF)
    SET(HAVE_SOMETYPE 1)
ENDIF(HAVE_SOMETYPE_DEFINE OR HAVE_SOMETYPE_TYPEDEF)

Is there a better way to deal with this?

TIA,
George.


More information about the CMake mailing list