Skip to content

Commit

Permalink
Merge branch 'fix-vnl-64bits-compile' into slicer-4.0
Browse files Browse the repository at this point in the history
* fix-vnl-64bits-compile:
  Review DETERMINE_TYPE vxl macro
  Add VXL_SIZEOF_SIZE_T test
  Add VXL_HAS_WIN_WCHAR_T test
  Update VXL_HAS_TYPE_OF_SIZE test
  • Loading branch information
jcfr committed May 7, 2011
2 parents 9a6954f + f1fe0ad commit 71e4277
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
12 changes: 12 additions & 0 deletions Utilities/vxl/config/cmake/config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ IF(APPLE)
ENDIF(NOT ${VXL_APPLE_HAS_ISNAND})
ENDIF(APPLE)

# Check if Windows have wchar_t defined
IF(WIN32)
PERFORM_CMAKE_TEST(vxl_platform_tests.cxx VXL_HAS_WIN_WCHAR_T)
ENDIF(WIN32)

#
# Find header files
#
Expand Down Expand Up @@ -339,6 +344,13 @@ ELSE(VCL_CXX_HAS_HEADER_LIMITS)
SET(VCL_PROCESSOR_HAS_INFINITY 0)
ENDIF(VCL_CXX_HAS_HEADER_LIMITS)

#
# Check the address model of the build, i.e. 32-bit (4-byte) or 64-bit (8-byte).
# The type of size_t is directly related to address model on most machines and compilers.
# Hence, we detect the size of size_t instead.
#
check_type_size(size_t VXL_SIZEOF_SIZE_T)
MATH(EXPR VXL_ADDRESS_BITS 8*${VXL_SIZEOF_SIZE_T} )

#
# configure files
Expand Down
15 changes: 5 additions & 10 deletions Utilities/vxl/config/cmake/config/vxl_config_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -249,23 +249,18 @@ MACRO( DETERMINE_TYPE VAR INTEGRAL_TYPE SIZE TYPE_LIST )
# line to avoid issues with spaces. (In "long double", for
# example)
WRITE_FILE( ${CMAKE_BINARY_DIR}/CMakeTmp/config.h "#define THE_TYPE ${TYPE}\n#define THE_SIZE ${SIZE}\n#define INTEGRAL_TYPE ${INTEGRAL_TYPE}" )
SET( MACRO_DETERMINE_TYPE_FLAGS "-DVXL_HAS_TYPE_OF_SIZE -I\"${CMAKE_BINARY_DIR}/CMakeTmp\"" )
SET( MACRO_DETERMINE_TYPE_FLAGS "-DVXL_HAS_TYPE_OF_SIZE" )
MESSAGE( STATUS "${MSG} [Checking ${TYPE}...]" )
TRY_RUN( RUN_RESULT COMPILE_RESULT
TRY_COMPILE(COMPILE_RESULT
${CMAKE_BINARY_DIR}
${vxl_config_SOURCE_DIR}/vxl_platform_tests.cxx
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_DETERMINE_TYPE_FLAGS}
-DINCLUDE_DIRECTORIES:STRING=${CMAKE_BINARY_DIR}/CMakeTmp
-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}
OUTPUT_VARIABLE OUTPUT )
IF( COMPILE_RESULT )
IF( NOT RUN_RESULT )
SET( VXL_${VAR} ${TYPE} )
SET( VXL_HAS_${VAR} 1 )
ELSE( NOT RUN_RESULT )
WRITE_FILE( ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"${MSG} Failed to run with the following output:\n(FLAGS=${MACRO_DETERMINE_TYPE_FLAGS})\n${OUTPUT}\n"
APPEND )
ENDIF( NOT RUN_RESULT )
SET( VXL_${VAR} ${TYPE} )
SET( VXL_HAS_${VAR} 1 )
ELSE( COMPILE_RESULT )
WRITE_FILE( ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"${MSG} Failed to compile with the following output:\n(FLAGS=${MACRO_DETERMINE_TYPE_FLAGS})\n${OUTPUT}\n"
Expand Down
24 changes: 23 additions & 1 deletion Utilities/vxl/config/cmake/config/vxl_platform_tests.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1039,9 +1039,13 @@ double cast( THE_TYPE a )
}
#endif // INTEGRAL_TYPE

// These declarations conflict unless the sizes match.
extern int (*verify_size)[sizeof(THE_TYPE) * CHAR_BIT];
extern int (*verify_size)[THE_SIZE];

int main()
{
return sizeof(THE_TYPE) * CHAR_BIT == THE_SIZE ? 0 : 1;
return 0;
}

#endif // VXL_HAS_TYPE_OF_SIZE
Expand Down Expand Up @@ -1124,6 +1128,24 @@ int main()
}
#endif // VXL_APPLE_HAS_INLINE_ISNAND

//-------------------------------------
#ifdef VXL_HAS_WIN_WCHAR_T

#ifdef _WCHAR_T_DEFINED
#include <wchar.h>
int main()
{
wchar_t buf [10];
buf[0] = L'1';
buf[1] = L'\0';
return 0;
}
#else
int main() { return 1; }
#endif

#endif

//-------------------------------------

#ifdef VXL_HAS_MM_MALLOC
Expand Down

0 comments on commit 71e4277

Please sign in to comment.