Files
CMake/Tests/RunCMake/DependencyGraph/WriteTargets.cmake
Kyle Edwards 2e42651dff 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.
2020-08-12 11:31:07 -04:00

17 lines
676 B
CMake

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()