[CMake] typedef vs. macro

George Neill georgen at neillnet.com
Tue Feb 3 02:40:05 EST 2009


On Tue, Feb 3, 2009 at 1:33 AM, George Neill <georgen at neillnet.com> wrote:
> 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?

Of course, as soon as I hit send .. I realized I can probably just do
the CHECK_TYPE_SIZE check and drop the CHECK_SYMBOL_EXISTS check;
since I know it's a type.

Later,
George.


More information about the CMake mailing list