1 # This module perdorms several try-compiles to determine the default integer
2 # size being used by the fortran compiler
4 # After execution, the following variables are set. If they are un set then
5 # size detection was not possible
7 # SIZEOF_INTEGER - Number of bytes used to store the default INTEGER type
8 # SIZEOF_REAL - Number of bytes used to store the default REAL type
9 # SIZEOF_LOGICAL - Number of bytes used to store the default LOGICAL type
10 # SIZEOF_CHARACTER - Number of bytes used to store the default CHARACTER type
12 #=============================================================================
13 # Author: Chuck Atkins
15 #=============================================================================
17 # Check the size of a single fortran type
18 macro( _CHECK_FORTRAN_TYPE_SIZE _TYPE_NAME _TEST_SIZES )
20 foreach( __TEST_SIZE ${_TEST_SIZES} )
21 set( __TEST_FILE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortran${_TYPE_NAME}Size${__TEST_SIZE}.f90 )
22 file( WRITE ${__TEST_FILE}
25 ${_TYPE_NAME}*${__TEST_SIZE}, TARGET :: a
26 ${_TYPE_NAME}, POINTER :: pa
30 try_compile( SIZEOF_${_TYPE_NAME} ${CMAKE_BINARY_DIR} ${__TEST_FILE} )
31 if( SIZEOF_${_TYPE_NAME} )
32 message( STATUS "Testing default ${_TYPE_NAME}*${__TEST_SIZE} - found" )
33 set( SIZEOF_${_TYPE_NAME} ${__TEST_SIZE} CACHE INTERNAL "Size of the default ${_TYPE_NAME} type" FORCE )
36 message( STATUS "Testing default ${_TYPE_NAME}*${__TEST_SIZE} -" )
43 macro( CHECK_FORTRAN_TYPE_SIZES )
44 if( NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90 )
45 message( FATAL_ERROR "Type size tests require Fortran 90 support" )
48 _CHECK_FORTRAN_TYPE_SIZE( "INTEGER" "2;4;8;16" )
49 _CHECK_FORTRAN_TYPE_SIZE( "REAL" "4;8;12;16" )
50 _CHECK_FORTRAN_TYPE_SIZE( "LOGICAL" "1;2;4;8;16" )
51 _CHECK_FORTRAN_TYPE_SIZE( "CHARACTER" "1;2;4;8;16" )