CXX_MODULES_DIRECTORY assumes exclusive use of its destination
Since CMake 3.28, the install(EXPORT)
command supports a CXX_MODULES_DIRECTORY
option. This option is required if the export set contains any targets that export one or more C++20 modules. At the moment, CMake will write files into that directory with file names that are not specific to the export set. These files have names cxx-modules.cmake
and cxx-modules-<config>.cmake
. This means you can't install two or more exports with the same CXX_MODULES_DIRECTORY
, because they will overwrite each other. This restriction is not mentioned in the documentation.
If the files were instead written with the export name included in the file names, this restriction would go away. Projects could then avoid having to add an extra directory level to the CXX_MODULES_DIRECTORY
just to make each export set put its exported modules files in a different location. The names of these files are internal implementation details, so we should be able to change them in a CMake 3.28.x patch release.