{"id":397017,"date":"2021-03-18T12:48:10","date_gmt":"2021-03-18T04:48:10","guid":{"rendered":"http:\/\/4563.org\/?p=397017"},"modified":"2021-03-18T12:48:10","modified_gmt":"2021-03-18T04:48:10","slug":"c-%e4%bb%a3%e7%a0%81%e4%bd%9c%e4%b8%ba-submodule-%e6%97%b6%ef%bc%8c%e5%a6%82%e4%bd%95%e9%81%bf%e5%85%8d%e5%8c%85%e5%90%ab%e7%9a%84-main-%e5%87%bd%e6%95%b0%e4%b8%8e%e4%b8%bb%e5%8c%85%e4%b8%ad","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=397017","title":{"rendered":"C++ \u4ee3\u7801\u4f5c\u4e3a submodule \u65f6\uff0c\u5982\u4f55\u907f\u514d\u5305\u542b\u7684 main \u51fd\u6570\u4e0e\u4e3b\u5305\u4e2d\u7684 main \u51b2\u7a81"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  C++ \u4ee3\u7801\u4f5c\u4e3a submodule \u65f6\uff0c\u5982\u4f55\u907f\u514d\u5305\u542b\u7684 main \u51fd\u6570\u4e0e\u4e3b\u5305\u4e2d\u7684 main \u51b2\u7a81               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : going2think <\/span>  <span><i><\/i> 1<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u60f3\u5230\u4e00\u4e2a C++\u7684\u95ee\u9898\uff0c\u8bf7\u5927\u5bb6\u5e2e\u5fd9\u770b\u770b\uff0c\u63d0\u524d\u8c22\u8c22\u4e86\u3002 \u73b0\u5728\u6709\u4ed3\u5e93 repo_A\uff1a<\/p>\n<pre><code>-repo_A |-- A.h |-- A.cpp |-- main.cpp <\/code><\/pre>\n<p>\u5728<code>main.cpp<\/code> \u4e2d\u5b9a\u4e49\u4e86 main \u51fd\u6570\uff0c\u7528\u4e8e\u81ea\u5df1\u4ee3\u7801\u7684\u6d4b\u8bd5\u3002<\/p>\n<p>\u73b0\u5728\u628a repo_A \u4f5c\u4e3a submodule \u5305\u542b\u5728\u4e00\u4e2a\u66f4\u5927\u7684\u4ed3\u5e93 repo_B \u4e2d\uff0c\u800c repo_B \u4e5f\u6709\u81ea\u5df1\u7684 main \u51fd\u6570\uff0c\u7ed3\u6784\u5927\u81f4\u5982\u4e0b\uff1a<\/p>\n<pre><code>-repo_B |--main.cpp |-- repo_A |--|-- A.h |--|-- A.cpp |--|-- main.cpp |--repo_C ... <\/code><\/pre>\n<p>\u90a3\u6709\u4e2a\u95ee\u9898\uff0c\u5728\u7f16\u8bd1\u65f6\uff08\u4f8b\u5982\u5728 VS \u4e2d\u4e00\u952e\u7f16\u8bd1\uff09\uff0c\u5982\u4f55\u907f\u514d\u4e24\u4e2a main \u51fd\u6570\u7684\u51b2\u7a81\u5462\uff0c\u5982\u679c\u6ce8\u91ca\u6389 repo_A \u4e2d\u7684 main \u51fd\u6570\uff0c\u6bcf\u6b21 pull \u7684\u65f6\u5019\u672c\u5730\u90fd\u4f1a\u4e0e\u8fdc\u7aef\u51b2\u7a81\uff0c\u60f3\u95ee\u4e0b\u5927\u5bb6\u4e00\u822c\u662f\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u7684\u5462<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>9<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5538770\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : GeruzoniAnsasu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6784\u5efa\u7cfb\u7edf\u662f\u5565\uff1f<\/p>\n<p>\u4f60\u4e0d\u4f1a\u628a\u76ee\u5f55\u548c\u5b50\u76ee\u5f55\u4e0b\u6240\u6709.cpp \u6587\u4ef6\u5168\u6293\u5230\u4e00\u8d77\u4f5c\u4e3a source \u5427\uff1f<\/p>\n<p>\u5178\u578b cmake: <\/p>\n<p>projectA\/CMakeLists.txt:<br \/>add_subdirectory(src) <\/p>\n<p>projectA\/src\/CMakeLists.txt:<br \/>file(GLOB_RECURSE *.cpp) <\/p>\n<p>target_include_directorie(projectA `submodule`\/include)<\/p>\n<p>\u8fd9\u79cd\u7ed3\u6784\uff0cprojectA \u548c submodule \u7684 source \u53c8\u4e0d\u4ea4\u53c9<br \/>\u629b\u5f00 submodule\uff0cunit test \u4e5f\u6709 main \u5462\uff0c\u8fd9\u4e2a\u95ee\u9898\u6ca1\u8003\u8651\u8fc7\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5538771\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : going2think <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @GeruzoniAnsasu \u611f\u8c22\u56de\u590d\uff0c\u7528 VS \u6765 build \u4ee3\u7801\uff0c\u73b0\u5728\u505a\u6cd5\u6bd4\u8f83 low\uff0c\u662f\u76f4\u63a5\u628a submodule clone \u8fdb\u53bb\uff0c\u4f5c\u4e3a\u4e00\u4e2a\u9879\u76ee\u6765\u7f16\u8bd1\uff0c\u6ca1\u7528 CMake \u6765\u7ba1\u7406\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5538772\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : secondwtq <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             VS \u80fd\u4e0d\u80fd\u628a\u91cc\u9762\u90a3\u4e2a main.cpp \u5728\u5de5\u7a0b\u91cc\u9762\u65e0\u89c6\u6389 &#8230; \u8c8c\u4f3c\u6709\u4e2a\u53eb\u201cExclude from Project\u201d\u7684\u529f\u80fd\uff1f<br \/>\u5176\u5b9e\u4e00\u822c\u6765\u8bb2\u76f4\u63a5\u5f15\u5165 C++ \u9879\u76ee\u7684\u90fd\u662f\u5e93\uff0c\u4e0d\u4f1a\u7f16\u8bd1\u51fa\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u6709\u7684\u9879\u76ee\u65e2\u4f1a\u7f16\u8bd1\u51fa\u5e93\u4e5f\u4f1a\u7f16\u8bd1\u51fa\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u8fd9\u79cd\u9879\u76ee\u4e00\u822c\u5df2\u7ecf\u4f7f\u7528\u4e86 CMake \u4e4b\u7c7b\u7684\u5de5\u5177\u7ba1\u7406 build \u8fc7\u7a0b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5538773\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ipwx <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             VS \u662f\u4e0d\u662f\u8be5\u628a\u9879\u76ee\u6587\u4ef6\u653e\u8fdb\u53bb\u3002\u3002\u3002\u6211\u8bb0\u5f97 GitHub \u7684 VS \u4ee3\u7801\u6807\u51c6\u505a\u6cd5\u5c31\u662f\u8fd9\u4e2a\u3002\u6709\u4e86\u9879\u76ee\u6587\u4ef6\u4e0d\u5c31\u53ef\u4ee5\u914d\u7f6e\u591a\u4e2a\u7f16\u8bd1\u76ee\u6807\u4e86\u561b\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5538774\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ipwx <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \uff08\u6211\u662f CLion + CMake \u7528\u6237\uff0c\u53cd\u6b63\u6211\u81ea\u5df1\u662f\u9760 CMake \u8bbe\u7f6e\u4e86\u591a\u4e2a\u7f16\u8bd1\u76ee\u6807\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5538775\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : GeruzoniAnsasu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @going2think vs \u4e00\u6837\u53ef\u4ee5\u5d4c\u5957 project \u554a <\/p>\n<p>vs \u6700\u7b80\u5355\u7c97\u66b4\u4e86\u9879\u76ee\u5305\u542b\u7684\u6e90\u6587\u4ef6\u5168\u5217\u5728.vcxproj \u91cc\uff0c\u6ca1\u6709\u5c31\u4e0d\u7f16\u8bd1\u3002<br \/>\u4e00\u4e2a sln \u80fd\u5957 N \u4e2a vcxproj\uff0cvcxproj \u53ef\u4ee5\u76f8\u4e92\u6307\u5b9a\u4f9d\u8d56\uff0c\u5148\u6784\u5efa\u88ab\u4f9d\u8d56\u7684 project\uff0c\u7136\u540e\u6784\u5efa\u4e0a\u5c42\u7684\u3002<br \/>\u7528 vs \u7684\u8bdd\u4f60\u7684\u9879\u76ee\u76ee\u5f55\u5e94\u8be5\u662f<\/p>\n<p>project\/:<br \/>A.sln A.vcxproj submodules\/ src\/ <\/p>\n<p>project\/submodules\/:<br \/>B\/<\/p>\n<p>project\/submodules\/B:<br \/>B.vcxproj src\/<\/p>\n<p>\u5728 A.sln \u91cc\u52a0\u5165 A.vcxproj \u548c B.vcxproj\uff0cA \u4f9d\u8d56 B\uff0c\u7136\u540e\u5c31\u80fd\u6b63\u5e38\u5d4c\u5957\u6784\u5efa\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5538776\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Vinty <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             project a<br \/>project b<br \/>project test a<br \/>project test b<br \/>\u8fd9\u6837                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5538777\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : going2think <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @GeruzoniAnsasu @ipwx @secondwtq @Vinty \u611f\u8c22\u5927\u5bb6\u7684\u5e2e\u52a9\uff0c\u6211\u5927\u6982\u6709\u4e2a\u601d\u8def\u4e86\uff0c\u4e4b\u524d\u7528\u7684\u6bd4\u8f83\u50bb\u74dc\uff0c\u5bf9\u9879\u76ee\u7684 vcxproj \u6587\u4ef6\u6ca1\u6709\u4ed4\u7ec6\u770b\u8fc7\uff0c\u5e94\u8be5\u662f\u53ef\u4ee5\u4fee\u6539\u8fd9\u4e2a\u6587\u4ef6\u8fbe\u5230\u76ee\u7684\u7684\uff0c\u518d\u6b21\u8c22\u8c22\u5927\u5bb6\u7684\u5e2e\u52a9\uff0c\u6211\u53bb\u8bd5\u4e00\u8bd5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5538778\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : QBugHunter <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u81ea\u5df1\u624b\u5199 cmake \u5c31\u4e0d\u4f1a\u9047\u5230\u8fd9\u79cd\u95ee\u9898                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>C++ \u4ee3\u7801\u4f5c\u4e3a submodul&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/397017"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=397017"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/397017\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=397017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=397017"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=397017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}