How do I add a C++ module partition implementation file to a CMake project?
target_sources(discovery_win32
PUBLIC
FILE_SET cxx_modules TYPE CXX_MODULES
FILES
"platform.win32.ixx" "platform.win32-window.ixx"
PRIVATE
"platform.win32-window.cpp")
This results in an error:
C:\Dev\Personal\Discovery\out\build\x64-debug\Discovery\EXEC : CMake error : Output platform\win32\CMakeFiles\discovery_win32.dir\platform.win32-window.cpp.obj provides the `platform.win32:window` module but it is not found in a `FILE_SET` of type `CXX_MODULES`
ninja: build stopped: subcommand failed.
A CMake Discourse conversation says that:
The .cpp file is not a module file (i.e., it does not produce a BMI). It is instead an implementation unit of a module; it does not belong in CXX_MODULES filesets.
Which is what I have tried to do. I cannot find any examples of how to correctly add the implementation file; unfortunately the CMake blog on modules does not show this either.
What is the correct way to achieve this?