diff --git a/Modules/CMakeBackwardCompatibilityC.cmake b/Modules/CMakeBackwardCompatibilityC.cmake index 857a55df4..a96f9530c 100644 --- a/Modules/CMakeBackwardCompatibilityC.cmake +++ b/Modules/CMakeBackwardCompatibilityC.cmake @@ -9,7 +9,7 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio 6") ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 6") 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(long CMAKE_SIZEOF_LONG) CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P) diff --git a/Modules/CheckSizeOf.c b/Modules/CheckSizeOf.c deleted file mode 100644 index 139a3ab7d..000000000 --- a/Modules/CheckSizeOf.c +++ /dev/null @@ -1,20 +0,0 @@ -#ifdef CHECK_SIZE_OF - -#ifdef HAVE_SYS_TYPES_H -# include -#endif /* HAVE_SYS_TYPES_H */ - -#ifdef HAVE_STDINT_H -# include -#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 */ diff --git a/Modules/CheckSizeOf.cmake b/Modules/CheckSizeOf.cmake index b4a880c5c..3820d4c52 100644 --- a/Modules/CheckSizeOf.cmake +++ b/Modules/CheckSizeOf.cmake @@ -1,34 +1,4 @@ -# -# 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_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) +MESSAGE(SEND_ERROR + "Modules/CheckSizeOf.cmake has been removed. " + "Use Modules/CheckTypeSize.cmake instead. This " + "compatability check may be removed before the next release!") diff --git a/Modules/CheckTypeSize.c b/Modules/CheckTypeSize.c new file mode 100644 index 000000000..43de43981 --- /dev/null +++ b/Modules/CheckTypeSize.c @@ -0,0 +1,20 @@ +#ifdef CHECK_TYPE_SIZE_TYPE + +#ifdef HAVE_SYS_TYPES_H +# include +#endif /* HAVE_SYS_TYPES_H */ + +#ifdef HAVE_STDINT_H +# include +#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 */ diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake new file mode 100644 index 000000000..35dcaaa81 --- /dev/null +++ b/Modules/CheckTypeSize.cmake @@ -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) diff --git a/Tests/LoadCommand/CMakeLists.txt b/Tests/LoadCommand/CMakeLists.txt index b20b4148a..24f985964 100644 --- a/Tests/LoadCommand/CMakeLists.txt +++ b/Tests/LoadCommand/CMakeLists.txt @@ -3,7 +3,7 @@ PROJECT(LoadedCommand) # set a definition SET (TEST_COMMAND_TEST1 1) -INCLUDE (${CMAKE_ROOT}/Modules/CheckSizeOf.cmake) +INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake) CHECK_TYPE_SIZE(char SIZEOF_CHAR) INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) diff --git a/Tests/LoadCommandOneConfig/CMakeLists.txt b/Tests/LoadCommandOneConfig/CMakeLists.txt index b20b4148a..24f985964 100644 --- a/Tests/LoadCommandOneConfig/CMakeLists.txt +++ b/Tests/LoadCommandOneConfig/CMakeLists.txt @@ -3,7 +3,7 @@ PROJECT(LoadedCommand) # set a definition SET (TEST_COMMAND_TEST1 1) -INCLUDE (${CMAKE_ROOT}/Modules/CheckSizeOf.cmake) +INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake) CHECK_TYPE_SIZE(char SIZEOF_CHAR) INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)