The CMake looks OK. Can you diff the link lines with and without modules on the executables? Or the symbols in the objects. There has to be some difference…
Probably better to move this to an issue on the repo and bring the result back here instead of hijacking the topic.
Can you provide an example of how this should be specified please, because it’s not obvious to me.
Here’s my attempt:
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")
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
I tried changing the name to be the project name (since custom targets are not allowed for FILE_SET CXX_MODULES, but that did not work either:
target_sources("${PROJECT_NAME}"
PUBLIC
FILE_SET CXX_MODULES FILES
"platform.win32.ixx"
"platform.win32-window.ixx"
PRIVATE
"platform.win32-window.cpp"
)
Subtle and perhaps not the most obvious. I appreciate this is very new, but perhaps a few examples would help. The example from the CMake blog is a bit too basic.
cmake_minimum_required(VERSION 3.28)
project(std_module_example CXX)
# Turning off extensions avoids and issue with the clang 16 compiler
# clang 17 and greater can avoid this setting
set(CMAKE_CXX_EXTENSIONS OFF)
# Set the version of C++ for the project
set(CMAKE_CXX_STANDARD 20)
# Create a library
add_library(foo)
# Add the module file to the library
target_sources(foo
PUBLIC
FILE_SET CXX_MODULES FILES
foo.cxx
)
# Create an executable
add_executable(hello main.cxx)
# Link to the library foo
target_link_libraries(hello foo)
Ideally, no. Consumers will need relinked as the object code has changed, but the implementation file should have no effect on BMI-producing files (just like a change to a .cxx shouldn’t make includers of the corresponding .h file care). If you see discrepancies, please file bugs with example code.