{"action":"created","issue":{"url":"https://api.github.com/repos/gflags/gflags/issues/117","repository_url":"https://api.github.com/repos/gflags/gflags","labels_url":"https://api.github.com/repos/gflags/gflags/issues/117/labels{/name}","comments_url":"https://api.github.com/repos/gflags/gflags/issues/117/comments","events_url":"https://api.github.com/repos/gflags/gflags/issues/117/events","html_url":"https://github.com/gflags/gflags/issues/117","id":91007712,"number":117,"title":"Using gflags as subproject","user":{"login":"evgen231","id":5925982,"avatar_url":"https://avatars.githubusercontent.com/u/5925982?v=3","gravatar_id":"","url":"https://api.github.com/users/evgen231","html_url":"https://github.com/evgen231","followers_url":"https://api.github.com/users/evgen231/followers","following_url":"https://api.github.com/users/evgen231/following{/other_user}","gists_url":"https://api.github.com/users/evgen231/gists{/gist_id}","starred_url":"https://api.github.com/users/evgen231/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evgen231/subscriptions","organizations_url":"https://api.github.com/users/evgen231/orgs","repos_url":"https://api.github.com/users/evgen231/repos","events_url":"https://api.github.com/users/evgen231/events{/privacy}","received_events_url":"https://api.github.com/users/evgen231/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-06-25T16:16:15Z","updated_at":"2016-03-01T22:03:17Z","closed_at":null,"body":"I get errors whenever I try to use gflags as subproject.\r\n```\r\nCMake Error at CMakeLists.txt:7 (target_link_libraries):\r\n  Target \"gflags\" of type UTILITY may not be linked into another target.  One\r\n  may link only to STATIC or SHARED libraries, or to executables with the\r\n  ENABLE_EXPORTS property set.\r\n```\r\n\r\nMinimal CMakeLists.txt.\r\n```cmake\r\ncmake_minimum_required (VERSION 3.2)\r\nproject (minimal)\r\n\r\nadd_subdirectory (gflags)\r\n\r\nadd_executable (minimal main.cpp)\r\ntarget_link_libraries (minimal gflags)\r\n```\r\n\r\nAs workaround I patched gflags/CMakeLists.txt with\r\n```patch\r\ndiff --git a/CMakeLists.txt b/CMakeLists.txt\r\nindex c32bce3..8207837 100644\r\n--- a/CMakeLists.txt\r\n+++ b/CMakeLists.txt\r\n@@ -335,9 +335,10 @@ foreach (TYPE IN ITEMS STATIC SHARED)\r\n           target_link_libraries (gflags${opts}-${type} shlwapi.lib)\r\n         endif ()\r\n         if (NOT TARGET gflags${opts})\r\n-          add_custom_target (gflags${opts})\r\n+          add_library (gflags${opts} ALIAS gflags${opts}-${type})\r\n+        else ()\r\n+          add_dependencies (gflags${opts} gflags${opts}-${type})\r\n         endif ()\r\n-        add_dependencies (gflags${opts} gflags${opts}-${type})\r\n         list (APPEND TARGETS gflags${opts}-${type})\r\n       endif ()\r\n     endforeach ()\r\n```\r\n\r\nEDIT BY @schuhschuh: This patch is invalid and should not be used! Instead, use the following or substitute ```gflags``` by ```gflags_static``` or ```gflags_shared``` in your ```target_link_libraries``` command.\r\n```cmake\r\nadd_subdirectory(gflags)\r\nadd_library(gflags ALIAS gflags_static)\r\n```\r\n\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/gflags/gflags/issues/comments/190926151","html_url":"https://github.com/gflags/gflags/issues/117#issuecomment-190926151","issue_url":"https://api.github.com/repos/gflags/gflags/issues/117","id":190926151,"user":{"login":"schuhschuh","id":975451,"avatar_url":"https://avatars.githubusercontent.com/u/975451?v=3","gravatar_id":"","url":"https://api.github.com/users/schuhschuh","html_url":"https://github.com/schuhschuh","followers_url":"https://api.github.com/users/schuhschuh/followers","following_url":"https://api.github.com/users/schuhschuh/following{/other_user}","gists_url":"https://api.github.com/users/schuhschuh/gists{/gist_id}","starred_url":"https://api.github.com/users/schuhschuh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schuhschuh/subscriptions","organizations_url":"https://api.github.com/users/schuhschuh/orgs","repos_url":"https://api.github.com/users/schuhschuh/repos","events_url":"https://api.github.com/users/schuhschuh/events{/privacy}","received_events_url":"https://api.github.com/users/schuhschuh/received_events","type":"User","site_admin":false},"created_at":"2016-03-01T22:03:17Z","updated_at":"2016-03-01T22:03:17Z","body":"The use of gflags as subproject is now possible. See [this example project](https://github.com/gflags/example) and PR #140."}}