[CMake] CheckTypeSize and non-standard headers

Michael Jackson mike.jackson at bluequartz.net
Mon Feb 16 20:53:32 EST 2009


project(Test)
cmake_minimum_required(VERSION 2.7)

INCLUDE(${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)

set(CMAKE_REQUIRED_DEFINITIONS_SAVE ${CMAKE_REQUIRED_DEFINITIONS})
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS};- 
D__need_wint_t=1)

CHECK_TYPE_SIZE(wint_t WINT_T)
message(STATUS "Size of wint_t: ${WINT_T}")
message(STATUS "HAVE_WINT_T: ${HAVE_WINT_T}")

set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS_SAVE})

Although I am not sure under what circumstances you are supposed to  
define __need_wint_t? Or if there is some other encompassing macro to  
define. Otherwise the above will find the size in bytes of wint_t.

_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio



On Feb 16, 2009, at 7:30 PM, Aaron Turner wrote:

> More testing seems to indicate that check_symbol_exists won't find any
> typedef defined in headers.
>
> Looking a the CheckSymbolExists.cmake file, the following .c is
> generated as a test:
>
> #include <runetype.h>
> void cmakeRequireSymbol(int dummy,...) {
>    (void)dummy;
> }
>
> int main() {
> #ifndef wint_t
>    cmakeRequireSymbol(0, &wint_t);
> #endif
>    return 0;
> }
>
> Unfortunately, you can't use #ifndef to test for the existence of a
> typedef, hence you get a compile failure and the result of the test is
> false.
>
> Is there another check which is typedef/define agnostic?  I'm sure I
> could write my own, but this seems like it should be included in the
> standard cmake library.
>
>
> -- 
> Aaron Turner
> http://synfin.net/
> http://tcpreplay.synfin.net/ - Pcap editing and replay tools for  
> Unix & Windows
> Those who would give up essential Liberty, to purchase a little
> temporary Safety,
> deserve neither Liberty nor Safety.
>    -- Benjamin Franklin
> _______________________________________________
> 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



More information about the CMake mailing list