{"id":13622,"date":"2024-02-08T21:29:57","date_gmt":"2024-02-08T13:29:57","guid":{"rendered":"https:\/\/92it.top\/?p=13622"},"modified":"2024-02-08T22:23:51","modified_gmt":"2024-02-08T14:23:51","slug":"centos7-cmake-%e7%89%88%e6%9c%ac%e5%8d%87%e7%ba%a7%ef%bc%88%e7%94%b1-v2-8-12-2-%e5%8d%87%e7%ba%a7%e8%87%b3-v3-26-4%ef%bc%89","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=13622","title":{"rendered":"Centos7 cmake \u7248\u672c\u5347\u7ea7\uff08\u7531 v2.8.12.2 \u5347\u7ea7\u81f3 v3.26.4\uff09"},"content":{"rendered":"\n<p><strong>1.CMake\u5b9a\u4e49<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>CMake\u662f\u4e00\u4e2a\u8de8\u5e73\u53f0\u7684\u7f16\u8bd1(Build)\u5de5\u5177,\u53ef\u4ee5\u7528\u7b80\u5355\u7684\u8bed\u53e5\u6765\u63cf\u8ff0\u6240\u6709\u5e73\u53f0\u7684\u7f16\u8bd1\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<p>CMake\u80fd\u591f\u8f93\u51fa\u5404\u79cd\u5404\u6837\u7684makefile\u6216\u8005project\u6587\u4ef6\uff0c\u80fd\u6d4b\u8bd5\u7f16\u8bd1\u5668\u6240\u652f\u6301\u7684C++\u7279\u6027,\u7c7b\u4f3cUNIX\u4e0b\u7684automake\u3002<\/p>\n\n\n\n<p>CMake \u4e0d\u4ec5\u53ef\u4ee5\u7f16\u8bd1\u6e90\u4ee3\u7801\u3001\u5236\u4f5c\u7a0b\u5e8f\u5e93\u3001\u4ea7\u751f\u9002\u914d\u5668\uff08wrapper\uff09\u3001\u8fd8\u53ef\u4ee5\u7528\u4efb\u610f\u7684\u987a\u5e8f\u5efa\u6784\u6267\u884c\u6863\u3002CMake \u652f\u6301 in-place \u5efa\u6784\uff08\u4e8c\u8fdb\u6863\u548c\u6e90\u4ee3\u7801\u5728\u540c\u4e00\u4e2a\u76ee\u5f55\u6811\u4e2d\uff09\u548c out-of-place \u5efa\u6784\uff08\u4e8c\u8fdb\u6863\u5728\u522b\u7684\u76ee\u5f55\u91cc\uff09\uff0c\u56e0\u6b64\u53ef\u4ee5\u5f88\u5bb9\u6613\u4ece\u540c\u4e00\u4e2a\u6e90\u4ee3\u7801\u76ee\u5f55\u6811\u4e2d\u5efa\u6784\u51fa\u591a\u4e2a\u4e8c\u8fdb\u6863\u3002CMake \u4e5f\u652f\u6301\u9759\u6001\u4e0e\u52a8\u6001\u7a0b\u5f0f\u5e93\u7684\u5efa\u6784\u3002<\/p>\n\n\n\n<p>\u201cCMake\u201d\u8fd9\u4e2a\u540d\u5b57\u662f\u201ccross platform make\u201d\u7684\u7f29\u5199\u3002\u867d\u7136\u540d\u5b57\u4e2d\u542b\u6709\u201cmake\u201d\uff0c\u4f46\u662fCMake\u548cUnix\u4e0a\u5e38\u89c1\u7684\u201cmake\u201d\u7cfb\u7edf\u662f\u5206\u5f00\u7684\uff0c\u800c\u4e14\u66f4\u4e3a\u9ad8\u9636\u3002<\/p>\n\n\n\n<p><strong>2.CMake\u5e94\u7528\u573a\u666f<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u5047\u5982\u6211\u4eec\u6709\u4e00\u4e2a\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u7684\u90e8\u5206\u5de5\u7a0b\u5217\u8868\uff0c\u91cc\u9762\u6709\u8d85\u8fc740\u4e2a\u4e92\u76f8\u8c03\u7528\u7684\u5de5\u7a0b\u5171\u540c\u7ec4\u6210\uff0c\u4e00\u4e9b\u7528\u4e8e\u751f\u6210\u5e93\u6587\u4ef6\uff0c\u4e00\u4e9b\u7528\u4e8e\u5b9e\u73b0\u903b\u8f91\u529f\u80fd\u3002\u4ed6\u4eec\u4e4b\u95f4\u7684\u8c03\u7528\u5173\u7cfb\u590d\u6742\u800c\u4e25\u683c\uff0c\u5982\u679c\u6211\u60f3\u5728\u8fd9\u6837\u590d\u6742\u7684\u6846\u67b6\u4e0b\u8fdb\u884c\u4e8c\u6b21\u5f00\u53d1\uff0c\u663e\u7136\u53ea\u62e5\u6709\u5b83\u7684\u6e90\u7801\u662f\u8fdc\u8fdc\u4e0d\u591f\u7684\uff0c\u8fd8\u9700\u8981\u6e05\u695a\u7684\u660e\u767d\u8fd9\u51e0\u5341\u4e2a\u9879\u76ee\u4e4b\u95f4\u7684\u590d\u6742\u5173\u7cfb\uff0c\u5728\u6ca1\u6709\u539f\u4f5c\u8005\u7684\u5e2e\u52a9\u4e0b\u8fdb\u884c\u8fd9\u9879\u5de5\u4f5c\u51e0\u4e4e\u662f\u4e0d\u53ef\u80fd\u7684\u3002<\/p>\n\n\n\n<p>\u5373\u4f7f\u662f\u539f\u4f5c\u8005\u7ed9\u51fa\u4e86\u76f8\u5173\u7684\u7ed3\u6784\u6587\u6863\uff0c\u5bf9\u65b0\u624b\u6765\u8bf4\u5efa\u7acb\u5de5\u7a0b\u7684\u8fc7\u7a0b\u4f9d\u65e7\u662f\u6f2b\u957f\u800c\u8270\u8f9b\u7684\uff0c\u56e0\u6b64CMake\u7684\u4f5c\u7528\u5c31\u51f8\u663e\u51fa\u6765\u4e86\u3002\u539f\u4f5c\u8005\u53ea\u9700\u8981\u751f\u6210\u4e00\u4efdCMakeLists.txt\u6587\u6863\uff0c\u6846\u67b6\u7684\u4f7f\u7528\u8005\u4eec\u53ea\u9700\u8981\u5728\u4e0b\u8f7d\u6e90\u7801\u7684\u540c\u65f6\u4e0b\u8f7d\u4f5c\u8005\u63d0\u4f9b\u7684CMakeLists.txt\uff0c\u5c31\u53ef\u4ee5\u5229\u7528CMake\uff0c\u5728\u201d\u539f\u4f5c\u8005\u7684\u5e2e\u52a9\u4e0b\u201c\u8fdb\u884c\u5de5\u7a0b\u7684\u642d\u5efa\u3002<\/p>\n\n\n\n<p>\u6253\u4e2a\u66f4\u901a\u4fd7\u6613\u61c2\u7684\u6bd4\u55bb\uff0c\u5c0f\u5229\u5728\u8def\u8fb9\u6361\u74f6\u76d6\u8d5a\u4e86500\u4e07\u51c6\u5907\u4e70\u623f\uff0c\u4f46\u662f\u5c0f\u5229\u8fd9\u4e00\u9ebb\u888b\u76845\u6bdb\u3001\u4e00\u5757\u3001\u5341\u5757\u3001\u4e94\u5341\u3001\u4e00\u767e\u552e\u697c\u5904\u7684\u5c0f\u59d0\u59d0\u5acc\u9ebb\u70e6\u4e0d\u60f3\u6536\u8fd9\u4e9b\u94b1\uff0c\u90a3\u600e\u4e48\u529e\u5462\uff1f\u5c0f\u59d0\u59d0\u5efa\u8bae\u5c0f\u5229\u628a\u94b1\u62ff\u5230\u94f6\u884c\u53bb\u6362\u6210\u4e00\u5f20\u94f6\u884c\u5361\uff0c\u7136\u540e\u76f4\u63a5\u6765\u5237\u5361\u5c31\u884c\u5566\uff01CMake\u8fd9\u91cc\u5c31\u626e\u6f14\u94f6\u884c\u7684\u89d2\u8272\uff0c\u5e2e\u4f60\u53bb\u6574\u7406\u4f60\u7684\u8d44\u4ea7\u3002<\/p>\n\n\n\n<p><strong>3.CMake\u4e3b\u8981\u529f\u80fd<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<ul><li><strong>\u914d\u7f6e\u548c\u751f\u6210\u5404\u5927\u5e73\u53f0\u7684\u5de5\u7a0b(VS\u7684vcxproj\uff0cQt\u7684Pro)\uff1a<\/strong><\/li><\/ul>\n\n\n\n<p>\u6bd4\u5982\u8bbe\u7f6e\u8f93\u51fa\u76ee\u5f55\uff0c\u8bbe\u7f6e\u7f16\u8bd1\u5bf9\u8c61\u7684debug\u540e\u7f00\uff0c\u8bbe\u7f6e\u6e90\u7801\u5728\u5de5\u7a0b\u4e2d\u7684\u90a3\u4e2a\u6587\u4ef6\u5939\uff08Filter\uff09\uff0c\u914d\u7f6e\u9700\u8981\u4f9d\u8d56\u7684\u7b2c\u4e09\u65b9\u7684\u5934\u6587\u4ef6\u76ee\u5f55\uff0c\u5e93\u76ee\u5f55\u7b49\u7b49\u5c5e\u6027\u3002<\/p>\n\n\n\n<ul><li><strong>\u751f\u6210makefile\u6587\u4ef6<\/strong><\/li><\/ul>\n\n\n\n<p>\u8ba1\u7b97\u673a\u7f16\u8bd1\u6e90\u6587\u4ef6\u7684\u65f6\u5019\u662f\u4e00\u6761\u6307\u4ee4\u4e00\u6761\u6307\u4ee4\u7684\u53d1\u9001\u7ed9\u7f16\u8bd1\u5668\u6267\u884c\u7684\uff0c\u8fd9\u6837\u6548\u7387\u5f88\u4f4e\u4e0b\uff0c\u6240\u4ee5\u5c31\u4ea7\u751f\u4e86\u4e00\u79cd\u6587\u4ef6\uff0c\u628a\u6240\u6709\u7684\u547d\u4ee4\u5199\u5230\u4e00\u4e2a\u6587\u4ef6\u4e2d\uff0c\u8fd9\u4e2a\u6587\u4ef6\u5c31\u662fmakefile\u3002CMake\u751f\u6210\u4e86\u8fd9\u4e2amakefile\u4e4b\u540e\uff0c\u5404\u5927\u5e73\u53f0\u7684\u7f16\u8bd1\u5668\u90fd\u4f1a\u62ff\u5230\u8fd9\u4e2amakefile\u7136\u540e\u89e3\u6790\u5b83\u3002\u5c06\u4ed6\u7684\u547d\u4ee4\u89e3\u6790\u51fa\u6765\u4e00\u6761\u4e00\u6761\u6267\u884c\u3002<\/p>\n\n\n\n<p><strong>4.makefile\u4ecb\u7ecd<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<ul><li><strong>\u4ec0\u4e48\u662fmakefile\uff1f<\/strong><\/li><\/ul>\n\n\n\n<p>\u6216\u8bb8\u5f88\u591aWinodws\u7684\u7a0b\u5e8f\u5458\u90fd\u4e0d\u77e5\u9053\u8fd9\u4e2a\u4e1c\u897f\uff0c\u56e0\u4e3a\u90a3\u4e9bWindows\u7684IDE\u90fd\u4e3a\u4f60\u505a\u4e86\u8fd9\u4e2a\u5de5\u4f5c\uff0c\u4f46\u8981\u4f5c\u4e00\u4e2a\u597d\u7684\u548cprofessional\u7684\u7a0b\u5e8f\u5458\uff0cmakefile\u8fd8\u662f\u8981\u61c2\u3002\u8fd9\u5c31\u597d\u50cf\u73b0\u5728\u6709\u8fd9\u4e48\u591a\u7684HTML\u7684\u7f16\u8f91\u5668\uff0c\u4f46\u5982\u679c\u4f60\u60f3\u6210\u4e3a\u4e00\u4e2a\u4e13\u4e1a\u4eba\u58eb\uff0c\u4f60\u8fd8\u662f\u8981\u4e86\u89e3HTML\u7684\u6807\u8bc6\u7684\u542b\u4e49\u3002<\/p>\n\n\n\n<p>\u7279\u522b\u5728Unix\u4e0b\u7684\u8f6f\u4ef6\u7f16\u8bd1\uff0c\u4f60\u5c31\u4e0d\u80fd\u4e0d\u81ea\u5df1\u5199makefile\u4e86\uff0c\u4f1a\u4e0d\u4f1a\u5199makefile\uff0c\u4ece\u4e00\u4e2a\u4fa7\u9762\u8bf4\u660e\u4e86\u4e00\u4e2a\u4eba\u662f\u5426\u5177\u5907\u5b8c\u6210\u5927\u578b\u5de5\u7a0b\u7684\u80fd\u529b\u3002\u56e0\u4e3a\uff0cmakefile\u5173\u7cfb\u5230\u4e86\u6574\u4e2a\u5de5\u7a0b\u7684\u7f16\u8bd1\u89c4\u5219\u3002\u4e00\u4e2a\u5de5\u7a0b\u4e2d\u7684\u6e90\u6587\u4ef6\u4e0d\u8ba1\u6570\uff0c\u5176\u6309\u7c7b\u578b\u3001\u529f\u80fd\u3001\u6a21\u5757\u5206\u522b\u653e\u5728\u82e5\u5e72\u4e2a\u76ee\u5f55\u4e2d\uff0c<mark>makefile\u5b9a\u4e49\u4e86\u4e00\u7cfb\u5217\u7684\u89c4\u5219\u6765\u6307\u5b9a\uff0c\u54ea\u4e9b\u6587\u4ef6\u9700\u8981\u5148\u7f16\u8bd1\uff0c\u54ea\u4e9b\u6587\u4ef6\u9700\u8981\u540e\u7f16\u8bd1\uff0c\u54ea\u4e9b\u6587\u4ef6\u9700\u8981\u91cd\u65b0\u7f16\u8bd1\uff0c\u751a\u81f3\u4e8e\u8fdb\u884c\u66f4\u590d\u6742\u7684\u529f\u80fd\u64cd\u4f5c<\/mark>\uff0c\u56e0\u4e3amakefile\u5c31\u50cf\u4e00\u4e2aShell\u811a\u672c\u4e00\u6837\uff0c\u5176\u4e2d\u4e5f\u53ef\u4ee5\u6267\u884c\u64cd\u4f5c\u7cfb\u7edf\u7684\u547d\u4ee4\u3002makefile\u5e26\u6765\u7684\u597d\u5904\u5c31\u662f\u2014\u2014\u201c\u81ea\u52a8\u5316\u7f16\u8bd1\u201d\uff0c\u4e00\u65e6\u5199\u597d\uff0c\u53ea\u9700\u8981\u4e00\u4e2amake\u547d\u4ee4\uff0c\u6574\u4e2a\u5de5\u7a0b\u5b8c\u5168\u81ea\u52a8\u7f16\u8bd1\uff0c\u6781\u5927\u7684\u63d0\u9ad8\u4e86\u8f6f\u4ef6\u5f00\u53d1\u7684\u6548\u7387\u3002<\/p>\n\n\n\n<p>\u4f7f\u7528 GCC \u7684\u547d\u4ee4\u884c\u8fdb\u884c\u7a0b\u5e8f\u7f16\u8bd1\u5728\u5355\u4e2a\u6587\u4ef6\u4e0b\u662f\u6bd4\u8f83\u65b9\u4fbf\u7684\uff0c\u5f53\u5de5\u7a0b\u4e2d\u7684\u6587\u4ef6\u9010\u6e10\u589e\u591a\uff0c\u751a\u81f3\u53d8\u5f97\u5341\u5206\u5e9e\u5927\u7684\u65f6\u5019\uff0c\u4f7f\u7528 GCC \u547d\u4ee4\u7f16\u8bd1\u5c31\u4f1a\u53d8\u5f97\u529b\u4e0d\u4ece\u5fc3\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\u6211\u4eec\u9700\u8981\u501f\u52a9\u9879\u76ee\u6784\u9020\u5de5\u5177 make \u5e2e\u52a9\u6211\u4eec\u5b8c\u6210\u8fd9\u4e2a\u8270\u5de8\u7684\u4efb\u52a1\u3002 make \u662f\u4e00\u4e2a\u547d\u4ee4\u5de5\u5177\uff0c\u662f\u4e00\u4e2a\u89e3\u91ca makefile \u4e2d\u6307\u4ee4\u7684\u547d\u4ee4\u5de5\u5177\uff0c\u4e00\u822c\u6765\u8bf4\uff0c\u5927\u591a\u6570\u7684 IDE \u90fd\u6709\u8fd9\u4e2a\u547d\u4ee4\uff0c\u6bd4\u5982\uff1aVisual C++ \u7684 nmake\uff0cQtCreator \u7684 qmake \u7b49\u3002<\/p>\n\n\n\n<p>make \u5de5\u5177\u5728\u6784\u9020\u9879\u76ee\u7684\u65f6\u5019\u9700\u8981\u52a0\u8f7d\u4e00\u4e2a\u53eb\u505a makefile \u7684\u6587\u4ef6\uff0cmakefile \u5173\u7cfb\u5230\u4e86\u6574\u4e2a\u5de5\u7a0b\u7684\u7f16\u8bd1\u89c4\u5219\u3002\u4e00\u4e2a\u5de5\u7a0b\u4e2d\u7684\u6e90\u6587\u4ef6\u4e0d\u8ba1\u6570\uff0c\u5176\u6309\u7c7b\u578b\u3001\u529f\u80fd\u3001\u6a21\u5757\u5206\u522b\u653e\u5728\u82e5\u5e72\u4e2a\u76ee\u5f55\u4e2d\uff0cmakefile \u5b9a\u4e49\u4e86\u4e00\u7cfb\u5217\u7684\u89c4\u5219\u6765\u6307\u5b9a\u54ea\u4e9b\u6587\u4ef6\u9700\u8981\u5148\u7f16\u8bd1\uff0c\u54ea\u4e9b\u6587\u4ef6\u9700\u8981\u540e\u7f16\u8bd1\uff0c\u54ea\u4e9b\u6587\u4ef6\u9700\u8981\u91cd\u65b0\u7f16\u8bd1\uff0c\u751a\u81f3\u4e8e\u8fdb\u884c\u66f4\u590d\u6742\u7684\u529f\u80fd\u64cd\u4f5c\uff0c\u56e0\u4e3a makefile \u5c31\u50cf\u4e00\u4e2a Shell \u811a\u672c\u4e00\u6837\uff0c\u5176\u4e2d\u4e5f\u53ef\u4ee5\u6267\u884c\u64cd\u4f5c\u7cfb\u7edf\u7684\u547d\u4ee4\u3002<\/p>\n\n\n\n<p>makefile \u5e26\u6765\u7684\u597d\u5904\u5c31\u662f \u2014\u2014\u201c\u81ea\u52a8\u5316\u7f16\u8bd1\u201d\uff0c\u4e00\u65e6\u5199\u597d\uff0c\u53ea\u9700\u8981\u4e00\u4e2a make \u547d\u4ee4\uff0c\u6574\u4e2a\u5de5\u7a0b\u5b8c\u5168\u81ea\u52a8\u7f16\u8bd1\uff0c\u6781\u5927\u7684\u63d0\u9ad8\u4e86\u8f6f\u4ef6\u5f00\u53d1\u7684\u6548\u7387\u3002<\/p>\n\n\n\n<p>makefile \u6587\u4ef6\u6709\u4e24\u79cd\u547d\u540d\u65b9\u5f0f makefile \u548c Makefile\uff0c<mark>\uff08\u6ce8\u610f\uff1amakefile\u6587\u4ef6\u5c31\u53eb\u8fd9\u4e2a\u540d\u5b57\uff0c\u662f\u524d\u9762\u8fd9\u4e24\u79cd\u6587\u4ef6\u540d\uff0c\u5e76\u4e14\u6ca1\u6709\u6269\u5c55\u540d\u6216\u8005\u540e\u7f00\uff09<\/mark>\uff0c\u6784\u5efa\u9879\u76ee\u7684\u65f6\u5019\u5728\u54ea\u4e2a\u76ee\u5f55\u4e0b\u6267\u884c\u6784\u5efa\u547d\u4ee4 make \u8fd9\u4e2a\u76ee\u5f55\u4e0b\u7684 makefile \u6587\u4ef6\u5c31\u4f1a\u522b\u52a0\u8f7d\uff0c\u56e0\u6b64\u5728\u4e00\u4e2a\u9879\u76ee\u4e2d\u53ef\u4ee5\u6709\u591a\u4e2a makefile \u6587\u4ef6\uff0c\u5206\u522b\u4f4d\u4e8e\u4e0d\u540c\u7684\u9879\u76ee\u76ee\u5f55\u4e2d\u3002<\/p>\n\n\n\n<ul><li><strong>\u4e3a\u4ec0\u4e48\u8981\u7528makefile\uff1f<\/strong><\/li><\/ul>\n\n\n\n<p>\u5bf9\u4e8e\u4e00\u4e2a\u5927\u578b\u8f6f\u4ef6\uff0c\u5176\u7f16\u8bd1\u3001\u7ef4\u62a4\u662f\u4e00\u4e2a\u590d\u6742\u800c\u8017\u65f6\u7684\u8fc7\u7a0b\u3002\u5b83\u6d89\u53ca\u5230\u5927\u91cf\u7684\u6587\u4ef6\u3001\u76ee\u5f55\uff0c\u8fd9\u4e9b\u6587\u4ef6\u53ef\u80fd\u662f\u5728\u4e0d\u540c\u7684\u65f6\u95f4\u3001\u7531\u4e0d\u540c\u7684\u4eba\u3001\u5728\u4e0d\u540c\u7684\u5730\u65b9\u5206\u522b\u5199\u7684\uff0c\u5176\u4e2d\u4e00\u4e9b\u662f\u7a0b\u5e8f\uff0c\u6709\u4e9b\u662f\u6570\u636e\uff0c\u6709\u4e9b\u662f\u6587\u6863\uff0c\u6709\u4e9b\u662f\u884d\u751f\u6587\u4ef6\u3002<\/p>\n\n\n\n<p>\u751a\u81f3\u53c2\u4e0e\u5f00\u53d1\u7684\u4eba\u5458\u4e5f\u4e0d\u4e00\u5b9a\u6e05\u695a\u6240\u6709\u6587\u4ef6\u7684\u7ec6\u8282\uff0c\u5305\u62ec\u5982\u4f55\u5904\u7406\u5b83\u4eec\u3002\u6b64\u5916\uff0c\u6784\u6210\u8f6f\u4ef6\u7684\u6587\u4ef6\u6570\u76ee\u53ef\u80fd\u8fbe\u5230\u6210\u767e\u4e0a\u5343\uff0c\u751a\u81f3\u6210\u5343\u4e0a\u4e07\u4e2a\uff0c\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u5f53\u4fee\u6539\u4e86\u5c11\u91cf\u51e0\u4e2a\u6587\u4ef6\u540e\uff0c\u5f80\u5f80\u53ea\u9700\u8981\u91cd\u65b0\u7f16\u8bd1\u3001\u751f\u6210\u5c11\u6570\u51e0\u4e2a\u6587\u4ef6\u3002\u6709\u6548\u5730\u63cf\u8ff0\u8fd9\u4e9b\u6587\u4ef6\u4e4b\u95f4\u7684\u4f9d\u8d56\u5173\u7cfb\u4ee5\u53ca\u5904\u7406\u547d\u4ee4\uff0c\u5f53\u4e2a\u522b\u6587\u4ef6\u6539\u52a8\u540e\u4ec5\u6267\u884c\u5fc5\u8981\u7684\u5904\u7406\uff0c\u800c\u4e0d\u5fc5\u91cd\u590d\u6574\u4e2a\u7f16\u8bd1\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u8f6f\u4ef6\u5f00\u53d1\u7684\u6548\u7387\u3002<\/p>\n\n\n\n<p><strong>5.CMakeLists.txt\u4ecb\u7ecd<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>CMakelists.txt\u662fCmake\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u7528\u4e8e\u63cf\u8ff0\u7f16\u8bd1\u65b9\u5f0f\u548c\u9879\u76ee\u4f9d\u8d56\u3002CMakeLists.txt\u6587\u4ef6\u662fCMake\u7f16\u8bd1\u7cfb\u7edf\u7f16\u8bd1\u8f6f\u4ef6\u5305\u8fc7\u7a0b\u7684\u8f93\u5165\u6587\u4ef6\uff0c\u4efb\u4f55CMake\u517c\u5bb9\u5305\u90fd\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2aCMakeLists.txt\u6587\u4ef6\uff0c\u8fd9\u4e9b\u6587\u4ef6\u63cf\u8ff0\u4e86\u5982\u4f55\u7f16\u8bd1\u4ee3\u7801\u4ee5\u53ca\u5c06\u5176\u5b89\u88c5\u5230\u54ea\u91cc\u3002\u5728windows\u4e0bCMake \u4f1a\u8bfb\u53d6 CMakeLists.txt \u4e2d\u7684\u8bbe\u7f6e\uff0c\u5e76\u751f\u6210\u9879\u76ee\u7684 makefile \u6216 Visual Studio \u5de5\u7a0b\u6587\u4ef6\u3002<\/p>\n\n\n\n<p>makefile\u6587\u4ef6\u7684\u7f16\u5199\u5b9e\u5728\u662f\u4e2a\u7e41\u7410\u7684\u4e8b\uff0c\u4e8e\u662f\uff0cCMake\u51fa\u73b0\u4e86\uff0c\u4f7f\u5f97\u8fd9\u4e00\u5207\u53d8\u5f97\u7b80\u5355\uff0cCMake\u901a\u8fc7CMakeLists.txt\u8bfb\u5165\u6240\u6709\u6e90\u6587\u4ef6\u81ea\u52a8\u751f\u6210makefile\uff0c\u8fdb\u800c\u5c06\u6e90\u6587\u4ef6\u7f16\u8bd1\u6210\u53ef\u6267\u884c\u6587\u4ef6\u6216\u5e93\u6587\u4ef6\u3002<\/p>\n\n\n\n<p><strong>6.\u603b\u7ed3<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Cmake\u662f\u7528\u6765makefile\u7684\u4e00\u4e2a\u5de5\u5177\uff0c\u8bfb\u5165\u6240\u6709\u6e90\u6587\u4ef6\u4e4b\u540e\uff0c\u81ea\u52a8\u751f\u6210makefile\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/02\/image-68-1024x226.png\" alt=\"\" class=\"wp-image-13625\" width=\"541\" height=\"119\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/02\/image-68-1024x226.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/02\/image-68-300x66.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/02\/image-68-768x170.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/02\/image-68-830x183.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/02\/image-68-230x51.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/02\/image-68-350x77.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/02\/image-68-480x106.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2024\/02\/image-68.png 1468w\" sizes=\"(max-width: 541px) 100vw, 541px\" \/><\/figure><\/div>\n\n\n\n<p><strong>7.centos \u5347\u7ea7 cmake \u65b9\u6cd5<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u5728centos7 <a rel=\"noreferrer noopener\" href=\"https:\/\/so.csdn.net\/so\/search?q=yum&amp;spm=1001.2101.3001.7020\" target=\"_blank\">yum<\/a>\u6e90\u4e2d\u548c\u7cfb\u7edf\u81ea\u5e26\u7684cmake\u7248\u672c\u4e3a2.8.12.2\uff1b\u5728\u7f16\u8bd1\u67d0\u4e9b\u6587\u4ef6\u7684\u65f6\u5019\u4f1a\u63d0\u9192cmake\u7248\u672c\u8fc7\u4f4e\uff0c\u672c\u6587\u65e8\u5728\u89e3\u51b3cmake\u7684\u66f4\u65b0\u95ee\u9898<\/p>\n\n\n\n<p>cmake\u5b98\u7f51\uff1a<a href=\"https:\/\/cmake.org\/\">https:\/\/cmake.org\/<\/a><br>cmake\u4e0b\u8f7d\uff1a<a href=\"https:\/\/cmake.org\/files\/\">https:\/\/cmake.org\/files\/<\/a><\/p>\n\n\n\n<p>1. \u67e5\u770b\u5f53\u524dcmake\u7248\u672c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@localhost ~]# cmake -version\ncmake version 2.8.12.2<\/pre>\n\n\n\n<p>2. \u8fdb\u884c\u5378\u8f7d<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@localhost ~]# yum remove -y cmake<\/pre>\n\n\n\n<p>3. \u8fdb\u884c\u5b89\u88c5\u5305\u7684\u4e0b\u8f7d\uff0c\u4e5f\u53ef\u4ee5\u4e0b\u8f7d\u597d\u5b89\u88c5\u5305\u540e\u4f20\u81f3\u76f8\u5e94\u7684\u76ee\u5f55<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@localhost ~]# mkdir \/opt\/cmake\n[root@localhost ~]# cd \/opt\/cmake\/<\/pre>\n\n\n\n<p>4. \u4e0b\u8f7d\u6216\u62f7\u8d1d\uff0c\u89e3\u538b<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@localhost cmake]# wget https:\/\/cmake.org\/files\/v3.26\/cmake-3.26.4.tar.gz\n[root@localhost cmake]# tar -zxvf cmake-3.26.4.tar.gz\n<\/pre>\n\n\n\n<p>5. \u5b89\u88c5\u7f16\u8bd1\u5de5\u5177<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@localhost cmake]# yum install -y gcc gcc-c++  <\/pre>\n\n\n\n<p>6. \u8fdb\u884c\u7f16\u8bd1\u8fde\u63a5<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@localhost cmake]# .\/configure --prefix=\/usr\/local\/cmake<\/pre>\n\n\n\n<p>7. \u5b89\u88c5<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@localhost cmake]# cd cmake-3.26.4\n[root@localhost cmake-3.26.4]# make &amp;&amp; make install <\/pre>\n\n\n\n<p>8. \u521b\u5efa\u94fe\u63a5<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@localhost cmake-3.16.6]# ln -s \/usr\/local\/cmake\/bin\/cmake \/usr\/bin\/cmake <\/pre>\n\n\n\n<p>9. \u67e5\u770b\u7248\u672c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@localhost cmake-3.26.4]# cmake -version\ncmake version 3.26.4\nCMake suite maintained and supported by Kitware (kitware.com\/cmake).<\/pre>\n\n\n\n<p>10\u3001\u5982\u679c\u7b2c9\u6b65\u4e0d\u60f3\u521b\u5efa\u94fe\u63a5\u7684\u8bdd\uff0c\u4e5f\u53ef\u4ee5\u4fee\u6539\u73af\u5883\u53d8\u91cf<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@localhost ~]# vim \/etc\/profile\n...\nexport CMAKE_HOME=\/usr\/local\/cmake\nexport PATH=$PATH:$CMAKE_HOME\/bin\n## \u5237\u65b0\u914d\u7f6e\n[root@localhost ~]# source \/etc\/profile\nCentos7 \u5347\u7ea7 cmake v3.26.4 \u64cd\u4f5c\u5b8c\u6bd5\uff01<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1.CMake\u5b9a\u4e49 CMake\u662f\u4e00\u4e2a\u8de8\u5e73\u53f0\u7684\u7f16\u8bd1(Build)\u5de5\u5177,\u53ef\u4ee5\u7528\u7b80\u5355\u7684\u8bed\u53e5\u6765\u63cf\u8ff0\u6240\u6709\u5e73\u53f0\u7684\u7f16\u8bd1\u8fc7\u7a0b\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/13622"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13622"}],"version-history":[{"count":3,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/13622\/revisions"}],"predecessor-version":[{"id":13627,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/13622\/revisions\/13627"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}