Hello,
I posted the following at https://stackoverflow.com/q/79687866/5525302, but got no answer, that is why I try it here.
I want to create a c+±20-module without partitions but where the interface is in a different file than the implementation. This is my setup:
interface file ModuleTest.ixx:
export module moduleTest;
export int foo();
implementation file ModuleTest.cpp:
module moduleTest;
int foo() {
// some implementation
}
How do I need to specify the implementation file within the corresponding target in CMakeLists.txt?
This is what I tried:
add_library(moduleTest)
target_sources(moduleTest
PRIVATE FILE_SET CXX_MODULES FILES
ModuleTest.ixx
PRIVATE
ModuleTest.cpp
)
target_compile_features(moduleTest PUBLIC cxx_std_20)
target_compile_options(moduleTest PRIVATE "-fmodules-ts")
I get this error:
moduleTest: error: failed to read compiled module: No such file or directory
moduleTest: note: compiled module file is 'gcm.cache/moduleTest.gcm'
moduleTest: note: imports must be built before being imported
moduleTest: fatal error: returning to the gate for a mechanical issue
Can I expect this to work at all?
Thanks for any advice!