Skip to content

`INTERFACE_INCLUDE_DIRECTORIES` not populated when installing a framework

On APPLE platforms when installing a framework library target the following way:

install(TARGETS ${PROJECT_NAME}
    EXPORT ${PROJECT_NAME}_Targets
    FRAMEWORK  DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

install(EXPORT ${PROJECT_NAME}_Targets
    NAMESPACE MyNamespace::
    FILE ${PROJECT_NAME}Targets.cmake
    DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
)

The exported config file will not set up INTERFACE_INCLUDE_DIRECTORIES to the public headers directory of the framework (where PUBLIC_HEADER are installed). This is an issue because you then either need to:

  • Copy headers yourselves (and thus duplicating them) because setting PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} will be ignored. But if you used it in combination with INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} it would cause issues as CMAKE_INSTALL_INCLUDEDIR would be referenced in INTERFACE_INCLUDE_DIRECTORIES. And since PUBLIC_HEADER DESTINATION is ignored, the folder will not exist. Thus consumers would end up with the following error :

CMake Error in CMakeLists.txt: Imported target "dep::dep" includes non-existent path

"/xxxx/out/install/include"

in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:

  • The path was deleted, renamed, or moved to another location.

  • An install or uninstall procedure did not complete successfully.

  • The installation package was faulty and references files it does not provide.

  • Set the INCLUDES DESTINATION to the framework public headers directory yourself which is very impractical
    • You would need to set its value depending on the platform and based on if the target is built as a framework (can not be predicted if the user sets CMAKE_FRAMEWORK variable)
    • The layout of frameworks is subject to changes from Apple and are not exposed by a module such as GNUInstallDirs

Right now, this makes it very difficult to write a decent install script that supports Apple frameworks.

Edited by Clément Grégoire
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information