ClangCodeModel in QtCreator says "module not found" on imported C++20 modules

Viewed 320

I use QtCreator 4.15.2, clang 12.0.1.

I have "generic project" with makefile. File src/test/main.cpp contains import test.StringUtil;. QtCreator complains that module is not found. (Project builds ok, but makefile uses gcc; I'm not familiar with clang.) I tried this:

  1. Generated .pcm file in separate directory:

    clang++ -std=c++20 -fmodules --precompile -x c++-module src/test/StringUtil.cpp -o target/clang/test.StringUtil.pcm
    
  2. Edited myproject.cxxflags in project root so it contains:

    -std=c++20 -fmodules -fprebuilt-module-path=/home/me/myproject/target/clang -Wall -Wextra -Wpedantic -fno-rtti
    

If I specify relative path -fprebuilt-module-path=target/clang then nothing changes; QtCreator still says that module not found. But with absolute path looks like ClangCodeModel gets disabled (crashes?): <No Symbols> in QtCreator's symbols combobox, no syntax errors reporting.

  1. I also tried to compile in additiion to generating .pcm file, with no difference:

    clang++ -std=c++20 -fmodules -c -x c++-module src/test/StringUtil.cpp -o target/build/clang/test.StringUtil.o
    

So: how do I make it work?

1 Answers

When I added support for modules in my own build system I found it easiest to specify each imported module with the flag -fmodule-file="path/to/other.pcm".

In the future I guess that the big build systems will do this aswell. since you need to preprocess the files anyway there is no extra cost. (It could be some extra work if you write your makefiles by hand though)

I don't think that qtcreators code model supports modules as of yet. I have tried but it does not work for me.

Related