Explorar o código

Detect object files in implicit link information

The NAG Fortran compiler implicitly passes object files by full path to
the linker.  Teach CMakeParseImplicitLinkInfo to parse object files that
match some tool-specific regular expression.
Brad King %!s(int64=15) %!d(string=hai) anos
pai
achega
fe3f878f15

+ 2 - 1
Modules/CMakeDetermineCompilerABI.cmake

@@ -64,7 +64,8 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src)
           AND NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES ";"
           AND NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES ";"
           # Skip this with Xcode for now.
           # Skip this with Xcode for now.
           AND NOT "${CMAKE_GENERATOR}" MATCHES Xcode)
           AND NOT "${CMAKE_GENERATOR}" MATCHES Xcode)
-        CMAKE_PARSE_IMPLICIT_LINK_INFO("${OUTPUT}" implicit_libs implicit_dirs log)
+        CMAKE_PARSE_IMPLICIT_LINK_INFO("${OUTPUT}" implicit_libs implicit_dirs log
+          "${CMAKE_${lang}_IMPLICIT_OBJECT_REGEX}")
         FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
           "Parsed ${lang} implicit link information from above output:\n${log}\n\n")
           "Parsed ${lang} implicit link information from above output:\n${log}\n\n")
       ENDIF()
       ENDIF()

+ 6 - 1
Modules/CMakeParseImplicitLinkInfo.cmake

@@ -16,7 +16,7 @@
 # This is used internally by CMake and should not be included by user
 # This is used internally by CMake and should not be included by user
 # code.
 # code.
 
 
-function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var log_var)
+function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var log_var obj_regex)
   set(implicit_libs_tmp "")
   set(implicit_libs_tmp "")
   set(implicit_dirs_tmp)
   set(implicit_dirs_tmp)
   set(log "")
   set(log "")
@@ -59,6 +59,11 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var log_var)
           # Unix library full path.
           # Unix library full path.
           list(APPEND implicit_libs_tmp ${arg})
           list(APPEND implicit_libs_tmp ${arg})
           set(log "${log}    arg [${arg}] ==> lib [${arg}]\n")
           set(log "${log}    arg [${arg}] ==> lib [${arg}]\n")
+        elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.o$"
+            AND obj_regex AND "${arg}" MATCHES "${obj_regex}")
+          # Object file full path.
+          list(APPEND implicit_libs_tmp ${arg})
+          set(log "${log}    arg [${arg}] ==> obj [${arg}]\n")
         elseif("${arg}" MATCHES "^-Y(P,)?")
         elseif("${arg}" MATCHES "^-Y(P,)?")
           # Sun search path.
           # Sun search path.
           string(REGEX REPLACE "^-Y(P,)?" "" dirs "${arg}")
           string(REGEX REPLACE "^-Y(P,)?" "" dirs "${arg}")

+ 8 - 1
Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in

@@ -77,6 +77,13 @@ set(linux64_pgf90_libs "pgf90;pgf90_rpm1;pgf902;pgf90rtl;pgftnrtl;nspgc;pgc;rt;p
 set(linux64_pgf90_dirs "/opt/compiler/pgi/linux86-64/8.0-3/lib;/usr/lib64;/usr/lib64/gcc/x86_64-suse-linux/4.1.2")
 set(linux64_pgf90_dirs "/opt/compiler/pgi/linux86-64/8.0-3/lib;/usr/lib64;/usr/lib64/gcc/x86_64-suse-linux/4.1.2")
 list(APPEND platforms linux64_pgf90)
 list(APPEND platforms linux64_pgf90)
 
 
+# nagfor dummy.f -Wl,-v
+set(linux64_nagfor_text " /usr/libexec/gcc/x86_64-redhat-linux/4.4.5/collect2 --no-add-needed --eh-frame-hdr --build-id -m elf_x86_64 --hash-style=gnu -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/lib/gcc/x86_64-redhat-linux/4.4.5/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/4.4.5/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/4.4.5/crtbegin.o -L/usr/lib/gcc/x86_64-redhat-linux/4.4.5 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.5 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.5/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.5/../../.. /usr/local/NAG/lib/f90_init.o /usr/local/NAG/lib/quickfit.o dummy.o -rpath /usr/local/NAG/lib /usr/local/NAG/lib/libf53.so /usr/local/NAG/lib/libf53.a -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-redhat-linux/4.4.5/crtend.o /usr/lib/gcc/x86_64-redhat-linux/4.4.5/../../../../lib64/crtn.o")
+set(linux64_nagfor_libs "/usr/local/NAG/lib/f90_init.o;/usr/local/NAG/lib/quickfit.o;/usr/local/NAG/lib/libf53.a;m;c")
+set(linux64_nagfor_dirs "/usr/lib/gcc/x86_64-redhat-linux/4.4.5;/usr/lib64;/lib64;/usr/lib")
+set(linux64_nagfor_obj_regex "^/usr/local/NAG/lib")
+list(APPEND platforms linux64_nagfor)
+
 # gcc dummy.c -v # in strange path
 # gcc dummy.c -v # in strange path
 set(linux64_test1_text "
 set(linux64_test1_text "
 /this/might/match/as/a/linker/ld/but/it/is/not because the ld is not the last path component
 /this/might/match/as/a/linker/ld/but/it/is/not because the ld is not the last path component
@@ -380,7 +387,7 @@ list(APPEND platforms msys_g77)
 # Test parsing for all above examples.
 # Test parsing for all above examples.
 
 
 foreach(p IN LISTS platforms)
 foreach(p IN LISTS platforms)
-  cmake_parse_implicit_link_info("${${p}_text}" libs dirs log)
+  cmake_parse_implicit_link_info("${${p}_text}" libs dirs log "${${p}_obj_regex}")
 
 
   foreach(v libs dirs)
   foreach(v libs dirs)
     if(NOT "${${v}}" STREQUAL "${${p}_${v}}")
     if(NOT "${${v}}" STREQUAL "${${p}_${v}}")