[CMake] OS X architecture changes interfere with CheckTypeSize()?

Clinton Stimpson clinton at elemtech.com
Wed Aug 11 15:26:51 EDT 2010


On Wednesday, August 11, 2010 12:52:32 pm Erik Lindahl wrote:
> Hi Sean,
> 
> On Aug 11, 2010, at 8:08 PM, Sean McBride wrote:
> > On Wed, 11 Aug 2010 18:08:35 +0200, Erik Lindahl said:
> >> All the CheckTypeSize() tests then seem to run directly when e.g. ccmake
> >> is invoked, and they thus set all SIZEOF_XXX defines to the 64-bit
> >> values (e.g. 8 for "long int").
> > 
> > Why do you need to know the size of 'long'?  Its size is not guaranteed
> > by the language spec.  If you're writing portable code, you should not
> > assume any more than the language guarantees.
> > 
> > If you need an integer of a specific size, use types like int32_t or
> > int64_t.  These are part of C99 and C++0x.  If they don't exist on some
> > platform you need to support, they are easy to typedef.
> 
> That's exactly the reason we test it at configure time - e.g. to find a
> data type to use for 4-byte integers, and whether there is any 8-byte type
> present for ~50 different OS/compiler combinations.
> 
> However, let's leave the "why" aside for now - I already worked around the
> specific issue.
> 
> Still, there are tons of other things at configure time that might depend
> on your architecture, and CMake has plenty of routines for such tests, so
> hopefully we can agree that if CMake allows the user to
> 
> (1) change the OS X architecture and
> (2) check for things at configuration time,
> 
> it's also a pretty reasonable goal to try and get the correct result from
> those test - isn't it?  :-)
> 
> Thus, back to my question: Wouldn't it make sense in this case to force the
> user to set the OS X architecture(s) at the same time as the compiler,
> and/or invalidate the cache when it changes? (just as CMake already does
> for the compilers)?
> 

On the other hand, there are many of us that use CMAKE_OSX_ARCHITECTURES to 
compile universal binaries with multiple architectures.  In that case the 
check for things at configuration time isn't reliable.  And if that is 
accounted for, one can change the OS X architecture and not have to redo 
configuration checks.  So, I don't see how cmake could know whether to 
invalidate the cache.

What if you hide that variable and force your users to pick a single 
architecture to begin with, perhaps using a cmake variable and/or environment 
variable of your own that they can set.
For the user, that could behave like specifying 32 or 64 bit on Linux/gcc.

Clint


More information about the CMake mailing list