summaryrefslogtreecommitdiff
path: root/CMAKE
diff options
context:
space:
mode:
authorjulie <julielangou@users.noreply.github.com>2011-02-26 20:51:01 (GMT)
committerjulie <julielangou@users.noreply.github.com>2011-02-26 20:51:01 (GMT)
commit2bbd1ad6d595d9c1f6f0c4f7f115486d38ac920a (patch)
tree669aa48af0c8a4a3e183813728ce36a5cd5201c9 /CMAKE
parent3e6afae0ef900f9ce7d807aac80607d4a53bc9e3 (diff)
downloadlapack-2bbd1ad6d595d9c1f6f0c4f7f115486d38ac920a.zip
lapack-2bbd1ad6d595d9c1f6f0c4f7f115486d38ac920a.tar.gz
lapack-2bbd1ad6d595d9c1f6f0c4f7f115486d38ac920a.tar.bz2
Re-worked type-size checks to search for differnt sizes for different types
- Chuck Atkins (Kitware)
Diffstat (limited to 'CMAKE')
-rw-r--r--CMAKE/CheckFortranTypeSizes.cmake56
1 files changed, 31 insertions, 25 deletions
diff --git a/CMAKE/CheckFortranTypeSizes.cmake b/CMAKE/CheckFortranTypeSizes.cmake
index e7c6ad6..9cc12ce 100644
--- a/CMAKE/CheckFortranTypeSizes.cmake
+++ b/CMAKE/CheckFortranTypeSizes.cmake
@@ -4,44 +4,50 @@
# After execution, the following variables are set. If they are un set then
# size detection was not possible
#
-# SIZEOF_CHARACTER - Number of bytes used to store the default CHARACTER type
-# SIZEOF_LOGICAL - Number of bytes used to store the default LOGICAL type
# SIZEOF_INTEGER - Number of bytes used to store the default INTEGER type
# SIZEOF_REAL - Number of bytes used to store the default REAL type
-# SIZEOF_COMPLEX - Number of bytes used to store the default COMPLEX type
+# SIZEOF_LOGICAL - Number of bytes used to store the default LOGICAL type
+# SIZEOF_CHARACTER - Number of bytes used to store the default CHARACTER type
#
#=============================================================================
# Author: Chuck Atkins
-# Copyright 2010
+# Copyright 2011
#=============================================================================
-macro( CHECK_FORTRAN_TYPE_SIZES )
- if( NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90 )
- message( FATAL_ERROR "Type size tests require Fortran 90 support" )
- endif()
- foreach( _TEST_TYPE "CHARACTER" "LOGICAL" "INTEGER" "REAL" "COMPLEX" )
- string( REPLACE " " "_" _TEST_TYPE_VAR "${_TEST_TYPE}" )
- foreach( _TEST_SIZE 1 2 4 8 16 32 )
- set( _TEST_FILE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortran${_TEST_TYPE_VAR}Size${_TEST_SIZE}.f90 )
- file( WRITE ${_TEST_FILE}
+# Check the size of a single fortran type
+macro( _CHECK_FORTRAN_TYPE_SIZE _TYPE_NAME _TEST_SIZES )
+
+ foreach( __TEST_SIZE ${_TEST_SIZES} )
+ set( __TEST_FILE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortran${_TYPE_NAME}Size${__TEST_SIZE}.f90 )
+ file( WRITE ${__TEST_FILE}
"
PROGRAM check_size
- ${_TEST_TYPE}*${_TEST_SIZE}, TARGET :: a
- ${_TEST_TYPE}, POINTER :: pa
+ ${_TYPE_NAME}*${__TEST_SIZE}, TARGET :: a
+ ${_TYPE_NAME}, POINTER :: pa
pa => a
END PROGRAM
")
- try_compile( SIZEOF_${_TEST_TYPE_VAR} ${CMAKE_BINARY_DIR} ${_TEST_FILE} )
- if( SIZEOF_${_TEST_TYPE_VAR} )
- message( STATUS "Testing default ${_TEST_TYPE}*${_TEST_SIZE} - found" )
- set( SIZEOF_${_TEST_TYPE_VAR} ${_TEST_SIZE} CACHE INTERNAL "Size of the default ${_TEST_TYPE} type" FORCE )
- break()
- endif()
- endforeach()
- if( NOT SIZEOF_${_TEST_TYPE_VAR} )
- message( WARNING "Unable to determine default size of type ${_TEST_TYPE}" )
- unset( SIZEOF_${_TEST_TYPE_VAR} CACHE )
+ try_compile( SIZEOF_${_TYPE_NAME} ${CMAKE_BINARY_DIR} ${__TEST_FILE} )
+ if( SIZEOF_${_TYPE_NAME} )
+ message( STATUS "Testing default ${_TYPE_NAME}*${__TEST_SIZE} - found" )
+ set( SIZEOF_${_TYPE_NAME} ${__TEST_SIZE} CACHE INTERNAL "Size of the default ${_TYPE_NAME} type" FORCE )
+ break()
+ else()
+ message( STATUS "Testing default ${_TYPE_NAME}*${__TEST_SIZE} -" )
endif()
endforeach()
+
+endmacro()
+
+
+macro( CHECK_FORTRAN_TYPE_SIZES )
+ if( NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90 )
+ message( FATAL_ERROR "Type size tests require Fortran 90 support" )
+ endif()
+
+ _CHECK_FORTRAN_TYPE_SIZE( "INTEGER" "2;4;8;16" )
+ _CHECK_FORTRAN_TYPE_SIZE( "REAL" "4;8;12;16" )
+ _CHECK_FORTRAN_TYPE_SIZE( "LOGICAL" "1;2;4;8;16" )
+ _CHECK_FORTRAN_TYPE_SIZE( "CHARACTER" "1;2;4;8;16" )
endmacro()