[cmake-commits] alex committed CheckTypeSize.c.in 1.3 NONE
CheckTypeSize.cmake 1.29 1.30 TestBigEndian.c 1.4 NONE
TestBigEndian.cmake 1.13 1.14 TestEndianess.c.in NONE 1.1
cmake-commits at cmake.org
cmake-commits at cmake.org
Fri Aug 10 13:14:03 EDT 2007
Update of /cvsroot/CMake/CMake/Modules
In directory public:/mounts/ram/cvs-serv14815
Modified Files:
CheckTypeSize.cmake TestBigEndian.cmake
Added Files:
TestEndianess.c.in
Removed Files:
CheckTypeSize.c.in TestBigEndian.c
Log Message:
STYLE: remove unused CheckTypeSize.c.in
ENH: change test for endianess from TRY_RUN() to TRY_COMPILE() by testing
the binary image of a 16bit integer array, tested on Linux x86, Intel Mac
and Sun (big endian)
Alex
Index: CheckTypeSize.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CheckTypeSize.cmake,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- CheckTypeSize.cmake 7 Jun 2007 17:51:17 -0000 1.29
+++ CheckTypeSize.cmake 10 Aug 2007 17:14:00 -0000 1.30
@@ -78,7 +78,7 @@
ELSE(HAVE_${VARIABLE})
MESSAGE(STATUS "Check size of ${TYPE} - failed")
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Determining size of ${TYPE} failed with the following output:\n${OUTPUT}\nCheckTypeSize.c:\n${CHECK_TYPE_SIZE_FILE_CONTENT}\n\n")
+ "Determining size of ${TYPE} failed with the following output:\n${OUTPUT}\nCheckTypeSizeC.c:\n${CHECK_TYPE_SIZE_FILE_CONTENT}\n\n")
SET(${VARIABLE})
ENDIF(HAVE_${VARIABLE})
SET(${VARIABLE} "${${VARIABLE}}" CACHE INTERNAL "Result of CHECK_TYPE_SIZE" FORCE)
--- NEW FILE: TestEndianess.c.in ---
/* A 16 bit integer is required. */
typedef @CMAKE_16BIT_TYPE@ cmakeint16;
/* On a little endian machine, these 16bit ints will give "THIS IS LITTLE ENDIAN."
On a big endian machine the characters will be exchanged pairwise. */
const cmakeint16 info_little[] = {0x4854, 0x5349, 0x4920, 0x2053, 0x494c, 0x5454, 0x454c, 0x4520, 0x444e, 0x4149, 0x2e4e, 0x0000};
/* on a big endian machine, these 16bit ints will give "THIS IS BIG ENDIAN."
On a little endian machine the characters will be exchanged pairwise. */
const cmakeint16 info_big[] = {0x5448, 0x4953, 0x2049, 0x5320, 0x4249, 0x4720, 0x454e, 0x4449, 0x414e, 0x2e2e, 0x0000};
#ifdef __CLASSIC_C__
int main(){
int ac;
char*av[];
#else
int main(int ac, char*av[]){
#endif
return (&info_little[0] != &info_big[0]);
}
--- TestBigEndian.c DELETED ---
--- CheckTypeSize.c.in DELETED ---
Index: TestBigEndian.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/TestBigEndian.cmake,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- TestBigEndian.cmake 1 Jun 2007 15:16:29 -0000 1.13
+++ TestBigEndian.cmake 10 Aug 2007 17:14:00 -0000 1.14
@@ -5,37 +5,85 @@
#
MACRO(TEST_BIG_ENDIAN VARIABLE)
- SET(CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS 1)
- IF(NOT DEFINED ${VARIABLE})
IF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$")
- TRY_RUN(${VARIABLE} HAVE_${VARIABLE}
- ${CMAKE_BINARY_DIR}
- ${CMAKE_ROOT}/Modules/TestBigEndian.c
- COMPILE_OUTPUT_VARIABLE OUTPUT)
- IF("${VARIABLE}" STREQUAL "FAILED_TO_RUN")
- MESSAGE(SEND_ERROR "TestBigEndian Failed to run with output: ${OUTPUT}")
- ENDIF("${VARIABLE}" STREQUAL "FAILED_TO_RUN")
MESSAGE(STATUS "Check if the system is big endian")
- IF(HAVE_${VARIABLE})
- FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Determining the endianes of the system passed. The system is ")
- IF(${VARIABLE})
- FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "big endian")
- MESSAGE(STATUS "Check if the system is big endian - big endian")
- ELSE(${VARIABLE})
- FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "little endian")
- MESSAGE(STATUS "Check if the system is big endian - little endian")
- ENDIF(${VARIABLE})
- FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Test produced following output:\n${OUTPUT}\n\n")
- ELSE(HAVE_${VARIABLE})
- FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Determining the endianes of the system failed with the following output:\n${OUTPUT}\n\n")
- MESSAGE("Check if the system is big endian - failed")
- ENDIF(HAVE_${VARIABLE})
+ MESSAGE(STATUS "Searching 16 bit integer")
+
+ INCLUDE(CheckTypeSize)
+
+ CHECK_TYPE_SIZE("unsigned short" CMAKE_SIZEOF_UNSIGNED_SHORT)
+ IF(CMAKE_SIZEOF_UNSIGNED_SHORT EQUAL 2)
+ MESSAGE(STATUS "Using unsigned short")
+ SET(CMAKE_16BIT_TYPE "unsigned short")
+ ELSE(CMAKE_SIZEOF_UNSIGNED_SHORT EQUAL 2)
+ CHECK_TYPE_SIZE("unsigned int" CMAKE_SIZEOF_UNSIGNED_INT)
+ IF(CMAKE_SIZEOF_UNSIGNED_INT)
+ MESSAGE(STATUS "Using unsigned int")
+ SET(CMAKE_16BIT_TYPE "unsigned int")
+
+ ELSE(CMAKE_SIZEOF_UNSIGNED_INT)
+
+ CHECK_TYPE_SIZE("unsigned long" CMAKE_SIZEOF_UNSIGNED_LONG)
+ IF(CMAKE_SIZEOF_UNSIGNED_LONG)
+ MESSAGE(STATUS "Using unsigned long")
+ SET(CMAKE_16BIT_TYPE "unsigned long")
+ ELSE(CMAKE_SIZEOF_UNSIGNED_LONG)
+ MESSAGE(FATAL_ERROR "no suitable type found")
+ ENDIF(CMAKE_SIZEOF_UNSIGNED_LONG)
+
+ ENDIF(CMAKE_SIZEOF_UNSIGNED_INT)
+
+ ENDIF(CMAKE_SIZEOF_UNSIGNED_SHORT EQUAL 2)
+
+
+ CONFIGURE_FILE("${CMAKE_ROOT}/Modules/TestEndianess.c.in"
+ "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/TestEndianess.c"
+ IMMEDIATE @ONLY)
+
+ FILE(READ "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/TestEndianess.c"
+ TEST_ENDIANESS_FILE_CONTENT)
+
+ TRY_COMPILE(HAVE_${VARIABLE}
+ "${CMAKE_BINARY_DIR}"
+ "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/TestEndianess.c"
+ OUTPUT_VARIABLE OUTPUT
+ COPY_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestEndianess.bin" )
+
+ IF(HAVE_${VARIABLE})
+
+ FILE(STRINGS "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestEndianess.bin"
+ CMAKE_TEST_ENDIANESS_STRINGS_LE LIMIT_COUNT 1 REGEX "THIS IS LITTLE ENDIAN")
+
+ FILE(STRINGS "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestEndianess.bin"
+ CMAKE_TEST_ENDIANESS_STRINGS_BE LIMIT_COUNT 1 REGEX "THIS IS BIG ENDIAN")
+
+ IF(CMAKE_TEST_ENDIANESS_STRINGS_LE)
+ SET(${VARIABLE} 0 CACHE INTERNAL "Result of TEST_BIG_ENDIAN" FORCE)
+ MESSAGE(STATUS "Check if the system is big endian - little endian")
+ ENDIF(CMAKE_TEST_ENDIANESS_STRINGS_LE)
+
+ IF(CMAKE_TEST_ENDIANESS_STRINGS_BE)
+ SET(${VARIABLE} 1 CACHE INTERNAL "Result of TEST_BIG_ENDIAN" FORCE)
+ MESSAGE(STATUS "Check if the system is big endian - big endian")
+ ENDIF(CMAKE_TEST_ENDIANESS_STRINGS_BE)
+
+ IF(CMAKE_TEST_ENDIANESS_STRINGS_BE AND CMAKE_TEST_ENDIANESS_STRINGS_LE)
+ MESSAGE(SEND_ERROR "TEST_BIG_ENDIAN found different results, consider setting CMAKE_OSX_ARCHITECTURES or CMAKE_TRY_COMPILE_OSX_ARCHITECTURES to one or no architecture !")
+ ENDIF(CMAKE_TEST_ENDIANESS_STRINGS_BE AND CMAKE_TEST_ENDIANESS_STRINGS_LE)
+ IF(NOT CMAKE_TEST_ENDIANESS_STRINGS_BE AND NOT CMAKE_TEST_ENDIANESS_STRINGS_LE)
+ MESSAGE(SEND_ERROR "TEST_BIG_ENDIAN found no !")
+ ENDIF(NOT CMAKE_TEST_ENDIANESS_STRINGS_BE AND NOT CMAKE_TEST_ENDIANESS_STRINGS_LE)
+
+ FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining if the system is big endian passed with the following output:\n${OUTPUT}\nTestEndianess.c:\n${TEST_ENDIANESS_FILE_CONTENT}\n\n")
+
+ ELSE(HAVE_${VARIABLE})
+ MESSAGE(STATUS "Check if the system is big endian - failed")
+ FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining if the system is big endian failed with the following output:\n${OUTPUT}\nTestEndianess.c:\n${TEST_ENDIANESS_FILE_CONTENT}\n\n")
+ SET(${VARIABLE})
+ ENDIF(HAVE_${VARIABLE})
ENDIF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$")
- ENDIF(NOT DEFINED ${VARIABLE})
- SET(CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS)
ENDMACRO(TEST_BIG_ENDIAN)
+
+
More information about the Cmake-commits
mailing list