Browse Source

Log implicit link information parsing actions

This commit teaches the CMAKE_PARSE_IMPLICIT_LINK_INFO function to log
its actions.  We store the log in CMakeFiles/CMakeOutput.log at the top
of the project build tree.  This will make diagnosis of implicit link
information parsing problems easier.
Brad King 16 years ago
parent
commit
b9850a614e

+ 3 - 1
Modules/CMakeDetermineCompilerABI.cmake

@@ -66,7 +66,9 @@ 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)
+        CMAKE_PARSE_IMPLICIT_LINK_INFO("${OUTPUT}" implicit_libs implicit_dirs log)
+        FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+          "Parsed ${lang} implicit link information from above output:\n${log}\n\n")
       ENDIF()
       ENDIF()
       SET(CMAKE_${lang}_IMPLICIT_LINK_LIBRARIES "${implicit_libs}" PARENT_SCOPE)
       SET(CMAKE_${lang}_IMPLICIT_LINK_LIBRARIES "${implicit_libs}" PARENT_SCOPE)
       SET(CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES "${implicit_dirs}" PARENT_SCOPE)
       SET(CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES "${implicit_dirs}" PARENT_SCOPE)

+ 21 - 1
Modules/CMakeParseImplicitLinkInfo.cmake

@@ -16,9 +16,10 @@
 # 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)
+function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var log_var)
   set(implicit_libs "")
   set(implicit_libs "")
   set(implicit_dirs_tmp)
   set(implicit_dirs_tmp)
+  set(log "")
 
 
   # Parse implicit linker arguments.
   # Parse implicit linker arguments.
   set(linker "CMAKE_LINKER-NOTFOUND")
   set(linker "CMAKE_LINKER-NOTFOUND")
@@ -38,38 +39,51 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var)
       list(GET args 0 cmd)
       list(GET args 0 cmd)
     endif()
     endif()
     if("${cmd}" MATCHES "${linker_regex}")
     if("${cmd}" MATCHES "${linker_regex}")
+      set(log "${log}  link line: [${line}]\n")
       string(REGEX REPLACE ";-([LYz]);" ";-\\1" args "${args}")
       string(REGEX REPLACE ";-([LYz]);" ";-\\1" args "${args}")
       foreach(arg IN LISTS args)
       foreach(arg IN LISTS args)
         if("${arg}" MATCHES "^-L(.:)?[/\\]")
         if("${arg}" MATCHES "^-L(.:)?[/\\]")
           # Unix search path.
           # Unix search path.
           string(REGEX REPLACE "^-L" "" dir "${arg}")
           string(REGEX REPLACE "^-L" "" dir "${arg}")
           list(APPEND implicit_dirs_tmp ${dir})
           list(APPEND implicit_dirs_tmp ${dir})
+          set(log "${log}    arg [${arg}] ==> dir [${dir}]\n")
         elseif("${arg}" MATCHES "^-l[^:]")
         elseif("${arg}" MATCHES "^-l[^:]")
           # Unix library.
           # Unix library.
           string(REGEX REPLACE "^-l" "" lib "${arg}")
           string(REGEX REPLACE "^-l" "" lib "${arg}")
           list(APPEND implicit_libs ${lib})
           list(APPEND implicit_libs ${lib})
+          set(log "${log}    arg [${arg}] ==> lib [${lib}]\n")
         elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.a$")
         elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.a$")
           # Unix library full path.
           # Unix library full path.
           list(APPEND implicit_libs ${arg})
           list(APPEND implicit_libs ${arg})
+          set(log "${log}    arg [${arg}] ==> lib [${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}")
           string(REPLACE ":" ";" dirs "${dirs}")
           string(REPLACE ":" ";" dirs "${dirs}")
           list(APPEND implicit_dirs_tmp ${dirs})
           list(APPEND implicit_dirs_tmp ${dirs})
+          set(log "${log}    arg [${arg}] ==> dirs [${dirs}]\n")
         elseif("${arg}" MATCHES "^-l:")
         elseif("${arg}" MATCHES "^-l:")
           # HP named library.
           # HP named library.
           list(APPEND implicit_libs ${arg})
           list(APPEND implicit_libs ${arg})
+          set(log "${log}    arg [${arg}] ==> lib [${arg}]\n")
         elseif("${arg}" MATCHES "^-z(all|default|weak)extract")
         elseif("${arg}" MATCHES "^-z(all|default|weak)extract")
           # Link editor option.
           # Link editor option.
           list(APPEND implicit_libs ${arg})
           list(APPEND implicit_libs ${arg})
+          set(log "${log}    arg [${arg}] ==> opt [${arg}]\n")
+        else()
+          set(log "${log}    arg [${arg}] ==> ignore\n")
         endif()
         endif()
       endforeach()
       endforeach()
       break()
       break()
     elseif("${line}" MATCHES "LPATH(=| is:? )")
     elseif("${line}" MATCHES "LPATH(=| is:? )")
+      set(log "${log}  LPATH line: [${line}]\n")
       # HP search path.
       # HP search path.
       string(REGEX REPLACE ".*LPATH(=| is:? *)" "" paths "${line}")
       string(REGEX REPLACE ".*LPATH(=| is:? *)" "" paths "${line}")
       string(REPLACE ":" ";" paths "${paths}")
       string(REPLACE ":" ";" paths "${paths}")
       list(APPEND implicit_dirs_tmp ${paths})
       list(APPEND implicit_dirs_tmp ${paths})
+      set(log "${log}    dirs [${paths}]\n")
+    else()
+      set(log "${log}  ignore line: [${line}]\n")
     endif()
     endif()
   endforeach()
   endforeach()
 
 
@@ -78,10 +92,16 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var)
   foreach(d IN LISTS implicit_dirs_tmp)
   foreach(d IN LISTS implicit_dirs_tmp)
     get_filename_component(dir "${d}" ABSOLUTE)
     get_filename_component(dir "${d}" ABSOLUTE)
     list(APPEND implicit_dirs "${dir}")
     list(APPEND implicit_dirs "${dir}")
+    set(log "${log}  collapse dir [${d}] ==> [${dir}]\n")
   endforeach()
   endforeach()
   list(REMOVE_DUPLICATES implicit_dirs)
   list(REMOVE_DUPLICATES implicit_dirs)
 
 
+  # Log results.
+  set(log "${log}  implicit libs: [${implicit_libs}]\n")
+  set(log "${log}  implicit dirs: [${implicit_dirs}]\n")
+
   # Return results.
   # Return results.
   set(${lib_var} "${implicit_libs}" PARENT_SCOPE)
   set(${lib_var} "${implicit_libs}" PARENT_SCOPE)
   set(${dir_var} "${implicit_dirs}" PARENT_SCOPE)
   set(${dir_var} "${implicit_dirs}" PARENT_SCOPE)
+  set(${log_var} "${log}" PARENT_SCOPE)
 endfunction()
 endfunction()

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

@@ -339,7 +339,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)
+  cmake_parse_implicit_link_info("${${p}_text}" libs dirs log)
 
 
   foreach(v libs dirs)
   foreach(v libs dirs)
     if(NOT "${${v}}" STREQUAL "${${p}_${v}}")
     if(NOT "${${v}}" STREQUAL "${${p}_${v}}")
@@ -349,6 +349,8 @@ foreach(p IN LISTS platforms)
         "  [${${p}_${v}}]\n"
         "  [${${p}_${v}}]\n"
         "but got\n"
         "but got\n"
         "  [${${v}}]\n"
         "  [${${v}}]\n"
+        "Parse log was:\n"
+        "${log}"
         )
         )
     endif()
     endif()
   endforeach()
   endforeach()