xmake
xmake copied to clipboard
Modules from packages not added when generating vs projects
Xmake Version
2.9.7
Operating System Version and Architecture
Windows
Describe Bug
Modules from packages are not added when generating vs projects (both vs and vsxmake). Local modules and modules from other targets work as expected, building also works.
Expected Behavior
Modules from packages are recognized in vs projects.
Project Configuration
add_requires("magic_enum", {configs={modules=true}})
add_rules("mode.debug", "mode.release")
set_languages("c++23")
target("module_test")
set_kind("binary")
add_files("src/*.cpp")
add_packages("magic_enum")
set_policy("build.c++.modules", true)
Additional Information and Error Logs
Compilation works:
xmake build module_test
checking for Microsoft Visual Studio (x64) version ... 2022
checking for Microsoft C/C++ Compiler (x64) version ... 19.42.34435
[ 0%]: <module_test> generating.module.deps src\main.cpp
[ 0%]: <module_test> generating.module.deps C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.42.34433\modules\std.ixx
[ 0%]: <module_test> generating.module.deps F:\packages\.xmake\packages\m\magic_enum\v0.9.7\fdb5460ff3c64f3a824f1e422136da67\modules\7597f117\magic_enum.cppm
[ 0%]: <module_test> generating.module.deps C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.42.34433\modules\std.compat.ixx
[ 42%]: <module_test> compiling.module.release magic_enum
[ 71%]: compiling.release src\main.cpp
[ 85%]: linking.release module_test.exe
[100%]: build ok, spent 3.938s
vs project generator does not support modules now.
vs project generator does not support modules now.
gcc15 也不支持吗. 我用gcc15 编译的模块工程, 生成compile_commands.json, clangd 也不识别, 用的 xmake v2.9.7+20250122, 如果我使用clang-20 编译, 然后它生成 compile_commands.json,clangd 可以识别
➜ test-mod diff compile_commands.json compile_commands.json.gcc15
4,5c4,5
< "arguments": ["/usr/lib/llvm-20/bin/clang", "-c", "-Qunused-arguments", "-m64", "-fvisibility=hidden", "-fvisibility-inlines-hidden", "-O3", "-std=c++26", "-stdlib=libc++", "-cxx-isystem/usr/lib/llvm-20/include/c++/v1", "-DNDEBUG", "-x", "c++-module", "-fmodule-output=build/.gens/test-mod/linux/x86_64/release/rules/bmi/cache/modules/641690a7/std.pcm", "-Wno-include-angled-in-module-purview", "-Wno-reserved-module-identifier", "-o", "build/.objs/test-mod/linux/x86_64/release/usr/lib/llvm-20/bin/__/lib/__/share/libc++/v1/std.cppm.o", "/usr/lib/llvm-20/bin/../lib/../share/libc++/v1/std.cppm"],
< "file": "/usr/lib/llvm-20/bin/../lib/../share/libc++/v1/std.cppm"
---
> "arguments": ["/root/gcc15/bin/g++", "-c", "-m64", "-fvisibility=hidden", "-fvisibility-inlines-hidden", "-O3", "-std=c++26", "-fmodules-ts", "-D_GLIBCXX_USE_CXX11_ABI=1", "-DNDEBUG", "-fmodule-mapper=/tmp/.xmake0/250126/test-mod/root/gcc15/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/../include/c++/15/bits/std.cc", "-x", "c++", "-o", "build/.objs/test-mod/linux/x86_64/release/root/gcc15/lib/gcc/x86_64-redhat-linux/15/__/__/__/__/lib64/__/include/c++/15/bits/std.cc.o", "/root/gcc15/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/../include/c++/15/bits/std.cc"],
> "file": "/root/gcc15/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/../include/c++/15/bits/std.cc"
9c9
< "arguments": ["/usr/lib/llvm-20/bin/clang", "-c", "-Qunused-arguments", "-m64", "-fvisibility=hidden", "-fvisibility-inlines-hidden", "-O3", "-std=c++26", "-stdlib=libc++", "-cxx-isystem/usr/lib/llvm-20/include/c++/v1", "-DNDEBUG", "-fmodule-file=std=build/.gens/test-mod/linux/x86_64/release/rules/bmi/cache/modules/641690a7/std.pcm", "-o", "build/.objs/test-mod/linux/x86_64/release/src/main.cpp.o", "src/main.cpp"],
---
> "arguments": ["/root/gcc15/bin/g++", "-c", "-m64", "-fvisibility=hidden", "-fvisibility-inlines-hidden", "-O3", "-std=c++26", "-fmodules-ts", "-D_GLIBCXX_USE_CXX11_ABI=1", "-DNDEBUG", "-fmodule-mapper=/tmp/.xmake0/250126/test-mod/src/main.cpp", "-o", "build/.objs/test-mod/linux/x86_64/release/src/main.cpp.o", "src/main.cpp"],
Bot detected the issue body's language is not English, translate it automatically.
vs project generator does not support modules now.
Doesn't gcc15 also support it? I compiled the module project with gcc15 and generated compile_commands.json, which is not recognized by clangd either.
这个你要问 clangd 了
Bot detected the issue body's language is not English, translate it automatically.
You have to ask clangd about this
这个你要问 clangd 了
你看我上面贴了 gcc 和 clang 生成 compile_commands.json, 它们俩 完全不同, xmake project -k compile_commands 生成 compile_commands.json, 是 xmake 自己内部实现的吗? 还是 调用了第三方的东西
Bot detected the issue body's language is not English, translate it automatically.
You have to ask Clangd
You see, I posted GCC and CLANG to generate compile_commands.json. They are completely different. Still calling the third party's things
这里只负责生成,不同编译器对应的 flags 和实现机制都不同,生成的 compile_commands 结果肯定都不同 ,至于 clangd 是否支持,你要去问 clangd 。。可以自行对比生成的结果。
Bot detected the issue body's language is not English, translate it automatically.
Here are only responsible for generating. The FLAGS corresponding to different compilers and the implementation mechanism are different. The result generated by the generated compile_commands must be different. As for whether Clangd supports, you have to ask Clangd. Essence You can compare the result of generating.
这里只负责生成,不同编译器对应的 flags 和实现机制都不同,生成的 compile_commands 结果肯定都不同 ,至于 clangd 是否支持,你要去问 clangd 。。可以自行对比生成的结果。
好,我刚才用cmake + ninja 编译然后生成compile_commands , clangd 也不识别, 看样子是clangd 的问题
Bot detected the issue body's language is not English, translate it automatically.
This is only responsible for generation. Different compilers have different flags and implementation mechanisms, and the generated compile_commands results are definitely different. As for whether clangd supports it, you have to ask clangd. . You can compare the generated results yourself.
Okay, I just used cmake + ninja to compile and generate compile_commands. Clangd doesn’t recognize it either. It seems to be a problem with clangd.