{"id":15991019,"url":"https://github.com/friendlyanon/cmake-init-fetchcontent","last_synced_at":"2026-03-19T18:26:36.061Z","repository":{"id":68574011,"uuid":"469242799","full_name":"friendlyanon/cmake-init-fetchcontent","owner":"friendlyanon","description":"Example for optionally vendoring using FetchContent","archived":false,"fork":false,"pushed_at":"2022-03-13T01:47:58.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-08T22:52:03.563Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/friendlyanon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-13T01:40:03.000Z","updated_at":"2022-08-03T21:28:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"b05e8d53-1e79-479f-b4b5-12b6a26ecc3f","html_url":"https://github.com/friendlyanon/cmake-init-fetchcontent","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/friendlyanon/cmake-init-fetchcontent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendlyanon%2Fcmake-init-fetchcontent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendlyanon%2Fcmake-init-fetchcontent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendlyanon%2Fcmake-init-fetchcontent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendlyanon%2Fcmake-init-fetchcontent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/friendlyanon","download_url":"https://codeload.github.com/friendlyanon/cmake-init-fetchcontent/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendlyanon%2Fcmake-init-fetchcontent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29332277,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T06:13:03.264Z","status":"ssl_error","status_checked_at":"2026-02-11T06:12:55.843Z","response_time":97,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T05:41:25.499Z","updated_at":"2026-02-11T10:34:44.789Z","avatar_url":"https://github.com/friendlyanon.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"# /!\\ Attention /!\\\n\nThis repository showcases a form of vendoring. Vendoring is a bad practice of\npulling in source code of other projects into your own and building those\nprojects in the same build as your own. This makes packaging a project\npotentially very difficult or otherwise requires unnecessary patches to be\nmaintained by the package manager that remove the vendoring.\n\nYou can't realistically vendor any project. They must be architected in a way\nthat allows them to be consumed like this. The [dependency][1] that is used as\nan example in this repository was generated by [cmake-init][2], which produces\nprojects that are by default easy to vendor.\n\nEven if something is easy to vendor, because everything happens in a single\nbuild, the vendored project will inherit your flags, which could cause errors\nin sources compiled from the vendored project if you are using a\nwarnings-as-errors flag.\n\n## fetchcontent\n\nThis project was generated by [cmake-init][2].  \nIt's heavily stripped down to focus on showing how to optionally make\ndependencies available using [FetchContent][3] via find modules.\n\nIf you look at the [build script](CMakeLists.txt#L34), you will see that the\ndependency is imported using the `find_package` command like normal. **This is\nvery important!** The point of this example is to showcase vendoring that is\ndone completely transparently.\n\nYou will also notice that the [linking](CMakeLists.txt#L35) is done using the\ntarget that contains a double colon. If you were using an `IMPORTED` target\nthat was created by a CMake package's config file, then you would have the\nexact same target name. The target name in this case comes from the `ALIAS`\ntarget from the [dependency's build script][4].\n\nThe opt-in is done by setting the `CMAKE_MODULE_PATH` variable in the [dev\npreset](CMakePresets.json#L24-L39), which enables the `find_package` command to\nfind the [`Findheaderonly.cmake`](cmake/find/Findheaderonly.cmake) file in\nmodule mode. We know that `find_package` will use module mode first before\nconfig mode, because the [basic signature][5] of the command is used and\n[`CMAKE_FIND_PACKAGE_PREFER_CONFIG`][6] isn't enabled.\n\nThe rest of the logic is explained in the find module.\n\n[1]: https://github.com/friendlyanon/cmake-init-header-only\n[2]: https://github.com/friendlyanon/cmake-init\n[3]: https://cmake.org/cmake/help/latest/module/FetchContent.html\n[4]: https://github.com/friendlyanon/cmake-init-header-only/blob/v0.20.6/CMakeLists.txt#L21\n[5]: https://cmake.org/cmake/help/latest/command/find_package.html#basic-signature\n[6]: https://cmake.org/cmake/help/latest/variable/CMAKE_FIND_PACKAGE_PREFER_CONFIG.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriendlyanon%2Fcmake-init-fetchcontent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffriendlyanon%2Fcmake-init-fetchcontent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriendlyanon%2Fcmake-init-fetchcontent/lists"}