ENH: Renamed Modules/CheckSizeOf to Modules/CheckTypeSize for consistency with the macro name that is defined by the module.

This commit is contained in:
Brad King 2002-12-30 11:02:31 -05:00
parent 6e4712d6ed
commit ea1467d056
7 changed files with 61 additions and 57 deletions

View File

@ -9,7 +9,7 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio 6")
ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 6") ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 6")
IF(NOT CMAKE_SKIP_COMPATIBILITY_TESTS) IF(NOT CMAKE_SKIP_COMPATIBILITY_TESTS)
INCLUDE (${CMAKE_ROOT}/Modules/CheckSizeOf.cmake) INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
CHECK_TYPE_SIZE(int CMAKE_SIZEOF_INT) CHECK_TYPE_SIZE(int CMAKE_SIZEOF_INT)
CHECK_TYPE_SIZE(long CMAKE_SIZEOF_LONG) CHECK_TYPE_SIZE(long CMAKE_SIZEOF_LONG)
CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P) CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P)

View File

@ -1,20 +0,0 @@
#ifdef CHECK_SIZE_OF
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif /* HAVE_STDINT_H */
int main()
{
return sizeof(CHECK_SIZE_OF);
}
#else /* CHECK_SIZE_OF */
# error "CHECK_SIZE_OF has to specify the type"
#endif /* CHECK_SIZE_OF */

View File

@ -1,34 +1,4 @@
# MESSAGE(SEND_ERROR
# Check if the type exists and determine size of type. if the type "Modules/CheckSizeOf.cmake has been removed. "
# exists, the size will be stored to the variable. "Use Modules/CheckTypeSize.cmake instead. This "
# "compatability check may be removed before the next release!")
# CHECK_TYPE_SIZE - macro which checks the size of type
# VARIABLE - variable to store size if the type exists.
#
MACRO(CHECK_TYPE_SIZE TYPE VARIABLE)
IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
SET(MACRO_CHECK_TYPE_SIZE_FLAGS -DCHECK_SIZE_OF="${TYPE}")
IF(HAVE_SYS_TYPES_H)
SET(MACRO_CHECK_TYPE_SIZE_FLAGS
"${MACRO_CHECK_TYPE_SIZE_FLAGS} -DHAVE_SYS_TYPES_H")
ENDIF(HAVE_SYS_TYPES_H)
IF(HAVE_STDINT_H)
SET(MACRO_CHECK_TYPE_SIZE_FLAGS "${MACRO_CHECK_TYPE_SIZE_FLAGS} -DHAVE_STDINT_H")
ENDIF(HAVE_STDINT_H)
MESSAGE(STATUS "Check size of ${TYPE}")
TRY_RUN(${VARIABLE} HAVE_${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_ROOT}/Modules/CheckSizeOf.c
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_TYPE_SIZE_FLAGS}
OUTPUT_VARIABLE OUTPUT)
IF(HAVE_${VARIABLE})
MESSAGE(STATUS "Check size of ${TYPE} - done")
ELSE(HAVE_${VARIABLE})
MESSAGE(STATUS "Check size of ${TYPE} - failed")
WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log
"Determining size of ${TYPE} failed with the following output:\n${OUTPUT}\n"
APPEND)
ENDIF(HAVE_${VARIABLE})
ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$")
ENDMACRO(CHECK_TYPE_SIZE)

20
Modules/CheckTypeSize.c Normal file
View File

@ -0,0 +1,20 @@
#ifdef CHECK_TYPE_SIZE_TYPE
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif /* HAVE_STDINT_H */
int main()
{
return sizeof(CHECK_TYPE_SIZE_TYPE);
}
#else /* CHECK_TYPE_SIZE_TYPE */
# error "CHECK_TYPE_SIZE_TYPE has to specify the type"
#endif /* CHECK_TYPE_SIZE_TYPE */

View File

@ -0,0 +1,34 @@
#
# Check if the type exists and determine size of type. if the type
# exists, the size will be stored to the variable.
#
# CHECK_TYPE_SIZE - macro which checks the size of type
# VARIABLE - variable to store size if the type exists.
#
MACRO(CHECK_TYPE_SIZE TYPE VARIABLE)
IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
SET(MACRO_CHECK_TYPE_SIZE_FLAGS -DCHECK_TYPE_SIZE_TYPE="${TYPE}")
IF(HAVE_SYS_TYPES_H)
SET(MACRO_CHECK_TYPE_SIZE_FLAGS
"${MACRO_CHECK_TYPE_SIZE_FLAGS} -DHAVE_SYS_TYPES_H")
ENDIF(HAVE_SYS_TYPES_H)
IF(HAVE_STDINT_H)
SET(MACRO_CHECK_TYPE_SIZE_FLAGS "${MACRO_CHECK_TYPE_SIZE_FLAGS} -DHAVE_STDINT_H")
ENDIF(HAVE_STDINT_H)
MESSAGE(STATUS "Check size of ${TYPE}")
TRY_RUN(${VARIABLE} HAVE_${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_ROOT}/Modules/CheckTypeSize.c
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_TYPE_SIZE_FLAGS}
OUTPUT_VARIABLE OUTPUT)
IF(HAVE_${VARIABLE})
MESSAGE(STATUS "Check size of ${TYPE} - done")
ELSE(HAVE_${VARIABLE})
MESSAGE(STATUS "Check size of ${TYPE} - failed")
WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log
"Determining size of ${TYPE} failed with the following output:\n${OUTPUT}\n"
APPEND)
ENDIF(HAVE_${VARIABLE})
ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$")
ENDMACRO(CHECK_TYPE_SIZE)

View File

@ -3,7 +3,7 @@ PROJECT(LoadedCommand)
# set a definition # set a definition
SET (TEST_COMMAND_TEST1 1) SET (TEST_COMMAND_TEST1 1)
INCLUDE (${CMAKE_ROOT}/Modules/CheckSizeOf.cmake) INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
CHECK_TYPE_SIZE(char SIZEOF_CHAR) CHECK_TYPE_SIZE(char SIZEOF_CHAR)
INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)

View File

@ -3,7 +3,7 @@ PROJECT(LoadedCommand)
# set a definition # set a definition
SET (TEST_COMMAND_TEST1 1) SET (TEST_COMMAND_TEST1 1)
INCLUDE (${CMAKE_ROOT}/Modules/CheckSizeOf.cmake) INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
CHECK_TYPE_SIZE(char SIZEOF_CHAR) CHECK_TYPE_SIZE(char SIZEOF_CHAR)
INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)