typestatusdateslugsummarytagscategoryiconpassword<ins/>Sample千呼万唤的 CMake 官方 C++ Modules 支持总算来了,主要就是用到了 target_sources 指令的 file_set 特性(3.28 支持 CXX_MODULES),文档在这里:target_sources — CMake 3.31.0-rc3 DocumentationRepeated calls for the same <target> append items in the order called.https://cmake.org/cmake/help/latest/command/target_sources.html#file-sets 用法相当简单,只需要对想添加 modules 源文件的 target 使用 target_sources+ FILE_SET CXX_MODULES 指定即可,下面是一个简单的例子: 对应的源文件:在 MSVC 17 2022 下成功编译运行。参考资料Modules (since C++20) - cppreference.comMost C++ projects use multiple translation units, and so they need to share declarations and definitions across those units. The usage of headers is prominent for this purpose, an example being the standard library whose declarations can be provided by including the corresponding header.https://en.cppreference.com/w/cpp/language/modulestarget_sources — CMake 3.31.0-rc3 DocumentationRepeated calls for the same <target> append items in the order called.https://cmake.org/cmake/help/latest/command/target_sources.htmlHow to use c++20 modules with CMake?Clang and MSVC already supports Modules TS from unfinished C++20 standard. Can I build my modules based project with CMake or other build system and how? I tried build2, it supports modules and it...https://stackoverflow.com/questions/57300495/how-to-use-c20-modules-with-cmake上一篇Apple Clang 获取系统 C++ 头文件目录下一篇C++ decltype(auto) 介绍下一篇C++ decltype(auto) 介绍作者:Kindem链接:https://www.flyandnotdown.com/post/12d8fb78-2f78-80af-b763-f7087434a2f2声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。相关文章Win11 重新编译 UE 后首次启动特别慢的解决方法Explosion 游戏引擎开发笔记 - QML 热重载Mac Mini M4 翻身做 NAS 折腾记 (三)Mac Mini M4 翻身做 NAS 折腾记 (二)Mac Mini M4 翻身做 NAS 折腾记 (一)电信/华为路由器 HN8156XR 折腾 ipv6 公网访问之路