summaryrefslogtreecommitdiff
path: root/CMAKE/CheckFortranIntSize.cmake
diff options
context:
space:
mode:
authorjulie <julielangou@users.noreply.github.com>2010-12-30 22:14:10 (GMT)
committerjulie <julielangou@users.noreply.github.com>2010-12-30 22:14:10 (GMT)
commitc541fcd90981835c8ad1accd9e5e0fbeb1f65f03 (patch)
tree2b5d08b2945bc64f24a1df54060d4cd1a8791edc /CMAKE/CheckFortranIntSize.cmake
parent3e21518c0e33aa5316e5ca4ba64955bc851b78c9 (diff)
downloadlapack-c541fcd90981835c8ad1accd9e5e0fbeb1f65f03.zip
lapack-c541fcd90981835c8ad1accd9e5e0fbeb1f65f03.tar.gz
lapack-c541fcd90981835c8ad1accd9e5e0fbeb1f65f03.tar.bz2
1. Adjusted regex checks in CheckLAPACKCompilerFlags.cmake to be more compact
2. Added CheckFortranIntSize.cmake to auto-determine the default integer size 3. Added more auto-detection features using integer size and compiler checks in FindBLAS.cmake - Chuck Atkins (Kitware)
Diffstat (limited to 'CMAKE/CheckFortranIntSize.cmake')
-rw-r--r--CMAKE/CheckFortranIntSize.cmake60
1 files changed, 60 insertions, 0 deletions
diff --git a/CMAKE/CheckFortranIntSize.cmake b/CMAKE/CheckFortranIntSize.cmake
new file mode 100644
index 0000000..d575e2e
--- /dev/null
+++ b/CMAKE/CheckFortranIntSize.cmake
@@ -0,0 +1,60 @@
+# This module perdorms several try-compiles to determine the default integer
+# size being used by the fortran compiler
+#
+# After execution, the following variable is set:
+#
+# SIZEOF_INTEGER - Number of bytes used to store the default integer type
+# Will be set to 1, 2, 4, 8 or 16 if successful, otherwise it
+# will be unset
+#
+#=============================================================================
+# Author: Chuck Atkins
+# Copyright 2010
+#=============================================================================
+
+macro( CHECK_FORTRAN_INT_SIZE )
+ if( NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90 )
+ message( FATAL_ERROR "Type size tests require Fortran 90 support" )
+ endif()
+ if( NOT SIZEOF_INTEGER )
+ foreach( _TEST_SIZE 1 2 4 8 16 )
+ message( STATUS "Testing default integer*${_TEST_SIZE} - " )
+ set( _TEST_FILE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranInteger${_TEST_SIZE}.f90 )
+ file( WRITE ${_TEST_FILE} "
+ module check_int_size
+ interface int_size
+ function int_size_${_TEST_SIZE}(a) result(int_size)
+ integer*${_TEST_SIZE} a
+ integer int_size
+ end function int_size_${_TEST_SIZE}
+ end interface
+ end module
+
+ program check_int_size_${_TEST_SIZE}
+ use check_int_size
+ integer a, b
+ a = 7
+ b = int_size(a)
+ end program
+
+ function int_size_${_TEST_SIZE}(a) result(int_size)
+ integer*4 a
+ int_size = 7
+ end function
+ ")
+ try_compile( SIZEOF_INTEGER ${CMAKE_BINARY_DIR} ${_TEST_FILE} )
+ if( SIZEOF_INTEGER )
+ message( STATUS "Testing default integer*${_TEST_SIZE} - found" )
+ set( SIZEOF_INTEGER ${_TEST_SIZE} CACHE INTERNAL "Size of the default INTEGER type" FORCE )
+ break()
+ else()
+ message( STATUS "Testing default integer*${_TEST_SIZE} - not found" )
+ endif()
+ endforeach()
+ endif()
+
+ if( NOT SIZEOF_INTEGER )
+ unset( SIZEOF_INTEGER )
+ endif()
+endmacro()
+