<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[想请教一下大家构建C++模块架构是这样的吗？]]></title><description><![CDATA[<pre><code>cmake_minimum_required(VERSION 3.28)

project(occ_module
    LANGUAGES CXX 
    VERSION 8.0.0
)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED true)

find_package(OpenCASCADE CONFIG REQUIRED)

add_library(occ_module)
target_link_libraries(occ_module PUBLIC 
    ${OpenCASCADE_LIBRARIES}
)

file(GLOB mfiles source/cppm/*/*.cppm source/cppm/*.cppm)
file(GLOB sfiles "source/src/*/*.cpp" source/src/*.cpp)
target_sources(occ_module 
PUBLIC 
    FILE_SET occ_module_m
        TYPE CXX_MODULES
            FILES ${mfiles}
PRIVATE 
    ${sfiles}
)

install(TARGETS occ_module 
    EXPORT occ_moduleTargets DESTINATION lib 
    FILE_SET occ_module_m
)
install(EXPORT occ_moduleTargets 
    NAMESPACE occ_module::
    DESTINATION lib/cmake/occ_module
)
include (CMakePackageConfigHelpers)
configure_package_config_file(
    "cmake/config.cmake.in"
    ${CMAKE_CURRENT_BINARY_DIR}/occ_moduleConfig.cmake
    INSTALL_DESTINATION lib/cmake/occ_module
)
write_basic_package_version_file(
    ${CMAKE_CURRENT_BINARY_DIR}/occ_moduleConfigVersion.cmake
    VERSION ${PROJECT_VERSION}
    COMPATIBILITY SameMajorVersion
)
install(FILES 
    ${CMAKE_CURRENT_BINARY_DIR}/occ_moduleConfig.cmake 
    ${CMAKE_CURRENT_BINARY_DIR}/occ_moduleConfigVersion.cmake 
    DESTINATION lib/occ_module
)

find_package(Boost CONFIG REQUIRED unit_test_framework)
enable_testing()
file(GLOB tfiles tests/*.cpp)
foreach (f ${tfiles})
get_filename_component(e ${f} NAME)
string(REPLACE ".cpp" "" e ${e})
add_executable(${e} ${f})
target_link_libraries(${e} PRIVATE 
    occ_module
    Boost::unit_test_framework
)

add_test(NAME ${e} COMMAND ${e})
endforeach()
</code></pre>
]]></description><link>http://forum.d2learn.org/topic/224/想请教一下大家构建c-模块架构是这样的吗</link><generator>RSS for Node</generator><lastBuildDate>Mon, 17 Aug 2026 04:22:35 GMT</lastBuildDate><atom:link href="http://forum.d2learn.org/topic/224.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 05 Jul 2026 15:01:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 想请教一下大家构建C++模块架构是这样的吗？ on Fri, 10 Jul 2026 05:19:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="http://forum.d2learn.org/uid/259">@小明</a> 后面有计划支持 msvc</p>
]]></description><link>http://forum.d2learn.org/post/891</link><guid isPermaLink="true">http://forum.d2learn.org/post/891</guid><dc:creator><![CDATA[SPeak]]></dc:creator><pubDate>Fri, 10 Jul 2026 05:19:40 GMT</pubDate></item><item><title><![CDATA[Reply to 想请教一下大家构建C++模块架构是这样的吗？ on Tue, 07 Jul 2026 01:56:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="http://forum.d2learn.org/uid/361">@__NaAlO2</a> 我看社区的 mcpp 也是使用LLVM，没有使用MSVC。Visual Studio + sln/slnx 估计不会考虑。</p>
]]></description><link>http://forum.d2learn.org/post/888</link><guid isPermaLink="true">http://forum.d2learn.org/post/888</guid><dc:creator><![CDATA[小明]]></dc:creator><pubDate>Tue, 07 Jul 2026 01:56:03 GMT</pubDate></item><item><title><![CDATA[Reply to 想请教一下大家构建C++模块架构是这样的吗？ on Mon, 06 Jul 2026 14:14:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="http://forum.d2learn.org/uid/259">@小明</a> CMake 的模块支持从 3.28 开始就有了，但 <code>import std</code> 直到目前最新版都还需要开启实验性支持才能用（见 <a href="https://cmake.com.cn/cmake/help/latest/prop_tgt/CXX_MODULE_STD.html" rel="nofollow ugc">https://cmake.com.cn/cmake/help/latest/prop_tgt/CXX_MODULE_STD.html</a> ）。<br />
至于头文件单元（例如 <code>import &lt;headers.hpp&gt;</code>），目前似乎只有 MSVC （用 Visual Studio 的 sln/slnx 工程）才支持。</p>
]]></description><link>http://forum.d2learn.org/post/887</link><guid isPermaLink="true">http://forum.d2learn.org/post/887</guid><dc:creator><![CDATA[__NaAlO2]]></dc:creator><pubDate>Mon, 06 Jul 2026 14:14:58 GMT</pubDate></item><item><title><![CDATA[Reply to 想请教一下大家构建C++模块架构是这样的吗？ on Mon, 06 Jul 2026 13:31:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="http://forum.d2learn.org/uid/3">@SPeak</a> 我看cmake很多模块支持的功能都是3.28引入的，稍后我看一下。</p>
]]></description><link>http://forum.d2learn.org/post/886</link><guid isPermaLink="true">http://forum.d2learn.org/post/886</guid><dc:creator><![CDATA[小明]]></dc:creator><pubDate>Mon, 06 Jul 2026 13:31:45 GMT</pubDate></item><item><title><![CDATA[Reply to 想请教一下大家构建C++模块架构是这样的吗？ on Mon, 06 Jul 2026 13:28:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="http://forum.d2learn.org/uid/361">@__NaAlO2</a> 稍后我试一下，我使用 clang 编译成功了，但是msvc编译失败了。提示是找不到 STD 模块，不知道是不是这个原因。</p>
]]></description><link>http://forum.d2learn.org/post/885</link><guid isPermaLink="true">http://forum.d2learn.org/post/885</guid><dc:creator><![CDATA[小明]]></dc:creator><pubDate>Mon, 06 Jul 2026 13:28:39 GMT</pubDate></item><item><title><![CDATA[Reply to 想请教一下大家构建C++模块架构是这样的吗？ on Mon, 06 Jul 2026 11:43:14 GMT]]></title><description><![CDATA[<p dir="auto">而且 mcpp 项目 完全使用 C++23 + 模块化工程结构, 本身可以作为 真实的 模块化项目示例 进行参考</p>
<ul>
<li><a href="https://github.com/mcpp-community/mcpp" rel="nofollow ugc">https://github.com/mcpp-community/mcpp</a></li>
</ul>
]]></description><link>http://forum.d2learn.org/post/884</link><guid isPermaLink="true">http://forum.d2learn.org/post/884</guid><dc:creator><![CDATA[SPeak]]></dc:creator><pubDate>Mon, 06 Jul 2026 11:43:14 GMT</pubDate></item><item><title><![CDATA[Reply to 想请教一下大家构建C++模块架构是这样的吗？ on Mon, 06 Jul 2026 11:41:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="http://forum.d2learn.org/uid/259">@小明</a>  模块文件布局没有什么问题</p>
<pre><code>module;

// 全局传统头文件

export module xxx; // 模块申明

import xxx; 导入

// 具体实现

</code></pre>
<p dir="auto">但是 cmake_minimum_required(VERSION 3.28)  这个版本好像太低了 而且cmake目前还是实验性支持module需要设置一个值, 我之之前有做一个视频有详细细节 可以参考</p>
<ul>
<li><a href="https://www.bilibili.com/video/BV12bT8z8Eq8" rel="nofollow ugc">https://www.bilibili.com/video/BV12bT8z8Eq8</a></li>
</ul>
<hr />
<p dir="auto">另外, 如果想要体验模块化建议使用 mcpp 专门为模块化工程打造的构建工具 支持非常好</p>
<ul>
<li><a href="https://github.com/mcpp-community/mcpp" rel="nofollow ugc">https://github.com/mcpp-community/mcpp</a></li>
</ul>
<p dir="auto">我也简单做过功能介绍视频, 可以了解</p>
<ul>
<li><a href="https://www.bilibili.com/video/BV19Kjf6cEVJ" rel="nofollow ugc">https://www.bilibili.com/video/BV19Kjf6cEVJ</a></li>
</ul>
]]></description><link>http://forum.d2learn.org/post/883</link><guid isPermaLink="true">http://forum.d2learn.org/post/883</guid><dc:creator><![CDATA[SPeak]]></dc:creator><pubDate>Mon, 06 Jul 2026 11:41:47 GMT</pubDate></item><item><title><![CDATA[Reply to 想请教一下大家构建C++模块架构是这样的吗？ on Mon, 06 Jul 2026 09:29:52 GMT]]></title><description><![CDATA[<p dir="auto">应该没问题。不过按我的经验来看，CMake 还需要添加 <code>set(CMAKE_CXX_SCAN_FOR_MODULES ON)</code> ，不然会提示编译器不支持模块。</p>
]]></description><link>http://forum.d2learn.org/post/882</link><guid isPermaLink="true">http://forum.d2learn.org/post/882</guid><dc:creator><![CDATA[__NaAlO2]]></dc:creator><pubDate>Mon, 06 Jul 2026 09:29:52 GMT</pubDate></item><item><title><![CDATA[Reply to 想请教一下大家构建C++模块架构是这样的吗？ on Mon, 06 Jul 2026 02:21:34 GMT]]></title><description><![CDATA[<p dir="auto">我参考了：<a href="https://github.com/mcpp-community/mcpp-style-ref" rel="nofollow ugc">https://github.com/mcpp-community/mcpp-style-ref</a></p>
]]></description><link>http://forum.d2learn.org/post/881</link><guid isPermaLink="true">http://forum.d2learn.org/post/881</guid><dc:creator><![CDATA[小明]]></dc:creator><pubDate>Mon, 06 Jul 2026 02:21:34 GMT</pubDate></item><item><title><![CDATA[Reply to 想请教一下大家构建C++模块架构是这样的吗？ on Sun, 05 Jul 2026 15:10:56 GMT]]></title><description><![CDATA[<p dir="auto">我想构建成cppm里声明导出模块和接口，定义实现内容放在.cpp文件里：</p>
<pre><code>module;

#include &lt;BinDrivers.hxx&gt;
#include &lt;BinDrivers_Marker.hxx&gt;
#include &lt;BinLDrivers_Marker.hxx&gt;

export module occ_module.application_framework.tkbin;

export namespace occ_module {
using BinDrivers = ::BinDrivers;
using BinDrivers_Marker = ::BinDrivers_Marker;
}
</code></pre>
]]></description><link>http://forum.d2learn.org/post/880</link><guid isPermaLink="true">http://forum.d2learn.org/post/880</guid><dc:creator><![CDATA[小明]]></dc:creator><pubDate>Sun, 05 Jul 2026 15:10:56 GMT</pubDate></item></channel></rss>