clang-tidy + cxx_modules

The notes above are right, but it is a standalone working example only.

The real question is why does clang-tidy ends with an clang-diagnostic-error:

bash-3.2$ ninja -C build/
ninja: Entering directory `build/'
[0/1] Re-running CMake...
CMake Warning (dev) at CMakeLists.txt:70 (target_sources):
  CMake's C++ module support is experimental.  It is meant only for
  experimentation and feedback to CMake developers.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done (0.1s)
CMake Warning (dev):
  C++20 modules support via CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP is
  experimental.  It is meant only for compiler developers to try.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done (0.0s)
-- Build files have been written to: /Users/clausklein/Workspace/cpp/cxx20/test/build
[4/8] Building CXX object CMakeFiles/foo.dir/foo.cxx.o
/Users/clausklein/Workspace/cpp/cxx20/test/foo.cxx:8:14: warning: class 'foo' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions,hicpp-special-member-functions]
export class foo {
             ^
/Users/clausklein/Workspace/cpp/cxx20/test/foo.cxx:8:14: warning: invalid case style for class 'foo' [readability-identifier-naming]
export class foo {
             ^~~
             Foo
/Users/clausklein/Workspace/cpp/cxx20/test/foo.cxx:15:11: warning: method 'helloworld' can be made static [readability-convert-member-functions-to-static]
void foo::helloworld() { std::cout << "hello world\n"; }
          ^
[7/8] Building CXX object CMakeFiles/hello.dir/main.cxx.o
FAILED: CMakeFiles/hello.dir/main.cxx.o 
/usr/local/Cellar/cmake/3.26.3/bin/cmake -E __run_co_compile --tidy="clang-tidy;-checks=*,-llvmlibc-*,-fuchsia-*,-cppcoreguidelines-init-variables;--extra-arg-before=--driver-mode=g++" --source=/Users/clausklein/Workspace/cpp/cxx20/test/main.cxx -- /usr/local/opt/llvm/bin/clang++   -std=c++20 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -MD -MT CMakeFiles/hello.dir/main.cxx.o -MF CMakeFiles/hello.dir/main.cxx.o.d @CMakeFiles/hello.dir/main.cxx.o.modmap -o CMakeFiles/hello.dir/main.cxx.o -c /Users/clausklein/Workspace/cpp/cxx20/test/main.cxx
/Users/clausklein/Workspace/cpp/cxx20/test/main.cxx:1:8: error: module 'foo' not found [clang-diagnostic-error]
import foo;
~~~~~~~^~~
1 error generated.
Error while processing /Users/clausklein/Workspace/cpp/cxx20/test/main.cxx.
Found compiler error(s).
ninja: build stopped: subcommand failed.
bash-3.2$