I am encountering this problem with CMake on Ubuntu 24.04, Clang 19, GCC 14 and CLion 2024.3.4. These are examples for talk and book so the partition module needs to be done with an MIU and implementation file. Other non-partition examples build correctly.
cmake -E cmake_ninja_dyndep --tdi=Javanese/CMakeFiles/javanese.dir/CXXDependInfo.json --lang=CXX --modmapfmt=gcc --dd=Javanese/CMakeFiles/javanese.dir/CXX.dd @Javanese/CMakeFiles/javanese.dir/CXX.dd.rsp
CMake Error: Output Javanese/CMakeFiles/javanese.dir/balinese.cpp.o provides the `Javanese:Balinese` module
but it is not found in a `FILE_SET` of type `CXX_MODULES`
ninja: build stopped: cannot make progress due to previous errors.
The files build correctly with both GCC and Clang using command lines.
Clang build:
+ clang++ -std=c++23 --precompile Balinese.cppm -o bin/Javanese-Balinese.pcm
+ clang++ -std=c++23 --precompile -fprebuilt-module-path=bin Javanese.cppm -o bin/Javanese.pcm
+ clang++ -std=c++23 -c -fprebuilt-module-path=bin Javanese.cppm -o bin/Javanese.o
+ clang++ -std=c++23 -c -fprebuilt-module-path=bin javanese.cpp -o bin/javanese.o
+ clang++ -std=c++23 -c -fprebuilt-module-path=bin balinese.cpp -o bin/balinese.o
+ clang++ -std=c++23 -r bin/Javanese.o bin/javanese.o bin/balinese.o -o bin/Javanese.Module.o
+ clang++ -std=c++23 -c -fprebuilt-module-path=bin main.cpp -o bin/main.o
+ clang++ -std=c++23 bin/Javanese.Module.o bin/main.o -o bin/main
+ bin/main
Kucing jawa ngomong 'mbelong'
Balinese anak kucing says 'meong'
The parent directory CMakeLists.txt
cmake_minimum_required(VERSION 3.30.5)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# must appear before project()
set(CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS "/usr/bin/clang-scan-deps")
endif ()
project(pragmatic_modules LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# other subdirectories
add_subdirectory(Javanese)
The Javanese CMakeLists.txt
cmake_minimum_required(VERSION 3.30.5)
project(Javanese LANGUAGES CXX)
set(module_name javanese)
add_executable(${PROJECT_NAME} main.cpp)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_23)
target_link_libraries(${PROJECT_NAME} ${module_name})
add_library(${module_name})
target_compile_features(${module_name} PUBLIC cxx_std_23)
target_sources(${module_name}
PUBLIC
FILE_SET cxx_modules TYPE CXX_MODULES
FILES
Balinese.cppm
${PROJECT_NAME}.cppm
PRIVATE
${module_name}.cpp
balinese.cpp
)
The partitions MIU Balinese.cppm
module;
export module Javanese:Balinese;
namespace Balinese {
export void meong();
}
The implementation file balinese.cpp
module;
#include <print>
module Javanese:Balinese;
namespace Balinese {
auto meong() -> void {
std::println("Balinese anak kucing says 'meong'");
}
}