First-class support for modulemap in FRAMEWORK targets

Setting the FRAMEWORK property on a library target builds a framework bundle on Apple platforms. The support for (as example) PUBLIC_HEADERS generating the Headers symlink and similar properties is really nice.

To use the framework with a Swift project, you also need a Modules/module.modulemap file to express the umbrella header. Is there a way (property?) to generate this additional file+directory in the resulting framework? Or would this be a new feature request?

I believe that is related to Clang modules (a predecessor to C++20 modules)? If so, CMake has no formal modelling for them (nor is it likely we’ll add it given that C++20 modules should cover its cases).

I found out about MACOSX_PACKAGE_LOCATION property. I tried setting it but it’s not putting that file in the bundle/framework.

configure_file(modulemap.in module.modulemap) # set umbrella header name
target_sources(${fw_name} PRIVATE ${CMAKE_BINARY_DIR}/module.modulemap)
set_source_files_properties(${CMAKE_BINARY_DIR}/module.modulemap
  PROPERTIES MACOSX_PACKAGE_LOCATION Modules)

The file is not installed though. I don’t see anything from the documentation for MACOSX_PACKAGE_LOCATION that I’m missing.

– UPDATE/EDIT –
It actually is installed, but it’s not linked from the Versions/A/Modules location to the bundle root, like the “known” bundle names (Headers, Private Headers, Resources) are. Looks like you have to manually link the directory.