diff options
author | Brad King <brad.king@kitware.com> | 2009-10-06 19:16:12 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-10-06 19:16:12 (GMT) |
commit | b9850a614e62e5efbfcb520286f87f60002c09d1 (patch) | |
tree | 7ddd881c8404ff44883b802669f2dc100ba91d3f | |
parent | 80533948b287cd26ec27cdfc29e76aad1ad38186 (diff) | |
download | CMake-b9850a614e62e5efbfcb520286f87f60002c09d1.zip CMake-b9850a614e62e5efbfcb520286f87f60002c09d1.tar.gz CMake-b9850a614e62e5efbfcb520286f87f60002c09d1.tar.bz2 |
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.
-rw-r--r-- | Modules/CMakeDetermineCompilerABI.cmake | 4 | ||||
-rw-r--r-- | Modules/CMakeParseImplicitLinkInfo.cmake | 22 | ||||
-rw-r--r-- | Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in | 4 |
3 files changed, 27 insertions, 3 deletions
diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 872e9ab..c8f4c99 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -66,7 +66,9 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src) AND NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES ";" # Skip this with Xcode for now. 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() SET(CMAKE_${lang}_IMPLICIT_LINK_LIBRARIES "${implicit_libs}" PARENT_SCOPE) SET(CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES "${implicit_dirs}" PARENT_SCOPE) diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake index d0bbc8c..9cab2de 100644 --- a/Modules/CMakeParseImplicitLinkInfo.cmake +++ b/Modules/CMakeParseImplicitLinkInfo.cmake @@ -16,9 +16,10 @@ # This is used internally by CMake and should not be included by user # 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_dirs_tmp) + set(log "") # Parse implicit linker arguments. 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) endif() if("${cmd}" MATCHES "${linker_regex}") + set(log "${log} link line: [${line}]\n") string(REGEX REPLACE ";-([LYz]);" ";-\\1" args "${args}") foreach(arg IN LISTS args) if("${arg}" MATCHES "^-L(.:)?[/\\]") # Unix search path. string(REGEX REPLACE "^-L" "" dir "${arg}") list(APPEND implicit_dirs_tmp ${dir}) + set(log "${log} arg [${arg}] ==> dir [${dir}]\n") elseif("${arg}" MATCHES "^-l[^:]") # Unix library. string(REGEX REPLACE "^-l" "" lib "${arg}") list(APPEND implicit_libs ${lib}) + set(log "${log} arg [${arg}] ==> lib [${lib}]\n") elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.a$") # Unix library full path. list(APPEND implicit_libs ${arg}) + set(log "${log} arg [${arg}] ==> lib [${arg}]\n") elseif("${arg}" MATCHES "^-Y(P,)?") # Sun search path. string(REGEX REPLACE "^-Y(P,)?" "" dirs "${arg}") string(REPLACE ":" ";" dirs "${dirs}") list(APPEND implicit_dirs_tmp ${dirs}) + set(log "${log} arg [${arg}] ==> dirs [${dirs}]\n") elseif("${arg}" MATCHES "^-l:") # HP named library. list(APPEND implicit_libs ${arg}) + set(log "${log} arg [${arg}] ==> lib [${arg}]\n") elseif("${arg}" MATCHES "^-z(all|default|weak)extract") # Link editor option. list(APPEND implicit_libs ${arg}) + set(log "${log} arg [${arg}] ==> opt [${arg}]\n") + else() + set(log "${log} arg [${arg}] ==> ignore\n") endif() endforeach() break() elseif("${line}" MATCHES "LPATH(=| is:? )") + set(log "${log} LPATH line: [${line}]\n") # HP search path. string(REGEX REPLACE ".*LPATH(=| is:? *)" "" paths "${line}") string(REPLACE ":" ";" paths "${paths}") list(APPEND implicit_dirs_tmp ${paths}) + set(log "${log} dirs [${paths}]\n") + else() + set(log "${log} ignore line: [${line}]\n") endif() endforeach() @@ -78,10 +92,16 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var) foreach(d IN LISTS implicit_dirs_tmp) get_filename_component(dir "${d}" ABSOLUTE) list(APPEND implicit_dirs "${dir}") + set(log "${log} collapse dir [${d}] ==> [${dir}]\n") endforeach() 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. set(${lib_var} "${implicit_libs}" PARENT_SCOPE) set(${dir_var} "${implicit_dirs}" PARENT_SCOPE) + set(${log_var} "${log}" PARENT_SCOPE) endfunction() diff --git a/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in index a549135..eba98a2 100644 --- a/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in +++ b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in @@ -339,7 +339,7 @@ list(APPEND platforms msys_g77) # Test parsing for all above examples. 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) if(NOT "${${v}}" STREQUAL "${${p}_${v}}") @@ -349,6 +349,8 @@ foreach(p IN LISTS platforms) " [${${p}_${v}}]\n" "but got\n" " [${${v}}]\n" + "Parse log was:\n" + "${log}" ) endif() endforeach() |