Giter Site home page Giter Site logo

Comments (3)

loicmouton avatar loicmouton commented on June 29, 2024 2

I came across the same issue while using FetchContent with this project and I think I found a solution but it would require to modify the CMakeLists.txt file.
The Vulkan-Headers cmake project does not follow the guidelines to create relocatable packages given in the CMake manual (link).
The solution would be to replace:
target_include_directories(Vulkan-Headers INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
by:
target_include_directories(Vulkan-Headers INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" )
Additionally, it would be great to add a cmake cache variable that would control whether the targets defined in this project are added to the install rule. By doing so, projects using FetchContent to add this project to their build could easily set the value themselves. This is done in a lot of projects (namely SDL2 and fmt if I remember correctly).

from vulkan-headers.

axsaucedo avatar axsaucedo commented on June 29, 2024

It's worth mentioning that if I try to export the targets myself I get the following error:

CMake Error in external/Vulkan-Headers/CMakeLists.txt:
  Target "Vulkan-Headers" INTERFACE_INCLUDE_DIRECTORIES property contains
  path:

    "C:/.../external/Vulkan-Headers/include"

  which is prefixed in the source directory.

This is attempting to add a separate export target for vulkan-headers as follows:

install(TARGETS Vulkan-Headers EXPORT Vulkan-HeaderTargets
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib
    INCLUDES DESTINATION include)

install(EXPORT Vulkan-HeaderTargets
    FILE vulkanHeadersConfig.cmake
    NAMESPACE Vulkan::Headers::
    DESTINATION lib/cmake/vulkanheaders)

Or if I try to add it as part of my current export:

    install(TARGETS Xlib VulkanHeaders EXPORT XlibTargets
        LIBRARY DESTINATION lib
        ARCHIVE DESTINATION lib
        INCLUDES DESTINATION include)

from vulkan-headers.

axsaucedo avatar axsaucedo commented on June 29, 2024

It seems that it's possible to circumvent the issue above by using this instead:

get_target_property(VULKAN_HEADERS_INCLUDES Vulkan-Headers INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(
    Xlib PUBLIC
    $<BUILD_INTERFACE:${VULKAN_HEADERS_INCLUDES}>)

However I'm not sure if this is the proper way of doing this - are there best practices on how to include for install interfaces?

from vulkan-headers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.