Open hghgthifg opened 1 month ago
Bot detected the issue body's language is not English, translate it automatically.
Title: The CMakeLists.txt generated by projects using the C++20 module is incorrect
你可以先自己调下 cmakelists.txt 看下哪里不对,xmake 能编译,不代表 cmake 一定也能很好支持 c++ modules。
Bot detected the issue body's language is not English, translate it automatically.
You can first adjust cmakelists.txt yourself to see what is wrong. If xmake can compile, it does not mean that cmake can also support c++ modules well.
Actually CMake support modules (with one exception, header units). But you should add sources like the following:
target_sources(foo
PUBLIC
FILE_SET CXX_MODULES FILES
foo.cxx
)
Note the FILE_SET CXX_MODULES FILES
annotation. This should be rather easy to implement in the XMake side.
Sources:
https://www.kitware.com/import-cmake-the-experiment-is-over/ https://www.kitware.com/import-std-in-cmake-3-30/
Note the FILE_SET CXX_MODULES FILES annotation. This should be rather easy to implement in the XMake side.
You can try add it in generated CMakeLists.txt manually. Does it work?
I think cmake is able to automatically recognize and support .cppm files for compiling as modules. It works for me.
Only non-module file suffixes (.cxx) need to be set CXX_MODULES file type explicitly.
Note the FILE_SET CXX_MODULES FILES annotation. This should be rather easy to implement in the XMake side.
You can try add it in generated CMakeLists.txt manually. Does it work?
I think cmake is able to automatically recognize and support .cppm files for compiling as modules. It works for me.
Only non-module file suffixes (.cxx) need to be set CXX_MODULES file type explicitly.
在我的环境下 windows + cmake 3.31.0 并使用 cppm 后缀无效,还是需要显式添加 PRIVATE FILE_SET CXX_MODULES FILES
Xmake 版本
v2.9.5+HEAD.d30de52e9
操作系统版本和架构
Windows11 version 23H2
描述问题
src/main.cpp:
src/vec3.cppm:
xmake.lua:
直接使用
xmake
进行构建是正常的,但是生成的CMakeLists.txt
无法正常使用。CMakeLists.txt:
用
CMake
构建得到的报错:期待的结果
期待生成的
CMakeLists.txt
能和用xmake
一样成功构建工程配置
附加信息和错误日志
用
CMake
构建得到的报错: