[Cmake-commits] [cmake-commits] king committed CMakeLists.txt NONE 1.1 CheckTypeSize.c NONE 1.1 config.h.in NONE 1.1
cmake-commits at cmake.org
cmake-commits at cmake.org
Thu Dec 17 15:15:36 EST 2009
Update of /cvsroot/CMake/CMake/Tests/Module/CheckTypeSize
In directory public:/mounts/ram/cvs-serv31562/Tests/Module/CheckTypeSize
Added Files:
CMakeLists.txt CheckTypeSize.c config.h.in
Log Message:
Test the CheckTypeSize module
We create test "Module.CheckTypeSize" to verify that type sizes get
detected correctly.
--- NEW FILE: CheckTypeSize.c ---
#include "config.h"
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif
#ifdef HAVE_STDDEF_H
# include <stddef.h>
#endif
#include <stdio.h>
#define CHECK(t,m) do { \
if(sizeof(t) != m) \
{ \
printf(#m ": expected %d, got %d (line %d)\n", \
(int)sizeof(t), (int)m, __LINE__); \
result = 1; \
} \
} while(0)
#define NODEF(m) do { \
printf(#m": not defined (line %d)\n", __LINE__); \
result = 1; \
} while(0)
int main()
{
int result = 0;
/* void* */
#if !defined(HAVE_SIZEOF_DATA_PTR)
NODEF(HAVE_SIZEOF_DATA_PTR);
#endif
#if defined(SIZEOF_DATA_PTR)
CHECK(void*, SIZEOF_DATA_PTR);
#else
NODEF(SIZEOF_DATA_PTR);
#endif
/* char */
#if !defined(HAVE_SIZEOF_CHAR)
NODEF(HAVE_SIZEOF_CHAR);
#endif
#if defined(SIZEOF_CHAR)
CHECK(char, SIZEOF_CHAR);
#else
NODEF(SIZEOF_CHAR);
#endif
/* short */
#if !defined(HAVE_SIZEOF_SHORT)
NODEF(HAVE_SIZEOF_SHORT);
#endif
#if defined(SIZEOF_SHORT)
CHECK(short, SIZEOF_SHORT);
#else
NODEF(SIZEOF_SHORT);
#endif
/* int */
#if !defined(HAVE_SIZEOF_INT)
NODEF(HAVE_SIZEOF_INT);
#endif
#if defined(SIZEOF_INT)
CHECK(int, SIZEOF_INT);
#else
NODEF(SIZEOF_INT);
#endif
/* long */
#if !defined(HAVE_SIZEOF_LONG)
NODEF(HAVE_SIZEOF_LONG);
#endif
#if defined(SIZEOF_LONG)
CHECK(long, SIZEOF_LONG);
#else
NODEF(SIZEOF_LONG);
#endif
/* long long */
#if defined(SIZEOF_LONG_LONG)
CHECK(long long, SIZEOF_LONG_LONG);
# if !defined(HAVE_SIZEOF_LONG_LONG)
NODEF(HAVE_SIZEOF_LONG_LONG);
# endif
#endif
/* __int64 */
#if defined(SIZEOF___INT64)
CHECK(__int64, SIZEOF___INT64);
# if !defined(HAVE_SIZEOF___INT64)
NODEF(HAVE_SIZEOF___INT64);
# endif
#elif defined(HAVE_SIZEOF___INT64)
NODEF(SIZEOF___INT64);
#endif
/* size_t */
#if !defined(HAVE_SIZEOF_SIZE_T)
NODEF(HAVE_SIZEOF_SIZE_T);
#endif
#if defined(SIZEOF_SIZE_T)
CHECK(size_t, SIZEOF_SIZE_T);
#else
NODEF(SIZEOF_SIZE_T);
#endif
/* ssize_t */
#if defined(SIZEOF_SSIZE_T)
CHECK(ssize_t, SIZEOF_SSIZE_T);
# if !defined(HAVE_SIZEOF_SSIZE_T)
NODEF(HAVE_SIZEOF_SSIZE_T);
# endif
#elif defined(HAVE_SIZEOF_SSIZE_T)
NODEF(SIZEOF_SSIZE_T);
#endif
return result;
}
--- NEW FILE: CMakeLists.txt ---
cmake_minimum_required(VERSION 2.8.1 FATAL_ERROR)
project(CheckTypeSize C)
include(CheckTypeSize)
check_type_size("void*" SIZEOF_DATA_PTR)
check_type_size(char SIZEOF_CHAR)
check_type_size(short SIZEOF_SHORT)
check_type_size(int SIZEOF_INT)
check_type_size(long SIZEOF_LONG)
check_type_size("long long" SIZEOF_LONG_LONG)
check_type_size(__int64 SIZEOF___INT64)
check_type_size(size_t SIZEOF_SIZE_T)
check_type_size(ssize_t SIZEOF_SSIZE_T)
configure_file(config.h.in config.h)
include_directories(${CheckTypeSize_BINARY_DIR})
add_executable(CheckTypeSize CheckTypeSize.c)
--- NEW FILE: config.h.in ---
#cmakedefine HAVE_SYS_TYPES_H
#cmakedefine HAVE_STDINT_H
#cmakedefine HAVE_STDDEF_H
/* void* */
#cmakedefine HAVE_SIZEOF_DATA_PTR
@SIZEOF_DATA_PTR_CODE@
/* char */
#cmakedefine HAVE_SIZEOF_CHAR
@SIZEOF_CHAR_CODE@
/* short */
#cmakedefine HAVE_SIZEOF_SHORT
@SIZEOF_SHORT_CODE@
/* int */
#cmakedefine HAVE_SIZEOF_INT
@SIZEOF_INT_CODE@
/* long */
#cmakedefine HAVE_SIZEOF_LONG
@SIZEOF_LONG_CODE@
/* long long */
#cmakedefine HAVE_SIZEOF_LONG_LONG
@SIZEOF_LONG_LONG_CODE@
/* __int64 */
#cmakedefine HAVE_SIZEOF___INT64
@SIZEOF___INT64_CODE@
/* size_t */
#cmakedefine HAVE_SIZEOF_SIZE_T
@SIZEOF_SIZE_T_CODE@
/* ssize_t */
#cmakedefine HAVE_SIZEOF_SSIZE_T
@SIZEOF_SSIZE_T_CODE@
More information about the Cmake-commits
mailing list