Fix unnecessary config.h preprocessor (re)definitions.

The CMake-generated config.h would redundantly define some types to
themselves, causing lots of warning in some cases (e.g. Xcode build).

This addresses #414
This commit is contained in:
Jon Siwek 2011-04-11 16:59:07 -05:00
parent 050680aa63
commit c732cef69b
3 changed files with 26 additions and 45 deletions

View file

@ -7,9 +7,6 @@ check_function_exists(strerror HAVE_STRERROR)
check_function_exists(strsep HAVE_STRSEP)
check_function_exists(sigset HAVE_SIGSET)
if (HAVE_SIGSET)
set(SIG_FUNC sigset)
else ()
set(SIG_FUNC signal)
if (NOT HAVE_SIGSET)
check_function_exists(sigaction HAVE_SIGACTION)
endif ()

View file

@ -4,43 +4,25 @@ check_type_size("long int" SIZEOF_LONG_INT)
check_type_size("long long" SIZEOF_LONG_LONG)
check_type_size("void *" SIZEOF_VOID_P)
# checks existence of ${_type}, and if it does not, sets CMake variable ${_var}
# to alternative type, ${_alt_type}
macro(CheckType _type _alt_type _var)
check_type_size(${_type} ${_var})
if (NOT ${_var})
set(${_var} ${_alt_type})
else ()
unset(${_var})
unset(${_var} CACHE)
endif ()
endmacro(CheckType _type _alt_type _var)
set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h)
check_type_size(int32_t INT32_T)
if (INT32_T)
set(INT32_T int32_t)
else()
set(INT32_T int)
endif()
check_type_size(u_int32_t U_INT32_T)
if (U_INT32_T)
set(U_INT32_T u_int32_t)
else ()
set(INT32_T u_int)
endif ()
check_type_size(u_int16_t U_INT16_T)
if (U_INT16_T)
set(U_INT16_T u_int16_t)
else ()
set(INT16_T u_short)
endif ()
check_type_size(u_int8_t U_INT8_T)
if (U_INT8_T)
set(U_INT8_T u_int8_t)
else ()
set(INT8_T u_char)
endif ()
CheckType(int32_t int int32_t)
CheckType(u_int32_t u_int u_int32_t)
CheckType(u_int16_t u_short u_int16_t)
CheckType(u_int8_t u_char u_int8_t)
set(CMAKE_EXTRA_INCLUDE_FILES)
set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
check_type_size(socklen_t SOCKLEN_T)
if (SOCKLEN_T)
set(SOCKLEN_T socklen_t)
else ()
set(SOCKLEN_T int)
endif ()
CheckType(socklen_t int socklen_t)
set(CMAKE_EXTRA_INCLUDE_FILES)

View file

@ -130,19 +130,21 @@
#endif
/* Define int32_t */
#define int32_t @INT32_T@
#cmakedefine int32_t @int32_t@
/* use sigset() instead of signal() */
#define signal @SIG_FUNC@
#ifdef HAVE_SIGSET
#define signal sigset
#endif
/* define to int if socklen_t not available */
#define socklen_t @SOCKLEN_T@
#cmakedefine socklen_t @socklen_t@
/* Define u_int16_t */
#define u_int16_t @U_INT16_T@
#cmakedefine u_int16_t @u_int16_t@
/* Define u_int32_t */
#define u_int32_t @U_INT32_T@
#cmakedefine u_int32_t @u_int32_t@
/* Define u_int8_t */
#define u_int8_t @U_INT8_T@
#cmakedefine u_int8_t @u_int8_t@