Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: C++20-Module installation and integration testing #538

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

M2-TE
Copy link
Contributor

@M2-TE M2-TE commented Apr 2, 2025

  • Installing Vulkan-HppModule target with Vulkan::HppModule ALIAS
  • FindPackage testing for module target
  • Cleaned up minimal .cpp
  • Properly utilized the existing Ninja variable in CMAKE_GENERATOR within CI

Co-authored-by: Charles Giessen <46324611+charles-lunarg@users.noreply.github.com>
@M2-TE
Copy link
Contributor Author

M2-TE commented Apr 2, 2025

CMake Error at CMakeLists.txt:123 (install):
install TARGETS target Vulkan-HppModule is exported but not all of its
interface file sets are installed

It looks like cmake wants us to explicitly install the .cppm file as well, even though we already install it implicitly here

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/vulkan" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

CMake install lists a property specifically for cxx modules as CXX_MODULES_BMI, so I will try to use that
This is not what we want

@M2-TE
Copy link
Contributor Author

M2-TE commented Apr 2, 2025

We likely need the FILE_SET key for install, which is not available for older CMake versions, so might have to split the installs up as before.
Though, I am not entirely sure how to go about installing file sets, as I've never done so before, especially with CXX modules.

M2-TE and others added 2 commits April 3, 2025 07:39
Rely entirely on env variable for the choice of cmake generator

Co-authored-by: jpr42 <109434725+jpr42@users.noreply.github.com>
Copy link
Contributor

@jpr42 jpr42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vulkan.cppm is being installed twice

@jpr42
Copy link
Contributor

jpr42 commented Apr 3, 2025

vulkan.cppm is being installed twice... It's also questionable if it should be installed in the include/vulkan directory.

-- Installing: /home/runner/work/Vulkan-Headers/Vulkan-Headers/build/install/include/vulkan/vulkan.cppm

...

-- Installing: /home/runner/work/Vulkan-Headers/Vulkan-Headers/build/install/lib/libVulkan-HppModule.a
-- Installing: /home/runner/work/Vulkan-Headers/Vulkan-Headers/build/install/include/include/vulkan/vulkan.cppm
-- Installing: /home/runner/work/Vulkan-Headers/Vulkan-Headers/build/install/share/cmake/VulkanHeaders/VulkanHeadersConfig.cmake
-- Installing: /home/runner/work/Vulkan-Headers/Vulkan-Headers/build/install/share/cmake/VulkanHeaders/VulkanHeadersConfig-noconfig.cmake
-- Installing: /home/runner/work/Vulkan-Headers/Vulkan-Headers/build/install/share/cmake/VulkanHeaders/./cxx-modules-VulkanHeadersConfig.cmake
-- Installing: /home/runner/work/Vulkan-Headers/Vulkan-Headers/build/install/share/cmake/VulkanHeaders/./cxx-modules-VulkanHeadersConfig-noconfig.cmake
-- Installing: /home/runner/work/Vulkan-Headers/Vulkan-Headers/build/install/share/cmake/VulkanHeaders/./target-HppModule-noconfig.cmake

Furthermore a libVulkan-HppModule.a is now being created as well as various *.cmake files.

What is the size of the static library? Could you size up these new artifacts on to github so we can look at them?

jpr42

This comment was marked as duplicate.

@jpr42
Copy link
Contributor

jpr42 commented Apr 3, 2025

vulkan.cppm is being installed twice

The culprit is this line of code install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/vulkan" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

It's installing everything even vulkan.cppm which it arguably shouldn't be... although it might break people if it gets changed now.

I'm not exactly certain with C++ modules so I can't speak with certainty.

@M2-TE M2-TE marked this pull request as draft April 4, 2025 06:22
@M2-TE
Copy link
Contributor Author

M2-TE commented Apr 4, 2025

It's installing everything even vulkan.cppm which it arguably shouldn't be... although it might break people if it gets changed now.

Yea that is what I was worried about once the normal headers are installed as file sets as well. But it is also how people get the .cppm file currently, so not putting it in the include/vulkan/ directory would certainly break things for them.
Normally, it should be put into a src/ folder from what I have seen, as it is basically a source file. But you could also argue that it is more akin to a header file, as we do NOT want to ship a compiled binary. So we basically want to ship the .cppm as a header, to be used as a source file by users.

For clarification:

Furthermore a libVulkan-HppModule.a is now being created as well as various *.cmake files.

I cannot speak on the *.cmake files, but the behavior of creating and installing a static library is wrong.
Modules can generally be:

  • Standalone files containing both declarations and implementations, akin to a header. That is what vulkan.cppm is.
  • Split up into interface modules for declarations and implementation modules. This would require shipping static or shared library for the compiled implementation.

I don't know if this can be precisely controlled, as, to CMake at least, the Vulkan-HppModule is a library, not an INTERFACE. We want to ship ONLY the Vulkan-HppModule target, as users will want to compile these on their own. In the far future, we might additionally ship the BMI, but those are still far too unstable so not an option yet.

Out of the installed *.cmake files

-- Installing: /home/runner/work/Vulkan-Headers/Vulkan-Headers/build/install/share/cmake/VulkanHeaders/VulkanHeadersConfig.cmake
-- Installing: /home/runner/work/Vulkan-Headers/Vulkan-Headers/build/install/share/cmake/VulkanHeaders/VulkanHeadersConfig-noconfig.cmake
-- Installing: /home/runner/work/Vulkan-Headers/Vulkan-Headers/build/install/share/cmake/VulkanHeaders/./cxx-modules-VulkanHeadersConfig.cmake
-- Installing: /home/runner/work/Vulkan-Headers/Vulkan-Headers/build/install/share/cmake/VulkanHeaders/./cxx-modules-VulkanHeadersConfig-noconfig.cmake
-- Installing: /home/runner/work/Vulkan-Headers/Vulkan-Headers/build/install/share/cmake/VulkanHeaders/./target-HppModule-noconfig.cmake

we likely do not need the additional ones with the "." path specified and those probably come from theCXX_MODULES_DIRECTORY . key during within install.

The things left to do are now, as far as I can tell:

  1. Remove the need to ship a binary, be it static or shared.
  2. Figure out what directory the .cppm should be put into (there might be more than one .cppm in the future).
  3. Assess whether the additional *.cmake files are necessary, specifically the ones with the "." path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants