summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Somerville <bill@classdesign.com>2015-07-29 16:36:38 (GMT)
committerBrad King <brad.king@kitware.com>2015-07-31 13:50:32 (GMT)
commit5d0a8b1abc3f8a6d8d23772251b4ef2758d2def6 (patch)
tree82509636512c869f3820297686fe3f815c2a64c4
parentafb674ab46a7d6ff3d1801315f3d852bdba79d0c (diff)
downloadCMake-5d0a8b1abc3f8a6d8d23772251b4ef2758d2def6.zip
CMake-5d0a8b1abc3f8a6d8d23772251b4ef2758d2def6.tar.gz
CMake-5d0a8b1abc3f8a6d8d23772251b4ef2758d2def6.tar.bz2
GetPrerequisites: Optionally filter "objdump" output for speed
As dumpbin.exe is no longer reliable for gcc libraries on MinGW because it crashes on many common libraries like libgcc_s and libgfortran it is now necessary too resort to using objdump for DLL dependency walking. Using objdump has a secondary problem in that it generates a lot of output for large libraries and causes fixup_bundle() to take many minutes to process what took fractions of a second with "dumpbin.exe /dependents". Add a 'grep' pre-filter in the execute_process() command pipeline to reduce this output to a minimum for a several orders of magnitude speed up. If grep is not available just use the full output. As there does not seem to be a reliable way of detecting MinGW, callers of fixup_bundle() may have to set the variable gp_tool to "objdump" if dumpbin.exe is installed on the build machine to stop it using the broken MS dumpbin.exe for library dependency walking.
-rw-r--r--Modules/GetPrerequisites.cmake8
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake
index a359d2c..e4018b6 100644
--- a/Modules/GetPrerequisites.cmake
+++ b/Modules/GetPrerequisites.cmake
@@ -700,6 +700,8 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
return()
endif()
+ set(gp_cmd_maybe_filter) # optional command to pre-filter gp_tool results
+
if(gp_tool STREQUAL "ldd")
set(gp_cmd_args "")
set(gp_regex "^[\t ]*[^\t ]+ => ([^\t\(]+) .*${eol_char}$")
@@ -724,6 +726,11 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
set(gp_regex_error "")
set(gp_regex_fallback "")
set(gp_regex_cmp_count 1)
+ # objdump generaates copious output so we create a grep filter to pre-filter results
+ find_program(gp_grep_cmd grep)
+ if(gp_grep_cmd)
+ set(gp_cmd_maybe_filter COMMAND ${gp_grep_cmd} "^[[:blank:]]*DLL Name: ")
+ endif()
else()
message(STATUS "warning: gp_tool='${gp_tool}' is an unknown tool...")
message(STATUS "CMake function get_prerequisites needs more code to handle '${gp_tool}'")
@@ -780,6 +787,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
#
execute_process(
COMMAND ${gp_cmd} ${gp_cmd_args} ${target}
+ ${gp_cmd_maybe_filter}
RESULT_VARIABLE gp_rv
OUTPUT_VARIABLE gp_cmd_ov
ERROR_VARIABLE gp_ev