INTERFACE_LINK_LIBRARIES_WARNING.txt 1.0 KB

1234567891011121314151617181920212223
  1. Note that it is not advisable to populate the
  2. |INTERFACE_PROPERTY_LINK| of a target with paths for dependencies.
  3. That would hard-code into installed packages the include directory paths
  4. for dependencies **as found on the machine the package was made on**.
  5. That is, code like this is incorrect for targets which will be used to
  6. generate :manual:`cmake-packages(7)`:
  7. .. code-block:: cmake
  8. target_link_libraries(mylib INTERFACE
  9. ${Boost_LIBRARIES};${OtherDep_LIBRARIES}
  10. )
  11. Dependencies must provide their own :ref:`IMPORTED targets <Imported Targets>`
  12. which have their own :prop_tgt:`IMPORTED_LOCATION` populated
  13. appropriately. That way, when a consumer uses the installed package, the
  14. consumer will run the appropriate :command:`find_package` command to find
  15. the dependencies on their own machine and populate the
  16. :ref:`IMPORTED targets <Imported Targets>` with appropriate paths. See
  17. :ref:`Creating Packages` for more. Note that many modules currently shipped
  18. with CMake do not currently provide :ref:`IMPORTED targets <Imported Targets>`.