{"id":3457,"date":"2024-09-08T21:57:00","date_gmt":"2024-09-08T12:57:00","guid":{"rendered":"http:\/\/43.203.250.216\/?p=3457"},"modified":"2024-09-08T21:57:01","modified_gmt":"2024-09-08T12:57:01","slug":"cmake-fetchcontent%ec%9d%98-target%ec%9d%b4-%ec%a4%91%eb%b3%b5%eb%90%98%eb%8a%94-%eb%ac%b8%ec%a0%9c-%ed%9a%8c%ed%94%bc","status":"publish","type":"post","link":"https:\/\/litcoder.com\/?p=3457","title":{"rendered":"CMake FetchContent\uc758 target\uc774 \uc911\ubcf5\ub418\ub294 \ubb38\uc81c"},"content":{"rendered":"\n<p>CMake\uc758 FetchContent\ub294 \ube4c\ub4dc \uacfc\uc815\uae4c\uc9c0 \ucc98\ub9ac\ud574 \uc8fc\uae30\uc5d0 git-submodule \ubcf4\ub2e4 \ud3b8\ub9ac\ud55c \ubc29\uc2dd\uc778 \uac83 \uac19\ub2e4. \ub2e4\ub9cc, version 3.22.1 \uae30\uc900\uc73c\ub85c \uc5ec\ub7ec \ud504\ub85c\uc81d\ud2b8 \ub4e4\uc774 \ub3d9\uc77c\ud55c target\uc774\ub984\uc744 \uc911\ubcf5\ud574\uc11c \uc120\uc5b8\ud558\ub294 \uacbd\uc6b0\uc5d0\ub294 \uc774\ub97c \uc798 \ucc98\ub9ac \ud558\uc9c0 \ubabb\ud558\uace0 \uc704\uc640 \uac19\uc740 \uc5d0\ub7ec\ub97c \ubc49\uace0 \uc885\ub8cc\ub418\ub294 \ubb38\uc81c\uac00 \uc788\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">-- Found systemd via pkg-config.\nCMake Error at build\/_deps\/grpc-src\/CMakeLists.txt:667 (add_custom_target):\n  add_custom_target cannot create target \"tools\" because another target with\n  the same name already exists.  The existing target is a custom target\n  created in source directory\n  \"&lt;absolute_path_to_the_build_dir>\/_deps\/vsomeip-src\".\n  See documentation for policy CMP0002 for more details.<\/pre>\n\n\n\n<p>\uc704\uc758 \uc624\ub958\ub294 COVESA\uc758 <a href=\"https:\/\/github.com\/COVESA\/vsomeip\" data-type=\"link\" data-id=\"https:\/\/github.com\/COVESA\/vsomeip\">vsomeip<\/a> project\uc640 <a href=\"https:\/\/github.com\/grpc\/grpc\" data-type=\"link\" data-id=\"https:\/\/github.com\/grpc\/grpc\">gRPC<\/a>\ub97c FetchContent\ub85c \uad6c\uc131\ud558\ub294 \uc911\uc5d0 \ubc1c\uc0dd\ud55c \uac83\uc778\ub370, \ub450 \ud504\ub85c\uc81d\ud2b8 \ubaa8\ub450 &#8220;tools&#8221;\ub77c\ub294 custom target\uc744 \uc120\uc5b8\ud558\uae30 \ub54c\ubb38\uc5d0 \uc911\ubcf5\uc73c\ub85c \uc624\ub958\uac00 \ubc1c\uc0dd\ud55c \uac83\uc774\ub2e4.<\/p>\n\n\n\n<p>\uc544\uc27d\uac8c\ub3c4 \ud604\uc7ac\ub85c\uc368\ub294 \uae54\ub054\ud558\uac8c \ud574\uacb0\ud558\ub294 \ubc29\ubc95\uc740 \uc5c6\ub294 \uac83 \uac19\uace0, \ub450 \ud504\ub85c\uc81d\ud2b8 \uc911 \ud558\ub098\uc758 custom target \uc774\ub984\uc744 \ubcc0\uacbd\ud574\uc11c \uc911\ubcf5\ub418\uc9c0 \uc54a\ub3c4\ub85d \ud574 \uc8fc\ub294 \ud328\uce58\ub97c \uc791\uc131\ud574\uc11c FetchContent\uc758 PATCH_COMMAND\uc5d0 \uc778\uc790\ub85c \ub123\uc5b4\uc8fc\ub294 \ubc29\ubc95\uc73c\ub85c \ud68c\ud53c\uac00 \uac00\ub2a5\ud558\ub2e4.<\/p>\n\n\n\n<p>\uba3c\uc800 vsomeip project\uc758 custom target\uc778 tools\ub97c vsomeip_tools\ub85c \ubcc0\uacbd\ud558\ub294 \ud328\uce58\ub97c \ub2e4\uc74c\uacfc \uac19\uc774 \uc791\uc131\ud558\uace0 fix_custom_target.patch\ub85c \uc800\uc7a5\ud55c\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"diff\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">diff --git a\/CMakeLists.txt b\/CMakeLists.txt\nindex 3501e02..0467426 100644\n--- a\/CMakeLists.txt\n+++ b\/CMakeLists.txt\n@@ -654,7 +654,7 @@ add_subdirectory( examples\/routingmanagerd )\n endif()\n \n # build tools\n-add_custom_target( tools )\n+add_custom_target( vsomeip_tools )\n add_subdirectory( tools )\n \n # build examples\n-- \n2.34.1\n<\/pre>\n\n\n\n<p>\ub2e4\uc74c\uc73c\ub85c FetchConetnet\uc5d0 PATCH_COMMAND argument\ub97c \uba85\uc2dc\ud55c\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># VSOME\/IP\nset(\n    fix_custom_target\n    git apply ${CMAKE_CURRENT_SOURCE_DIR}\/fix_custom_target.patch\n)\nFetchContent_Declare(\n    vsomeip\n    GIT_REPOSITORY https:\/\/github.com\/COVESA\/vsomeip.git\n    GIT_TAG &lt;GIT_TAG>\n    PATCH_COMMAND ${fix_custom_target}\n)\n\nFetchContent_MakeAvailable(vsomeip gRPC)<\/pre>\n\n\n\n<p>\uc774\uc81c cmake\ub97c \uc2e4\ud589\ud558\uba74 patch\uac00 \uc801\uc6a9\ub418\uc5b4 \uc911\ubcf5\ub418\ub294 target \uc774\ub984 \ubb38\uc81c\ub97c \ud574\uacb0\ud560 \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<p>\ud558\uc9c0\ub9cc \uc774 \ud574\uacb0\ucc45\uc740 \uc544\uc9c1 \uae54\ub054\ud558\uc9c4 \uc54a\uc740\ub370 \uadf8 \uc774\uc720\ub294 \ucc98\uc74c cmake\ub97c \uc2e4\ud589\ud558\uba74 patch\uac00 \uc801\uc6a9\ub418\uba74\uc11c \uc798 \ub418\uc9c0\ub9cc \ub450\ubc88\uc9f8\ub85c cmake\ub97c \uc2e4\ud589 \ud560 \ub54c\ub294 \uc774\ubbf8 \uc801\uc6a9\ub41c patch \ub54c\ubb38\uc5d0 git apply \uba85\ub839\uc5b4\uac00 \uc2e4\ud328 \ud558\uae30 \ub54c\ubb38\uc5d0 \ub9e4\ubc88 patch\uac00 \uc801\uc6a9\ub41c directory(_deps\/vsomeip-src)\ub85c \uc774\ub3d9\ud574\uc11c git checkout -f\ub97c \uc2e4\ud589\ud574 \uc8fc\uc5b4\uc57c \ud558\uae30 \ub54c\ubb38\uc774\ub2e4.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\ucd5c\uc885\ubc84\uc804<\/h2>\n\n\n\n<p>git apply\uc758 &#8211;reverse &#8211;check \uc635\uc158\uc744 \uc0ac\uc6a9\ud558\uba74 \ud328\uce58\uac00 \uc801\uc6a9\ub418\uc5b4 \uc788\ub294\uc9c0 \uc5ec\ubd80\ub97c \uac80\uc0ac\ud560 \uc218 \uc788\uc73c\ub2c8 \uc774 \uac83\uc744 \uc774\uc6a9\ud574\uc11c \ub2e4\uc74c\uacfc \uac19\uc740 \uac04\ub2e8\ud55c shell script\ub97c \ub9cc\ub4e4\uace0 apply_patch_if_not.sh\ub85c \uc800\uc7a5\ud55c\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/usr\/bin\/env sh\n# apply_patch_if_not.sh\n# Apply given patch if not already applied.\n#\n#                         - Sep 2024, litcoder\n\nif [ -z $1 ]; then\n  echo \"Usage: $0 &lt;patch file path>\"\n  exit 1\nfi\n\n# Check if the patch was already applied.\ngit apply --reverse --check $1\nif [ $? -eq 0 ]; then\n  echo \"The patch already applied, skip.\"\n  exit 0\nelse\n  # Apply the patch\n  git apply $1\nfi<\/pre>\n\n\n\n<p>\uc774\uc81c \uc55e\uc5d0\uc11c \uc791\uc131\ud55c FetchContent_Declare\uac00 \uc774 script\ub97c \ubd80\ub974\ub3c4\ub85d \ubcc0\uacbd\ud55c\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># VSOME\/IP\nset(\n    fix_custom_target\n    apply_patch_if_not.sh ${CMAKE_CURRENT_SOURCE_DIR}\/fix_custom_target.patch\n)\nFetchContent_Declare(\n    vsomeip\n    GIT_REPOSITORY https:\/\/github.com\/COVESA\/vsomeip.git\n    GIT_TAG &lt;GIT_TAG>\n    PATCH_COMMAND ${fix_custom_target}\n)\n\nFetchContent_MakeAvailable(vsomeip gRPC)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>CMake\uc758 FetchContent\ub294 \ube4c\ub4dc \uacfc\uc815\uae4c\uc9c0 \ucc98\ub9ac\ud574 \uc8fc\uae30\uc5d0 git-submodule \ubcf4\ub2e4 \ud3b8\ub9ac\ud55c \ubc29\uc2dd\uc778 \uac83 \uac19\ub2e4. \ub2e4\ub9cc, version 3.22.1 \uae30\uc900\uc73c\ub85c \uc5ec\ub7ec \ud504\ub85c\uc81d\ud2b8 \ub4e4\uc774 \ub3d9\uc77c\ud55c target\uc774\ub984\uc744 \uc911\ubcf5\ud574\uc11c \uc120\uc5b8\ud558\ub294 \uacbd\uc6b0\uc5d0\ub294 \uc774\ub97c \uc798 \ucc98\ub9ac \ud558\uc9c0 \ubabb\ud558\uace0 \uc704\uc640 \uac19\uc740 \uc5d0\ub7ec\ub97c \ubc49\uace0 \uc885\ub8cc\ub418\ub294 \ubb38\uc81c\uac00 \uc788\ub2e4. \uc704\uc758 \uc624\ub958\ub294 COVESA\uc758 vsomeip project\uc640 gRPC\ub97c FetchContent\ub85c \uad6c\uc131\ud558\ub294 \uc911\uc5d0 \ubc1c\uc0dd\ud55c \uac83\uc778\ub370, \ub450 \ud504\ub85c\uc81d\ud2b8 \ubaa8\ub450 &#8220;tools&#8221;\ub77c\ub294 custom target\uc744 \uc120\uc5b8\ud558\uae30 \ub54c\ubb38\uc5d0 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6],"tags":[322,327,326,330,328],"class_list":["post-3457","post","type-post","status-publish","format-standard","hentry","category-tools","tag-cmake","tag-custom_target","tag-fetchcontent","tag-grpc","tag-push_command"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/posts\/3457","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/litcoder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3457"}],"version-history":[{"count":9,"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/posts\/3457\/revisions"}],"predecessor-version":[{"id":3470,"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/posts\/3457\/revisions\/3470"}],"wp:attachment":[{"href":"https:\/\/litcoder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/litcoder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/litcoder.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}