Commit b6917337 authored by Chuck Atkins's avatar Chuck Atkins
Browse files

Speedup dependency resolution and installation for the sdk

Large list appending with hundreds of duplicate entries is a
significant performance bottleneck in CMake.  This keeps the
dependency list for each library in a separate variable and only
combines them at the end, removing duplicates as it goes.
parent d423d75c
......@@ -171,7 +171,12 @@ set(dependency_search_paths
list(SORT libraries_to_install)
foreach (fname IN LISTS libraries_to_install binaries_to_install)
get_filename_component(fname "${fname}" ABSOLUTE)
get_filename_component(fname_dir "${fname}" DIRECTORY)
get_filename_component(fname_dir_real "${fname_dir}" REALPATH)
......@@ -220,39 +225,51 @@ foreach (fname IN LISTS libraries_to_install binaries_to_install)
endif ()
endif ()
# The TBB libraries are special.
if (fname MATCHES "libtbb(|_malloc)")
continue ()
endif ()
# We still want to install a symlink but only perform dependency resolution
# on actual files.
if (IS_SYMLINK "${fname}")
continue ()
endif ()
message("Gathering dependencies for ${fname}")
get_prerequisites("${fname}" dependencies 1 1 "" "${dependency_search_paths}")
if (NOT dependencies)
continue ()
endif ()
get_filename_component(fname_base "${fname}" NAME_WE)
list(APPEND fname_dep_map ${fname_base}_deps)
foreach (dep IN LISTS dependencies)
if (IS_SYMLINK "${dep}")
# Symlinks better not cross the root directory. Bad install, bad.
get_filename_component(resolved_dep "${dep}" REALPATH)
list(APPEND all_binaries "${resolved_dep}")
list(APPEND ${fname_base}_deps "${resolved_dep}")
endif ()
list(APPEND all_binaries "${dep}")
list(APPEND ${fname_base}_deps "${dep}")
endforeach ()
endforeach ()
if (all_binaries)
list(REMOVE_DUPLICATES all_binaries)
endif ()
foreach (f IN LISTS all_binaries)
message("Combining and collapsing dependencies")
foreach (fname_dep_var IN LISTS fname_dep_map)
foreach (dep IN LISTS ${fname_dep_var})
list(APPEND all_deps "${dep}")
endforeach ()
if (all_deps)
list(REMOVE_DUPLICATES all_deps)
endif ()
endforeach ()
message("Building install rules for dependencies")
foreach(dep IN LISTS all_deps)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment