summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineFortranCompiler.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2006-08-29 17:59:15 (GMT)
committerBrad King <brad.king@kitware.com>2006-08-29 17:59:15 (GMT)
commit7001a88a746073a46200dde7c6613789cf4b9cc8 (patch)
tree3e9eda6caa4872c168c23882e63f0ec726169588 /Modules/CMakeDetermineFortranCompiler.cmake
parentbdb530191dba75f8b358367d6da9dd8aa8e763e3 (diff)
downloadCMake-7001a88a746073a46200dde7c6613789cf4b9cc8.zip
CMake-7001a88a746073a46200dde7c6613789cf4b9cc8.tar.gz
CMake-7001a88a746073a46200dde7c6613789cf4b9cc8.tar.bz2
BUG: Search for the compiler only once and store a full path to it in the cache. This avoids problems with the case of locations in the PATH variable on Windows that change the compiler name when CMake is re-run. CMakeFiles/CMake*Compiler.cmake files should hold the full path to the compiler always.
Diffstat (limited to 'Modules/CMakeDetermineFortranCompiler.cmake')
-rw-r--r--Modules/CMakeDetermineFortranCompiler.cmake29
1 files changed, 15 insertions, 14 deletions
diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake
index edec369..eaa7f0d 100644
--- a/Modules/CMakeDetermineFortranCompiler.cmake
+++ b/Modules/CMakeDetermineFortranCompiler.cmake
@@ -24,11 +24,11 @@ IF(NOT CMAKE_Fortran_COMPILER)
SET(CMAKE_Fortran_COMPILER_INIT ${CMAKE_GENERATOR_FC})
ENDIF(NOT CMAKE_Fortran_COMPILER_INIT)
ENDIF(CMAKE_GENERATOR_FC)
-
-
- # if no compiler has been specified yet, then look for one
- IF(NOT CMAKE_Fortran_COMPILER_INIT)
- # if not in the envionment then search for the compiler in the path
+
+ # finally list compilers to try
+ IF(CMAKE_Fortran_COMPILER_INIT)
+ SET(CMAKE_Fortran_COMPILER_LIST ${CMAKE_Fortran_COMPILER_INIT})
+ ELSE(CMAKE_Fortran_COMPILER_INIT)
# Known compilers:
# f77/f90/f95: generic compiler names
# g77: GNU Fortran 77 compiler
@@ -51,16 +51,17 @@ IF(NOT CMAKE_Fortran_COMPILER)
# NOTE for testing purposes this list is DUPLICATED in
# CMake/Source/CMakeLists.txt, IF YOU CHANGE THIS LIST,
# PLEASE UPDATE THAT FILE AS WELL!
- SET(CMAKE_Fortran_COMPILER_LIST ifort ifc efc f95 pgf95
- lf95 xlf95 fort gfortran f90 pgf90 xlf90 epcf90 fort77 frt pgf77 xlf fl32 af77 g77 f77 )
- FIND_PROGRAM(CMAKE_Fortran_COMPILER_FULLPATH NAMES ${CMAKE_Fortran_COMPILER_LIST} )
- GET_FILENAME_COMPONENT(CMAKE_Fortran_COMPILER_INIT
- ${CMAKE_Fortran_COMPILER_FULLPATH} NAME)
- SET(CMAKE_Fortran_COMPILER_FULLPATH "${CMAKE_Fortran_COMPILER_FULLPATH}"
- CACHE INTERNAL "full path to the compiler cmake found")
- ENDIF(NOT CMAKE_Fortran_COMPILER_INIT)
+ SET(CMAKE_Fortran_COMPILER_LIST
+ ifort ifc efc f95 pgf95 lf95 xlf95 fort gfortran f90
+ pgf90 xlf90 epcf90 fort77 frt pgf77 xlf fl32 af77 g77 f77
+ )
+ ENDIF(CMAKE_Fortran_COMPILER_INIT)
- SET(CMAKE_Fortran_COMPILER ${CMAKE_Fortran_COMPILER_INIT} CACHE STRING "Fortran compiler")
+ # Find the compiler.
+ FIND_PROGRAM(CMAKE_Fortran_COMPILER NAMES ${CMAKE_Fortran_COMPILER_LIST} DOC "Fortran compiler")
+ IF(CMAKE_Fortran_COMPILER_INIT AND NOT CMAKE_Fortran_COMPILER)
+ SET(CMAKE_Fortran_COMPILER "${CMAKE_Fortran_COMPILER_INIT}" CACHE FILEPATH "Fortran compiler" FORCE)
+ ENDIF(CMAKE_Fortran_COMPILER_INIT AND NOT CMAKE_Fortran_COMPILER)
ENDIF(NOT CMAKE_Fortran_COMPILER)
MARK_AS_ADVANCED(CMAKE_Fortran_COMPILER)