bash-3.2$ cmake --version
cmake version 3.26.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
bash-3.2$ ninja --version
1.11.1.git.kitware.jobserver-1
bash-3.2$ cmake -B build -G Ninja
-- The CXX compiler identification is AppleClang 14.0.3.14030022
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at CMakeLists.txt:77 (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.6s)
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
bash-3.2$ ninja -C build
ninja: Entering directory `build'
[3/8] Generating CXX dyndep file CMakeFiles/foo.dir/CXX.dd
FAILED: CMakeFiles/foo.dir/CXX.dd
/usr/local/Cellar/cmake/3.26.3/bin/cmake -E cmake_ninja_dyndep --tdi=CMakeFiles/foo.dir/CXXDependInfo.json --lang=CXX --dd=CMakeFiles/foo.dir/CXX.dd @CMakeFiles/foo.dir/CXX.dd.rsp
CMake Error: -E cmake_ninja_dyndep failed to parse CMakeFiles/foo.dir/foo.cxx.o.ddi* Line 1, Column 1
Syntax error: value, object or array expected.
CMake Error: -E cmake_ninja_dyndep failed to parse ddi file CMakeFiles/foo.dir/foo.cxx.o.ddi
ninja: build stopped: subcommand failed.
bash-3.2$
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$