{"id":37084,"date":"2019-10-31T22:15:40","date_gmt":"2019-10-31T19:15:40","guid":{"rendered":"https:\/\/prohoster.info\/blog\/c-i-cmake-bratya-navek-chast-ii\/"},"modified":"2019-10-31T22:15:40","modified_gmt":"2019-10-31T19:15:40","slug":"c-i-cmake-bratya-navek-chast-ii","status":"publish","type":"post","link":"https:\/\/prohoster.info\/bg\/blog\/administrirovanie\/c-i-cmake-bratya-navek-chast-ii","title":{"rendered":"C++ \u0438 CMake \u2014 \u0437\u0430\u0432\u0438\u043d\u0430\u0433\u0438 \u0431\u0440\u0430\u0442\u044f, \u0447\u0430\u0441\u0442 II","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p><img decoding=\"async\" alt=\"C++ \u0438 CMake \u2014 \u0437\u0430\u0432\u0438\u043d\u0430\u0433\u0438 \u0431\u0440\u0430\u0442\u044f, \u0447\u0430\u0441\u0442 II\" src=\"\/wp-content\/uploads\/2019\/08\/1d86b8b1668ae29ff3e634df9059d9b1.png\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p><noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/461817\/\">\u0412 \u043f\u0440\u0435\u0434\u0438\u0448\u043d\u0430\u0442\u0430 \u0447\u0430\u0441\u0442<\/a><\/noindex> \u0432 \u0442\u043e\u0437\u0438 \u0443\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u0435\u043d \u0440\u0430\u0437\u043a\u0430\u0437 \u0441\u0435 \u0433\u043e\u0432\u043e\u0440\u0435\u0448\u0435 \u0437\u0430 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u044f\u0442\u0430 \u043d\u0430 \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u0430\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0432 \u0440\u0430\u043c\u043a\u0438\u0442\u0435 \u043d\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043d\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0438 \u0437\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u0430\u0446\u0438\u044f CMake.<\/p>\n<p><\/p>\n<p>\u0422\u043e\u0437\u0438 \u043f\u044a\u0442 \u0449\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438 \u0449\u0435 \u043e\u0431\u0441\u044a\u0434\u0438\u043c \u043a\u0430\u043a \u0434\u0430 \u0441\u0432\u044a\u0440\u0436\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u0438\u0442\u0435 \u043f\u043e\u043c\u0435\u0436\u0434\u0443 \u0438\u043c.<\/p>\n<p><\/p>\n<blockquote><p>\u041a\u0430\u043a\u0442\u043e \u0432\u0438\u043d\u0430\u0433\u0438, \u0442\u0435\u0437\u0438, \u043a\u043e\u0438\u0442\u043e \u043d\u0435 \u043c\u043e\u0433\u0430\u0442 \u0434\u0430 \u0447\u0430\u043a\u0430\u0442, \u043c\u043e\u0433\u0430\u0442 \u0432\u0435\u0434\u043d\u0430\u0433\u0430 <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/izvolov\/mylib\">\u0434\u0430 \u0441\u0435 \u043d\u0430\u0441\u043e\u0447\u0430\u0442 \u043a\u044a\u043c \u043e\u0431\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0443\u043c<\/a><\/noindex> \u0438 \u0434\u0430 \u043e\u043f\u0438\u0442\u0430\u0442 \u0432\u0441\u0438\u0447\u043a\u043e \u0441\u0430\u043c\u0438.<\/p><\/blockquote>\n<p><noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><br \/>\n<noindex><a rel=\"nofollow\" name=\"contents\"><\/a><\/noindex><\/p>\n<h2>\u0421\u044a\u0434\u044a\u0440\u0436\u0430\u043d\u0438\u0435<\/h2>\n<p><\/p>\n<ol>\n<li><noindex><a rel=\"nofollow\" href=\"#divide\">\u0420\u0430\u0437\u0434\u0435\u043b\u044f\u0439<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"#impera\">\u0426\u0430\u0440\u0443\u0432\u0430\u0439<\/a><\/noindex><\/li>\n<\/ol>\n<p>\n<noindex><a rel=\"nofollow\" name=\"divide\"><\/a><\/noindex><\/p>\n<h2><noindex><a rel=\"nofollow\" href=\"#contents\">\u0420\u0430\u0437\u0434\u0435\u043b\u044f\u0439<\/a><\/noindex><\/h2>\n<p><\/p>\n<p>\u041f\u044a\u0440\u0432\u043e\u0442\u043e \u043d\u0435\u0449\u043e, \u043a\u043e\u0435\u0442\u043e \u0442\u0440\u044f\u0431\u0432\u0430 \u0434\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u043c, \u0437\u0430 \u0434\u0430 \u043f\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u043c \u043d\u0430\u0448\u0430\u0442\u0430 \u0432\u0438\u0441\u043e\u043a\u0430 \u0446\u0435\u043b, \u0435 \u0434\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0432\u0430\u043d\u043e\u0442\u043e \u0441\u043e\u0444\u0442\u0443\u0435\u0440\u043d\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u043d\u0438 \u0438\u0437\u043e\u043b\u0438\u0440\u0430\u043d\u0438 \u0431\u043b\u043e\u043a\u043e\u0432\u0435, \u043a\u043e\u0438\u0442\u043e \u0441\u0430 \u0443\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u0430\u043d\u0438 \u043e\u0442 \u0433\u043b\u0435\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u043d\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f.<\/p>\n<p><\/p>\n<p>\u0412 \u043f\u044a\u0440\u0432\u0430\u0442\u0430 \u0447\u0430\u0441\u0442 \u0431\u0435\u0448\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u0442\u0430\u043a\u044a\u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435\u043d \u0431\u043b\u043e\u043a \u2014 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u044a\u0441 \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430. \u0421\u0435\u0433\u0430 \u0449\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u044a\u043c \u043d\u0430\u0448\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430.<\/p>\n<p><\/p>\n<p>\u0417\u0430 \u0446\u0435\u043b\u0442\u0430 \u0449\u0435 \u0438\u0437\u043d\u0435\u0441\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u0442\u0430 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0442\u0430 <code>myfunc<\/code> \u0432 \u043e\u0442\u0434\u0435\u043b\u0435\u043d <code>.cpp<\/code>-\u0444\u0430\u0439\u043b:<\/p>\n<p><\/p>\n<pre><code class=\"diff\">diff --git a\/include\/mylib\/myfeature.hpp b\/include\/mylib\/myfeature.hpp\nindex 43db388..ba62b4f 100644\n--- a\/include\/mylib\/myfeature.hpp\n+++ b\/include\/mylib\/myfeature.hpp\n@@ -46,8 +46,5 @@ namespace mylib\n\n         ~  \u0432\u0438\u0436 mystruct\n      * \/\n-    inline bool myfunc (mystruct)\n-    {\n-        return true;\n-    }\n+    bool myfunc (mystruct);\n }\ndiff --git a\/src\/mylib\/myfeature.cpp b\/src\/mylib\/myfeature.cpp\nnew file mode 100644\nindex 0000000..abb5004\n--- \/dev\/null\n+++ b\/src\/mylib\/myfeature.cpp\n@@ -0,0 +1,9 @@\n+#include \n+\n+namespace mylib\n+{\n+    bool myfunc (mystruct)\n+    {\n+        return true;\n+    }\n+}<\/code><\/pre>\n<p><\/p>\n<p>\u0421\u043b\u0435\u0434 \u0442\u043e\u0432\u0430 \u0449\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 (<code>myfeature<\/code>), \u043a\u043e\u044f\u0442\u043e \u0449\u0435 \u0441\u0435 \u0441\u044a\u0441\u0442\u043e\u0438 \u043e\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u0438\u0448\u043d\u0430\u0442\u0430 \u0441\u0442\u044a\u043f\u043a\u0430 <code>.cpp<\/code>-\u0444\u0430\u0439\u043b. \u041d\u043e\u0432\u0430\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0438\u0437\u0438\u0441\u043a\u0432\u0430 \u0432\u0435\u0447\u0435 \u043d\u0430\u043b\u0438\u0447\u043d\u0438 \u0437\u0430\u0433\u043b\u0430\u0432\u0438\u044f \u0438 \u0437\u0430 \u0434\u0430 \u043e\u0441\u0438\u0433\u0443\u0440\u0438\u043c \u0442\u043e\u0432\u0430, \u043c\u043e\u0436\u0435\u043c \u0438 \u0442\u0440\u044f\u0431\u0432\u0430 \u0434\u0430 \u044f \u0441\u0432\u044a\u0440\u0436\u0435\u043c \u0441 \u043d\u0430\u043b\u0438\u0447\u043d\u0430\u0442\u0430 \u0446\u0435\u043b <code>mylib<\/code>. \u0421\u0432\u044a\u0440\u0437\u0432\u0430\u043d\u0435\u0442\u043e \u043c\u0435\u0436\u0434\u0443 \u0442\u044f\u0445 \u0435 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e, \u043a\u043e\u0435\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0432\u0430, \u0447\u0435 \u0432\u0441\u0438\u0447\u043a\u043e, \u043a\u043e\u0435\u0442\u043e \u0449\u0435 \u0431\u044a\u0434\u0435 \u0441\u0432\u044a\u0440\u0437\u0430\u043d\u043e \u0441 \u0446\u0435\u043b\u0442\u0430 <code>myfeature<\/code>, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u0449\u0435 \u043f\u043e\u043b\u0443\u0447\u0438 \u0438 \u0446\u0435\u043b\u0442\u0430 <code>mylib<\/code> (<noindex><a rel=\"nofollow\" href=\"https:\/\/cmake.org\/cmake\/help\/v3.14\/command\/target_link_libraries.html#libraries-for-a-target-and-or-its-dependents\">\u043f\u043e\u0432\u0435\u0447\u0435 \u0437\u0430 \u043d\u0430\u0447\u0438\u043d\u0438\u0442\u0435 \u043d\u0430 \u0441\u0432\u044a\u0440\u0437\u0432\u0430\u043d\u0435<\/a><\/noindex>). <\/p>\n<p><\/p>\n<pre><code class=\"diff\">diff --git a\/CMakeLists.txt b\/CMakeLists.txt\nindex 108045c..0de77b8 100644\n--- a\/CMakeLists.txt\n+++ b\/CMakeLists.txt\n@@ -64,6 +64,17 @@ target_compile_features(mylib INTERFACE cxx_std_17)\n\n add_library(Mylib::mylib ALIAS mylib)\n\n+###################################################################################################\n+##\n+##      \u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\n+##\n+###################################################################################################\n+\n+add_library(myfeature src\/mylib\/myfeature.cpp)\n+target_link_libraries(myfeature PUBLIC mylib)\n+\n+add_library(Mylib::myfeature ALIAS myfeature)\n+<\/code><\/pre>\n<p><\/p>\n<p>\u0421\u043b\u0435\u0434 \u0442\u043e\u0432\u0430 \u0449\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u0430\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441\u044a\u0449\u043e \u0442\u0430\u043a\u0430 \u0434\u0430 \u0431\u044a\u0434\u0435 \u0438\u043d\u0441\u0442\u0430\u043b\u0438\u0440\u0430\u043d\u0430 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0430:<\/p>\n<p><\/p>\n<pre><code class=\"diff\">@@ -72,7 +83,7 @@ add_library(Mylib::mylib ALIAS mylib)\n\n install(DIRECTORY include\/mylib DESTINATION include)\n\n-install(TARGETS mylib EXPORT MylibConfig)\n+install(TARGETS mylib myfeature EXPORT MylibConfig)\n install(EXPORT MylibConfig NAMESPACE Mylib:: DESTINATION share\/Mylib\/cmake)\n\n include(CMakePackageConfigHelpers)<\/code><\/pre>\n<p><\/p>\n<p>\u0422\u0440\u044f\u0431\u0432\u0430 \u0434\u0430 \u0441\u0435 \u043e\u0431\u044a\u0440\u043d\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0435 \u0437\u0430 \u0446\u0435\u043b\u0442\u0430 <code>myfeature<\/code>, \u043a\u0430\u043a\u0442\u043e \u0438 \u0437\u0430 <code>mylib<\/code> \u0435 \u0441\u044a\u0437\u0434\u0430\u0434\u0435\u043d \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441 <code>Mylib::<\/code>. \u0421\u044a\u0449\u043e\u0442\u043e \u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0438 \u0437\u0430 \u0434\u0432\u0435\u0442\u0435 \u0446\u0435\u043b\u0438 \u043f\u0440\u0438 \u0435\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0430\u043d\u0435 \u0437\u0430 \u0438\u043d\u0441\u0442\u0430\u043b\u0430\u0446\u0438\u044f \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0430. \u0422\u043e\u0432\u0430 \u0434\u0430\u0432\u0430 \u0432\u044a\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442 \u0437\u0430 \u0443\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u0430\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0446\u0435\u043b\u0438\u0442\u0435 \u043f\u0440\u0438 \u0432\u0441\u044f\u043a\u0430 <noindex><a rel=\"nofollow\" href=\"#impera\">\u0441\u0445\u0435\u043c\u0430 \u043d\u0430 \u0441\u0432\u044a\u0440\u0437\u0432\u0430\u043d\u0435<\/a><\/noindex>.<\/p>\n<p><\/p>\n<p>\u0421\u043b\u0435\u0434 \u0442\u043e\u0432\u0430 \u043e\u0441\u0442\u0430\u0432\u0430 \u0434\u0430 \u0441\u0432\u044a\u0440\u0436\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u043d\u0438\u0442\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u0435 \u0441 \u043d\u043e\u0432\u0430\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 (\u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0442\u0430 <code>myfunc<\/code> \u0431\u0435 \u0438\u0437\u043d\u0435\u0441\u0435\u043d\u0430 \u043e\u0442 \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u0438\u044f \u0444\u0430\u0439\u043b, \u0442\u0430\u043a\u0430 \u0447\u0435 \u0441\u0435\u0433\u0430 \u0442\u0440\u044f\u0431\u0432\u0430 \u0434\u0430 \u0441\u0435 \u043b\u0438\u043d\u043a\u043e\u0432\u0430\u043c\u0435):<\/p>\n<p><\/p>\n<pre><code class=\"diff\">diff --git a\/test\/CMakeLists.txt b\/test\/CMakeLists.txt\nindex 5620be4..bc1266c 100644\n--- a\/test\/CMakeLists.txt\n+++ b\/test\/CMakeLists.txt\n@@ -4,7 +4,7 @@ add_executable(mylib-unit-tests test_main.cpp)\n target_sources(mylib-unit-tests PRIVATE mylib\/myfeature.cpp)\n target_link_libraries(mylib-unit-tests\n     PRIVATE\n-        Mylib::mylib\n+        Mylib::myfeature\n         doctest::doctest\n )<\/code><\/pre>\n<p><\/p>\n<p>\u0417\u0430\u0433\u043b\u0430\u0432\u0438\u044f\u0442\u0430 (<code>Mylib::mylib<\/code>) \u0432\u0435\u0447\u0435 \u043d\u0435 \u0442\u0440\u044f\u0431\u0432\u0430 \u0434\u0430 \u0441\u0435 \u0432\u043a\u043b\u044e\u0447\u0432\u0430\u0442 \u043e\u0442\u0434\u0435\u043b\u043d\u043e, \u0437\u0430\u0449\u043e\u0442\u043e, \u043a\u0430\u043a\u0442\u043e \u0432\u0435\u0447\u0435 \u0431\u0435 \u0441\u043f\u043e\u043c\u0435\u043d\u0430\u0442\u043e, \u0442\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u0441\u0435 \u0432\u043a\u043b\u044e\u0447\u0432\u0430\u0442 \u0437\u0430\u0435\u0434\u043d\u043e \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0442\u0430 (<code>Mylib::myfeature<\/code>).<\/p>\n<p><\/p>\n<p>\u0418 \u0449\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u044f\u043a\u043e\u043b\u043a\u043e \u043d\u044e\u0430\u043d\u0441\u0430, \u0437\u0430 \u0434\u0430 \u043e\u0441\u0438\u0433\u0443\u0440\u0438\u043c \u0438\u0437\u043c\u0435\u0440\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043f\u043e\u043a\u0440\u0438\u0442\u0438\u0435\u0442\u043e \u0441 \u043e\u0433\u043b\u0435\u0434 \u043d\u0430 \u043d\u043e\u0432\u043e\u043f\u0440\u0438\u0441\u0442\u0438\u0433\u043d\u0430\u043b\u0430\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430:<\/p>\n<p><\/p>\n<pre><code class=\"diff\">@@ -15,11 +15,16 @@ if(MYLIB_COVERAGE AND GCOVR_EXECUTABLE)\n     target_compile_options(mylib-unit-tests PRIVATE --coverage)\n     target_link_libraries(mylib-unit-tests PRIVATE gcov)\n\n+    target_compile_options(myfeature PRIVATE --coverage)\n+    target_link_libraries(myfeature PRIVATE gcov)\n+\n     add_custom_target(coverage\n         COMMAND\n             ${GCOVR_EXECUTABLE}\n-                --root=${PROJECT_SOURCE_DIR}\/include\/\n-                --object-directory=${CMAKE_CURRENT_BINARY_DIR}\n+                --root=${PROJECT_SOURCE_DIR}\/\n+                --filter=${PROJECT_SOURCE_DIR}\/include\n+                --filter=${PROJECT_SOURCE_DIR}\/src\n+                --object-directory=${PROJECT_BINARY_DIR}\n         DEPENDS\n             check\n     )<\/code><\/pre>\n<p><\/p>\n<p>\u041c\u043e\u0436\u0435 \u0434\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u043e\u0432\u0435\u0447\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0438\u0437\u043f\u044a\u043b\u043d\u0438\u043c\u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u0435 \u0438 \u0442.\u043d. \u0412\u0430\u0436\u043d\u043e \u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043e \u043a\u043e\u0438 \u0446\u0435\u043b\u0438 \u0441\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043d\u0430 \u043d\u0430\u0448\u0438\u044f \u043c\u043e\u0434\u0443\u043b, \u0442.\u0435. \u0438\u0437\u043b\u0438\u0437\u0430\u0442 \u043d\u0430\u0432\u044a\u043d.<\/p>\n<p>\n<noindex><a rel=\"nofollow\" name=\"impera\"><\/a><\/noindex><\/p>\n<h2><noindex><a rel=\"nofollow\" href=\"#contents\">\u0426\u0430\u0440\u0443\u0432\u0430\u0439<\/a><\/noindex><\/h2>\n<p><\/p>\n<p>\u0421\u0435\u0433\u0430 \u0438\u043c\u0430\u043c\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0438 \u043c\u043e\u0434\u0443\u043b\u043d\u0438 \u0431\u043b\u043e\u043a\u043e\u0432\u0435 \u0438 \u043c\u043e\u0436\u0435\u043c \u0434\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u044f\u0445: \u0434\u0430 \u0433\u0438 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0440\u0430\u043d\u0435 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441 \u0432\u0441\u044f\u043a\u0430\u043a\u0432\u0430 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442, \u0438\u043d\u0441\u0442\u0430\u043b\u0438\u0440\u0430\u0439\u043a\u0438 \u0433\u0438 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0430 \u0438\u043b\u0438 \u0441\u0432\u044a\u0440\u0437\u0432\u0430\u0439\u043a\u0438 \u0433\u0438 \u043f\u043e\u043c\u0435\u0436\u0434\u0443 \u0438\u043c \u0432 \u0440\u0430\u043c\u043a\u0438\u0442\u0435 \u043d\u0430 \u0435\u0434\u0438\u043d\u043d\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0437\u0430 \u0441\u0431\u043e\u0440\u043a\u0430.<\/p>\n<p><\/p>\n<h3 id=\"ustanovka-v-sistemu\">\u0418\u043d\u0441\u0442\u0430\u043b\u0430\u0446\u0438\u044f \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0430<\/h3>\n<p><\/p>\n<p>\u0415\u0434\u0438\u043d \u043e\u0442 \u043d\u0430\u0447\u0438\u043d\u0438\u0442\u0435 \u0437\u0430 \u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430\u043d\u0435 \u043d\u0430 \u043c\u043e\u0434\u0443\u043b\u0430 \u0435 \u0434\u0430 \u0438\u043d\u0441\u0442\u0430\u043b\u0438\u0440\u0430\u043c\u0435 \u043d\u0430\u0448\u0438\u044f \u043c\u043e\u0434\u0443\u043b \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0430.<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">cmake --build \u043f\u044a\u0442\/\u043a\/\u0441\u0431\u043e\u0440\u043e\u0447\u043d\u0430\u0442\u0430\/\u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f --target install<\/code><\/pre>\n<p><\/p>\n<p>\u0421\u043b\u0435\u0434 \u0442\u043e\u0432\u0430 \u0442\u043e\u0439 \u043c\u043e\u0436\u0435 \u0434\u0430 \u0441\u0435 \u0441\u0432\u044a\u0440\u0436\u0435 \u0432 \u0432\u0441\u0435\u043a\u0438 \u0434\u0440\u0443\u0433 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u0442\u0430 \u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u0442\u0430 <noindex><a rel=\"nofollow\" href=\"https:\/\/cmake.org\/cmake\/help\/v3.14\/command\/find_package.html\"><code>find_package<\/code><\/a><\/noindex>.<\/p>\n<p><\/p>\n<pre><code class=\"cmake\">find_package(Mylib 1.0 REQUIRED)<\/code><\/pre>\n<p><\/p>\n<h3 id=\"podklyuchenie-v-kachestve-podmodulya\">\u0421\u0432\u044a\u0440\u0437\u0432\u0430\u043d\u0435 \u043a\u0430\u0442\u043e \u043f\u043e\u0434\u043c\u043e\u0434\u0443\u043b<\/h3>\n<p><\/p>\n<p>\u0414\u0440\u0443\u0433 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0435 \u0434\u0430 \u0441\u0432\u044a\u0440\u0436\u0435\u043c \u043f\u0430\u043f\u043a\u0430\u0442\u0430 \u0441 \u043d\u0430\u0448\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u0434\u0440\u0443\u0433 \u043f\u0440\u043e\u0435\u043a\u0442 \u043a\u0430\u0442\u043e \u043f\u043e\u0434\u043c\u043e\u0434\u0443\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u0442\u0430 \u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u0442\u0430 <noindex><a rel=\"nofollow\" href=\"https:\/\/cmake.org\/cmake\/help\/v3.14\/command\/add_subdirectory.html\"><code>add_subdirectory<\/code><\/a><\/noindex>.<\/p>\n<p><\/p>\n<h3 id=\"ispolzovanie\">\u0418\u0437\u043f\u043e\u043b\u0437\u0432\u0430\u043d\u0435<\/h3>\n<p><\/p>\n<p>\u041c\u0435\u0442\u043e\u0434\u0438\u0442\u0435 \u0437\u0430 \u0441\u0432\u044a\u0440\u0437\u0432\u0430\u043d\u0435 \u0441\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u0438, \u043d\u043e \u0440\u0435\u0437\u0443\u043b\u0442\u0430\u0442\u044a\u0442 \u0435 \u0435\u0434\u0438\u043d \u0438 \u0441\u044a\u0449. \u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043a\u043e\u0439\u0442\u043e \u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430 \u043d\u0430\u0448\u0438\u044f \u043c\u043e\u0434\u0443\u043b, \u0446\u0435\u043b\u0438\u0442\u0435 \u0449\u0435 \u0431\u044a\u0434\u0430\u0442 \u0434\u043e\u0441\u0442\u044a\u043f\u043d\u0438 \u0438 \u0432 \u0434\u0432\u0430\u0442\u0430 \u0441\u043b\u0443\u0447\u0430\u044f. <code>Mylib::myfeature<\/code> \u0438 <code>Mylib::mylib<\/code>, \u043a\u043e\u0438\u0442\u043e \u043c\u043e\u0433\u0430\u0442 \u0434\u0430 \u0441\u0435 \u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a\u0430:<\/p>\n<p><\/p>\n<pre><code class=\"cmake\">add_executable(some_executable some.cpp sources.cpp)\ntarget_link_libraries(some_executable PRIVATE Mylib::myfeature)<\/code><\/pre>\n<p><\/p>\n<p>\u0412 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0438\u044f \u043d\u0438 \u0441\u043b\u0443\u0447\u0430\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0442\u0430 <code>Mylib::myfeature<\/code> \u0442\u0440\u044f\u0431\u0432\u0430 \u0434\u0430 \u0441\u0435 \u0441\u0432\u044a\u0440\u0436\u0435, \u043a\u043e\u0433\u0430\u0442\u043e \u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u0430 \u0441\u0435 \u0441\u0432\u044a\u0440\u0436\u0435 \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0442\u0430 <code>libmyfeature<\/code>. \u0410\u043a\u043e \u0438\u043c\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u044a\u0447\u043d\u043e \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u0435, \u0442\u043e\u0433\u0430\u0432\u0430 \u0435 \u043f\u043e-\u0434\u043e\u0431\u0440\u0435 \u0434\u0430 \u0441\u0435 \u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0442\u0430 <code>Mylib::mylib<\/code>.<\/p>\n<p><\/p>\n<p>CMake \u0446\u0435\u043b\u0438\u0442\u0435 \u043c\u043e\u0433\u0430\u0442 \u0434\u0430 \u0431\u044a\u0434\u0430\u0442 \u0445\u0438\u0442\u0440\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438 \u0441\u0430\u043c\u043e \u0437\u0430 \u043f\u0440\u043e\u043a\u0430\u0440\u0432\u0430\u043d\u0435 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0442.\u043d. \u0420\u0430\u0431\u043e\u0442\u0430\u0442\u0430 \u0441 \u0442\u044f\u0445 \u043f\u0440\u043e\u0442\u0438\u0447\u0430 \u043f\u043e \u0435\u0434\u0438\u043d \u0438 \u0441\u044a\u0449 \u043d\u0430\u0447\u0438\u043d.<\/p>\n<p><\/p>\n<p>\u0422\u043e\u0432\u0430 \u0438\u0441\u043a\u0430\u0445\u043c\u0435 \u0434\u0430 \u043f\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u043c.<\/p>\n<p>\u0418\u0437\u0442\u043e\u0447\u043d\u0438\u043a: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/463295\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u043e\u0431 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441\u0438\u0441\u0442\u0435\u043c \u0441\u0431\u043e\u0440\u043a\u0438 CMake. \u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a \u043d\u0435\u043c\u0443 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u043a\u0435 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c. \u041a\u0430\u043a \u0438 \u043f\u0440\u0435\u0436\u0434\u0435, \u0442\u0435\u043c, \u043a\u043e\u043c\u0443 \u043d\u0435 \u0442\u0435\u0440\u043f\u0438\u0442\u0441\u044f, \u043c\u043e\u0433\u0443\u0442 \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d\u043d\u044b\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0438 \u043f\u043e\u0442\u0440\u043e\u0433\u0430\u0442\u044c \u0432\u0441\u0451 \u0441\u0432\u043e\u0438\u043c\u0438 \u0440\u0443\u043a\u0430\u043c\u0438. \u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0420\u0430\u0437\u0434\u0435\u043b\u044f\u0439 \u0412\u043b\u0430\u0441\u0442\u0432\u0443\u0439 [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":27802,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-37084","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/bg\/blog\/administrirovanie\/c-i-cmake-bratya-navek-chast-ii\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"bg_BG\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47C++ \u0438 CMake \u2014 \u0431\u0440\u0430\u0442\u044c\u044f \u043d\u0430\u0432\u0435\u043a, \u0447\u0430\u0441\u0442\u044c II | ProHoster\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/bg\/blog\/administrirovanie\/c-i-cmake-bratya-navek-chast-ii\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-10-31T19:15:40+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2019-10-31T19:15:40+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47C++ \u0438 CMake \u2014 \u0431\u0440\u0430\u0442\u044f \u0437\u0430\u0432\u0438\u043d\u0430\u0433\u0438, \u0447\u0430\u0441\u0442 II | ProHoster","description":"","canonical_url":"https:\/\/prohoster.info\/bg\/blog\/administrirovanie\/c-i-cmake-bratya-navek-chast-ii","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"bg_BG","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47C++ \u0438 CMake \u2014 \u0431\u0440\u0430\u0442\u044c\u044f \u043d\u0430\u0432\u0435\u043a, \u0447\u0430\u0441\u0442\u044c II | ProHoster","og:url":"https:\/\/prohoster.info\/bg\/blog\/administrirovanie\/c-i-cmake-bratya-navek-chast-ii","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2019-10-31T19:15:40+00:00","article:modified_time":"2019-10-31T19:15:40+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"37084","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-01-22 06:02:22","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-03-01 01:33:25","updated":"2026-01-22 06:02:22","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/posts\/37084","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/comments?post=37084"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/posts\/37084\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/media\/27802"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/media?parent=37084"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/categories?post=37084"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/bg\/wp-json\/wp\/v2\/tags?post=37084"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}