[CMake] FreeBSD compile thinks its __APPLE_ in #ifdefs

E. Wing ewmailing at gmail.com
Thu Mar 22 16:36:11 EST 2007


Very weird. I've never had this problem myself when running on
FreeBSD. I agree with Philip and make sure something isn't defining it
somewhere in the code. Also make sure the person didn't generate the
CMake stuff in Apple first, and then reboot or used a shared disk in
FreeBSD and tried reusing the generated CMake stuff and Makefiles.

One other thing caught my attention. Why are you including <malloc.h>
if Apple? In general, you shouldn't have to do this unless you're
doing some really weird stuff. (Also, Darwin is a BSD sibling so in
many respects, the common code should be very close to FreeBSD.)

-Eric


> Tim Sutton wrote:
> > The code in question looks like this:
> >
> > 4 #ifdef __APPLE__
> > 5 #include <malloc.h>
> > 6 #endif
> >
> > So cmake has decided its an APPLE machine and is incorrectly entering
> > this ifdef. Can any one point me to some notes on making things behave
> > correctly on FreeBSD?
>
> I'd double check and make sure that __APPLE__ isn't getting accidentally
>   defined somehow by something you're #including.
>
>
> Alternatively, make a small Hello World project for CMake and verify
> that it's actually defining __APPLE__ when you generate on FreeBSD.
>
> CMakeLists.txt:
> ADD_EXECUTABLE(hello hello.cc)
>
> hello.cc:
>
> #include <iostream>
> int main()
> #ifdef __APPLE__
>     std::cout << "Apple is defined!" << std::endl;
> #endif
>     return 0;
> }
>


More information about the CMake mailing list