diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2020-07-29 18:19:56 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-08-12 15:31:07 (GMT) |
commit | 2e42651dff43c4e962f03fc24281cbf446880ded (patch) | |
tree | 5a1fa6f2098d9cb5bdc04c7f9285dc454c3a5ebf /Tests/RunCMake/DependencyGraph/WriteTargets.cmake | |
parent | 0cd3b5d0ca8d541fc3769f467db71a07a95be7f6 (diff) | |
download | CMake-2e42651dff43c4e962f03fc24281cbf446880ded.zip CMake-2e42651dff43c4e962f03fc24281cbf446880ded.tar.gz CMake-2e42651dff43c4e962f03fc24281cbf446880ded.tar.bz2 |
Add option to optimize link dependencies for static libraries
Add an `OPTIMIZE_DEPENDENCIES` target property and supporting
`CMAKE_OPTIMIZE_DEPENDENCIES` variable to optionally enable pruning and
flattening of outgoing dependencies from static libraries. Since they
do not actually link, they only depend on side effects of their
dependencies. Therefore we can drop dependencies that contribute no
side effects.
Diffstat (limited to 'Tests/RunCMake/DependencyGraph/WriteTargets.cmake')
-rw-r--r-- | Tests/RunCMake/DependencyGraph/WriteTargets.cmake | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Tests/RunCMake/DependencyGraph/WriteTargets.cmake b/Tests/RunCMake/DependencyGraph/WriteTargets.cmake new file mode 100644 index 0000000..e1012c1 --- /dev/null +++ b/Tests/RunCMake/DependencyGraph/WriteTargets.cmake @@ -0,0 +1,16 @@ +function(write_targets) + set(_input "") + + get_property(_targets DIRECTORY . PROPERTY BUILDSYSTEM_TARGETS) + foreach(_t IN LISTS _targets) + get_property(_type TARGET "${_t}" PROPERTY TYPE) + if(_type STREQUAL "SHARED_LIBRARY") + string(APPEND _input "set(${_t}_TARGET_FILE [==[$<TARGET_FILE:${_t}>]==])\n") + string(APPEND _input "set(${_t}_TARGET_LINKER_FILE [==[$<TARGET_LINKER_FILE:${_t}>]==])\n") + elseif(_type STREQUAL "STATIC_LIBRARY") + string(APPEND _input "set(${_t}_TARGET_FILE [==[$<TARGET_FILE:${_t}>]==])\n") + endif() + endforeach() + + file(GENERATE OUTPUT target_files.cmake CONTENT "${_input}" CONDITION $<CONFIG:Release>) +endfunction() |