-
-
Notifications
You must be signed in to change notification settings - Fork 784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用了C++20 module的项目生成的CMakeLists.txt不正确 #5765
Comments
Title: The CMakeLists.txt generated by projects using the C++20 module is incorrect |
你可以先自己调下 cmakelists.txt 看下哪里不对,xmake 能编译,不代表 cmake 一定也能很好支持 c++ modules。 |
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 Sources: https://www.kitware.com/import-cmake-the-experiment-is-over/ |
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. |
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
构建得到的报错:The text was updated successfully, but these errors were encountered: