UseSWIG: remove duplicate directory includes
This changeset simply removes duplicate -I
entries from target-propagated includes (with the USE_TARGET_INCLUDE_DIRECTORIES
source file property) in the SWIG command.
The motivation is that our project (SCALE) recently encountered a build failure while trying to generate SWIG wrappers for a library that was downstream of almost everything in our codebase:
execvp: /bin/sh: Argument list too long
The problem is that the TriBITS build system links each library publicly against all N
upstream dependencies, each of which is linked against up to N-1
upstream deps. It seems that $<TARGET_PROPERTY:${target_name},INCLUDE_DIRECTORIES>
does not automatically deduplicate include transitive directory includes, so the SWIG link line can contain at worst O(N^2)
include commands pointing to N
include dirs.
It may be worth examining whether the TARGET_PROPERTY
command itself should automatically do the deduplication. Until then, this provides an easy fix.
See https://gitlab.kitware.com/sethrj/swig-include-dirs for a demonstration of the difference. With 32 libraries, each of which links against all parents:
Words in COMMAND before fix:
553
Words in COMMAND after fix:
58