C++20 modules API example

Same problems without import std;

cmake_minimum_required(VERSION 3.30...4.0)

set(CMAKE_EXPORT_COMPILE_COMMANDS YES)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_EXTENSIONS YES)
set(CMAKE_CXX_STANDARD_REQUIRED YES)

set(CMAKE_CXX_SCAN_FOR_MODULES YES)

project(FetchLibTestReceive VERSION 1.0 LANGUAGES CXX)

# First find clang-tidy, this also allows users to provide hints
# FIXME: find_program(CMAKE_CXX_CLANG_TIDY NAMES clang-tidy REQUIRED)

file(WRITE greeting.cppm
     [=[
// Global Module Fragment (GMF) where #includes can happen
module;
#include <print>
#include <string>

// first thing after the Global module fragment must be a module command
// XXX import std;

export module greeting;

export class greeting {
  public:
    explicit greeting(const std::string_view name) : m_name(name) {}
    ~greeting() = default;
    void helloworld();

  private:
    std::string m_name;
};

void greeting::helloworld() {
    std::print("hello world from {}\n", m_name);
}
]=]
)

file(WRITE hello.cpp
     [=[
import greeting;

auto main() -> int {
    greeting greeter("Claus");
    greeter.helloworld();

    return 0;
}
]=]
)

add_library(greeting)
target_sources(
  greeting
  PUBLIC FILE_SET
         cxx_modules
         TYPE
         CXX_MODULES
         FILES
         greeting.cppm
)
add_executable(hello hello.cpp)
target_link_libraries(hello greeting)

enable_testing()
add_test(NAME hello COMMAND hello)

add_test(NAME test-simple_module COMMAND test-simple_module)
install(TARGETS greeting ARCHIVE PUBLIC_HEADER FILE_SET cxx_modules DESTINATION include CXX_MODULES_BMI
                                               DESTINATION libexec/cpp-modules
)

but run-clang-tidy from console works fine:

run-clang-tidy -p out/build/release -checks='-*,hicpp-*'
Enabled checks:
    hicpp-avoid-c-arrays
    hicpp-avoid-goto
    hicpp-braces-around-statements
    hicpp-deprecated-headers
    hicpp-exception-baseclass
    hicpp-explicit-conversions
    hicpp-function-size
    hicpp-ignored-remove-result
    hicpp-invalid-access-moved
    hicpp-member-init
    hicpp-move-const-arg
    hicpp-multiway-paths-covered
    hicpp-named-parameter
    hicpp-new-delete-operators
    hicpp-no-array-decay
    hicpp-no-assembler
    hicpp-no-malloc
    hicpp-noexcept-move
    hicpp-signed-bitwise
    hicpp-special-member-functions
    hicpp-static-assert
    hicpp-undelegated-constructor
    hicpp-uppercase-literal-suffix
    hicpp-use-auto
    hicpp-use-emplace
    hicpp-use-equals-default
    hicpp-use-equals-delete
    hicpp-use-noexcept
    hicpp-use-nullptr
    hicpp-use-override
    hicpp-vararg

Running clang-tidy for 2 files out of 2 in compilation database ...
[1/2][1.1s] /usr/local/opt/llvm/bin/clang-tidy -checks=-*,hicpp-* -p=out/build/release /Users/clausklein/Workspace/cpp/cxx20/test/hello.cpp
1772 warnings generated.
Suppressed 1772 warnings (1772 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

[2/2][1.6s] /usr/local/opt/llvm/bin/clang-tidy -checks=-*,hicpp-* -p=out/build/release /Users/clausklein/Workspace/cpp/cxx20/test/greeting.cppm
/Users/clausklein/Workspace/cpp/cxx20/test/greeting.cppm:11:14: warning: class 'greeting' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [hicpp-special-member-functions]
   11 | export class greeting {
      |              ^
1772 warnings generated.
Suppressed 1771 warnings (1771 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

bash-5.2$