typestatusdateslugsummarytagscategoryiconpasswordSample千呼万唤的 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 许可协议,转载请注明出处。相关文章PyCharm 配置 Unreal Python Module 代码提示Apple Clang 获取系统 C++ 头文件目录C++ decltype(auto) 介绍一文理解 FP16 Shader一文理解超分辨率记给 UnrealEngine 的一次 Contribution