summaryrefslogtreecommitdiffstats
path: root/Modules/Compiler
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2010-12-09 22:12:19 (GMT)
committerBrad King <brad.king@kitware.com>2010-12-09 23:12:34 (GMT)
commitaf2ad90991faea2be0dfe62e456794f46758c92a (patch)
treebb66a00631cd648aeed109cebe3b5b68b309201c /Modules/Compiler
parent24cc3d48174ef7b120491520ceb9f81389dd6b3e (diff)
downloadCMake-af2ad90991faea2be0dfe62e456794f46758c92a.zip
CMake-af2ad90991faea2be0dfe62e456794f46758c92a.tar.gz
CMake-af2ad90991faea2be0dfe62e456794f46758c92a.tar.bz2
Add NAG Fortran compiler information files
On Linux the NAG Fortran compiler uses gcc under the hood to link. Use "-Wl,-v" to pass "-v" to the underlying gcc compiler to get verbose link output. Detect the NAG Fortran directory (using -dryrun) and then honor object files in the directory referenced in the implicit link line. Pass real linker options with "-Wl,-Xlinker,". The -Wl, gets through the NAG front-end and the -Xlinker gets through the gcc front-end.
Diffstat (limited to 'Modules/Compiler')
-rw-r--r--Modules/Compiler/NAG-Fortran.cmake32
1 files changed, 32 insertions, 0 deletions
diff --git a/Modules/Compiler/NAG-Fortran.cmake b/Modules/Compiler/NAG-Fortran.cmake
new file mode 100644
index 0000000..b68c479
--- /dev/null
+++ b/Modules/Compiler/NAG-Fortran.cmake
@@ -0,0 +1,32 @@
+# Help CMAKE_PARSE_IMPLICIT_LINK_INFO detect NAG Fortran object files.
+if(NOT CMAKE_Fortran_COMPILER_WORKS AND NOT CMAKE_Fortran_COMPILER_FORCED)
+ message(STATUS "Detecting NAG Fortran directory")
+ # Run with -dryrun to see sample "link" line.
+ execute_process(
+ COMMAND ${CMAKE_Fortran_COMPILER} dummy.o -dryrun
+ OUTPUT_VARIABLE _dryrun
+ ERROR_VARIABLE _dryrun
+ )
+ # Match an object file.
+ string(REGEX MATCH "/[^ ]*/[^ /][^ /]*\\.o" _nag_obj "${_dryrun}")
+ if(_nag_obj)
+ # Parse object directory and convert to a regex.
+ string(REGEX REPLACE "/[^/]*$" "" _nag_dir "${_nag_obj}")
+ string(REGEX REPLACE "([][+.*()^])" "\\\\\\1" _nag_regex "${_nag_dir}")
+ set(CMAKE_Fortran_IMPLICIT_OBJECT_REGEX "^${_nag_regex}/")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Detecting NAG Fortran directory with -dryrun found\n"
+ " object: ${_nag_obj}\n"
+ " directory: ${_nag_dir}\n"
+ " regex: ${CMAKE_Fortran_IMPLICIT_OBJECT_REGEX}\n"
+ "from output:\n${_dryrun}\n\n")
+ message(STATUS "Detecting NAG Fortran directory - ${_nag_dir}")
+ else()
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Detecting NAG Fortran directory with -dryrun failed:\n${_dryrun}\n\n")
+ message(STATUS "Detecting NAG Fortran directory - failed")
+ endif()
+endif()
+
+set(CMAKE_Fortran_MODDIR_FLAG "-mdir ")
+set(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-PIC")