[CMake] CMake 2.8rc2 and "CHECK_TYPE_SIZE found different results" error

Brad King brad.king at kitware.com
Fri Oct 2 14:47:02 EDT 2009


Sean McBride wrote:
> Hi all,
> 
> I've just tried building VTK with 2.8rc1 and it gives an error:
> 
> -- Check size of long
> CMake Error at /Applications/CMake 2.8-0.app/Contents/share/cmake-2.8/
> Modules/CheckTypeSize.cmake:102 (MESSAGE):
>   CHECK_TYPE_SIZE found different results, consider setting
>   CMAKE_OSX_ARCHITECTURES or CMAKE_TRY_COMPILE_OSX_ARCHITECTURES to one or no
>   architecture !
> Call Stack (most recent call first):
>   CMake/CMakeBackwardCompatibilityC.cmake:14 (CHECK_TYPE_SIZE)
>   CMakeLists.txt:403 (INCLUDE)
> 
> I don't recall this happening in earlier versions.

Have you used the combination of 32-bit and 64-bit archs before?
What does 2.6.4 do?

> Indeed I have set CMAKE_OSX_ARCHITECTURES to "i386;x86_64" and this
> error does go away if I use only one arch.  It is also correct that
> 'long' has a different size between those 2 architectures. 
> Nevertheless, I want/need to build VTK in both architectures.
> 
> What is the correct fix here?  I guess it's VTK that needs to change?

The problem is that the project is querying the size of a type with
a try-compile assuming that there is only one target architecture.
Any decision made in the CMakeLists.txt file based on this result
may not work for both architectures.

In order to support universal binaries VTK needs to be taught about
them.  Endian-ness and type size need to be selected at preprocessing
time.  That doesn't mean try-compile can't be used at all for ABI
related queries, but if it is then it should be run once for each
architecture by setting CMAKE_TRY_COMPILE_OSX_ARCHITECTURES to one
value at a time.

Please bring this up on the VTK develpoers list.

-Brad



More information about the CMake mailing list