diff options
author | Brad King <brad.king@kitware.com> | 2012-09-12 11:51:28 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2012-09-12 11:51:28 (GMT) |
commit | 49e1819f0f7c4cc6eadc2905c1b382e8e7a877ac (patch) | |
tree | 6e6071028f4a82f267882f1e776dce8cfa81e02e /Modules | |
parent | 442c07ea0a0f49550e1ff5d115b0974d7e066e2c (diff) | |
parent | 7924aacbfa193232465794fed4a1081c0424ef87 (diff) | |
download | CMake-49e1819f0f7c4cc6eadc2905c1b382e8e7a877ac.zip CMake-49e1819f0f7c4cc6eadc2905c1b382e8e7a877ac.tar.gz CMake-49e1819f0f7c4cc6eadc2905c1b382e8e7a877ac.tar.bz2 |
Merge topic 'FortranCrossCompiling3'
7924aac CMakeDetermineFortranCompiler: add support for cross-compiling (#13379)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeDetermineFortranCompiler.cmake | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 051f832..f861e39 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -189,6 +189,32 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN) endif() endif() +if (NOT _CMAKE_TOOLCHAIN_LOCATION) + get_filename_component(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_Fortran_COMPILER}" PATH) +endif () + +# if we have a fortran cross compiler, they have usually some prefix, like +# e.g. powerpc-linux-gfortran, arm-elf-gfortran or i586-mingw32msvc-gfortran , optionally +# with a 3-component version number at the end (e.g. arm-eabi-gcc-4.5.2). +# The other tools of the toolchain usually have the same prefix +# NAME_WE cannot be used since then this test will fail for names lile +# "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be +# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" +if (CMAKE_CROSSCOMPILING + AND "${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU" + AND NOT _CMAKE_TOOLCHAIN_PREFIX) + get_filename_component(COMPILER_BASENAME "${CMAKE_Fortran_COMPILER}" NAME) + if (COMPILER_BASENAME MATCHES "^(.+-)g?fortran(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + endif () + + # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils + # but uses the regular ar, objcopy, etc. (instead of llvm-objcopy etc.) + if ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + endif () +endif () + include(CMakeFindBinUtils) if(MSVC_Fortran_ARCHITECTURE_ID) |