[CMake] try_compile() to determine the largest available Fortran integer
Williams, Norman K
norman-k-williams at uiowa.edu
Thu Oct 3 10:53:17 EDT 2013
CMake string literals can contain newlines, so the version below is
more succinct and easier to read.
In this case everything works perfectly. If you have to include strings
that look like variables to expand (e.g. ${THIS} ) you have to be careful
about using escapes.
In that particular case just escaping the '$' would suppress the variable
expansion.
macro(Fortran_biggest_int)
message(STATUS "Checking for the largest available Fortran integer..")
set(filename ${CMAKE_BINARY_DIR}/getbigint.f90)
file(WRITE ${filename} "program getbigint
implicit none
integer ,parameter :: DEFAULT = kind(1) , DEF_RANGE = range(kind(1))
integer :: r, ktmp, k
r = DEF_RANGE
k = DEFAULT
do
r = r + 1
ktmp = selected_int_kind(r)
if ( ktmp == -1 ) exit
k = ktmp
end do
write(*,'(i0)') k
end program
")
try_run(BIG_INT_COMPILES BIG_INT_RUNS
${CMAKE_BINARY_DIR} ${filename}
RUN_OUTPUT_VARIABLE FBIGINT)
message(STATUS "Fortran big integer kind: ${FBIGINT}")
endmacro()
________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error, then delete it. Thank you.
________________________________
More information about the CMake
mailing list