New in version 3.19.
Activates dependency optimization of static and object libraries.
When this property is set to true, some dependencies for a static or object library may be removed at generation time if they are not necessary to build the library, since static and object libraries don’t actually link against anything.
If a static or object library has dependency optimization enabled, it first discards all dependencies. Then, it looks through all of the direct and indirect dependencies that it initially had, and adds them back if they meet any of the following criteria:
add_dependencies()
.PRE_BUILD
, PRE_LINK
, or POST_BUILD
custom commands associated with it.As an example, assume you have a static Fortran library which depends on a static C library, which in turn depends on a static Fortran library. The top-level Fortran library has optimization enabled, but the middle C library does not. If you build the top Fortran library, the bottom Fortran library will also build, but not the middle C library, since the C library does not have any side effects that are relevant for the Fortran library. However, if you build the middle C library, the bottom Fortran library will also build, even though it does not have any side effects that are relevant to the C library, since the C library does not have optimization enabled.
© 2000–2020 Kitware, Inc. and Contributors
Licensed under the BSD 3-clause License.
https://cmake.org/cmake/help/v3.19/prop_tgt/OPTIMIZE_DEPENDENCIES.html