On 8/11/10 4:29 PM, Michael Wild wrote:
>
> On 11. Aug, 2010, at 22:16 , Michael Jackson wrote:
>
>>
>>
>> On Aug 11, 2010, at 3:52 PM, Michael Wild wrote:
>>
>>>
>>> On 11. Aug, 2010, at 21:44 , Erik Lindahl wrote:
>>>
>>>> Hi,
>>>>
>>>> Sound technical answers from both David & Clinton - I see the limitations,
>>>> and why we have to live with it for now ;-)
>>>>
>>>> Given that there are good reasons to change it on-the-fly, but that it is
>>>> still almost as fundamental as a compiler change, perhaps it could at
>>>> least make sense to display some sort of warning if it is changed, and
>>>> stress that it will not update architecture-dependent data in the cache?
>>>>
>>>> Cheers,
>>>>
>>>> Erik
>>>
>>> The problem is more fundamental. If you set CMAKE_OSX_ARCHITECTURES to e.g.
>>> i386;x86_64;ppc;ppc64 to compile a four-way universal binary, what is the
>>> expected result from CheckTypeSize() and similar functions? There should be
>>> one result for each of the architectures. That's why you need to do it at
>>> compile-time using __i386__, __x86_64__, __ppc__ and __ppc64__, or you test
>>> the length of the CMAKE_OSX_ARCHITECTURES list and if that is larger than
>>> one, you error out. IMHO CMake can't help you much beyond that.
>>>
>>> Michael
>>
>> Just as I was looking something else up I came across the docs for
>> "CheckTypeSize".
>>
>> Check if the type exists and determine its size. On return,
>> "HAVE_${VARIABLE}" holds the existence of the type, and "${VARIABLE}" holds
>> one of the following:
>> <size> = type has non-zero size <size>
>> "0" = type has arch-dependent size (see below)
>> "" = type does not exist
>> Furthermore, the variable "${VARIABLE}_CODE" holds C preprocessor code to
>> define the macro "${VARIABLE}" to the size of the type, or leave the macro
>> undefined if the type does not exist.
>>
>> The variable "${VARIABLE}" may be "0" when CMAKE_OSX_ARCHITECTURES has
>> multiple architectures for building OS X universal binaries. This indicates
>> that the type size varies across architectures. In this case
>> "${VARIABLE}_CODE" contains C preprocessor tests mapping from each
>> architecture macro to the corresponding type size. The list of architecture
>> macros is stored in "${VARIABLE}_KEYS", and the value for each key is stored
>> in "${VARIABLE}-${KEY}".
>>
>> With that I wrote the following CMakeLists.txt
>>
>> # Begin CMakeLists.txt
>>
>> project(test)
>>
>> cmake_minimum_required(VERSION 2.8)
>>
>> INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
>>
>> CHECK_TYPE_SIZE(long SIZE_OF_LONG)
>>
>> message(STATUS "Preprocessor Code To use. \n ${SIZE_OF_LONG_CODE}")
>>
>> foreach( key ${SIZE_OF_LONG_KEYS})
>>
>> message(STATUS "Variable: SIZE_OF_LONG key: ${key} value:
>> ${SIZE_OF_LONG-${key}}")
>>
>> endforeach()
>>
>>
>> # End CMakeLists.txt file
>>
>> and invoked it with the following:
>> cmake -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" ../
>>
>>
>> and got back this in response.
>> .....
>> -- Check size of long
>> -- Check size of long - done
>> -- Preprocessor Code To use. #if defined(__i386)
>> # define SIZE_OF_LONG 4
>> #elif defined(__x86_64)
>> # define SIZE_OF_LONG 8
>> #else
>> # error SIZE_OF_LONG unknown
>> #endif
>> -- Variable: SIZE_OF_LONG key: __i386 value: 4
>> -- Variable: SIZE_OF_LONG key: __x86_64 value: 8
>> .....
>>
>> So CMake is _trying_ to help you as best it can at the moment. You should
>> still be able to wrap the test to CheckTypeSize() with your own function,
>> detect the change to CMAKE_OSX_ARCHITECTURES and the forcibly rerun the test
>> again.
>>
>> Hope some of that helps.
>> Mike Jackson
>
> Now THAT is very neat indeed! Thanks for that hint.
>
> Michael
I second that - would it be worth putting that in a cmake-supplied macro?
-Chris
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake