PS1:
I also tried:
// utils.cppm
export module utils;
import std;
import :random_impl;
export import :random;
export namespace utils {}
// utils-random.cc
module utils:random_impl;
import :random;
namespace utils::random {
void print_partition_name() { std::println("{}", utils::random::part_name); }
}
as clang kinda does in their docs, though I get the same error:
CMake Error: Output bin/lib/utils/CMakeFiles/utils.dir/utils-random.cc.o provides the `utils:random_impl` module but it is not found in a `FILE_SET` of type `CXX_MODULES`
PS2:
I also tried doing what they do in their examples, and compiling and linking from the command line, so, no CMake involved, and it, surprisingly, works.
I found that extremely weird.
They do: module <primary_module>:<name_1>
and import :<part_to_be_implemented>
[in the implementation file] and import :<name_1>;
in the .cppm
, primary module file. Totally different from cppreference.
According to cppreference, <name_1>
should be module partition interface unit we’re implementing, and there should be no import :<partition_to_be_implemented>;
, since this would be clear from module <primary_module>:<partition_to_be_implemented>;
statement.
Nevertheless, that’s why I decided to post here first, since, via clang++ only, the example works ok, regardless of being weird or not.
PS3: I know this is all experimental,and will, therefore, have some rough edges. As I said, I’m just trying to experiment with what we have to see what works and what doesn’t, how this all works, etc.