{"id":20618936,"url":"https://github.com/jahnf/cmake-resources","last_synced_at":"2025-08-10T21:03:13.627Z","repository":{"id":74770680,"uuid":"274053633","full_name":"jahnf/CMake-Resources","owner":"jahnf","description":"Python script and CMake functionality to easily embed and maintain resource files into C++ executables and libraries.","archived":false,"fork":false,"pushed_at":"2020-06-22T17:14:23.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-07-23T11:55:29.867Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jahnf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2020-06-22T06:07:07.000Z","updated_at":"2023-02-04T23:56:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"c8dacdd6-4c65-4adc-a89f-2c9cafd37129","html_url":"https://github.com/jahnf/CMake-Resources","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jahnf/CMake-Resources","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jahnf%2FCMake-Resources","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jahnf%2FCMake-Resources/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jahnf%2FCMake-Resources/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jahnf%2FCMake-Resources/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jahnf","download_url":"https://codeload.github.com/jahnf/CMake-Resources/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jahnf%2FCMake-Resources/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269787312,"owners_count":24475714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-11-16T12:09:57.990Z","updated_at":"2025-08-10T21:03:13.603Z","avatar_url":"https://github.com/jahnf.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CMake-Resources\n\nPython script and CMake functionality to easily embed and maintain resource files into\nC++ executables and libraries.\n\n## Example Usage\n\nFor a ready to use example have a look into the `./example` directory.\n\n### 1. Configure resources in JSON file(s)\n\nConfigure resources you want to embed in a JSON file, example: `resources.json`\n\n```json\n{\n  \"CRES\": [\n    {\n      \"prefix\": \"sources/\",\n      \"files\": [\n        { \"name\": \"example.cc\" },\n        { \"name\": \"example.cc\", \"alias\": \"example-alias.cc\" }\n      ]\n    },\n    {\n      \"prefix\": \"other-data/\",\n      \"files\": [\n        { \"name\": \"CMakeLists.txt\" },\n        { \"name\": \"resources.json\" }\n      ]\n    }\n  ]\n}\n```\n### 2. Include module in your `CMakeLists.txt` and add resource library\n\nExample:\n\n```cmake\nlist(APPEND CMAKE_MODULE_PATH \"${CMAKE_CURRENT_SOURCE_DIR}/cmake\")\ninclude(Resources)\n\n# Creates a library target `resources` that can be used by and linked against all other targets.\nadd_resources_library(myresources resources.json)\n```\n\n### 3. Link against the resource library\n\n```cmake\nadd_executable(example example.cc)\ntarget_link_libraries(example PRIVATE myresources)\n```\n\n### 4. Include header and list or access embedded files\n\n`example.cc`\n```cpp\n#include \u003ciostream\u003e\n#include \u003cmyresources/resources.h\u003e\n\nint main(int argc, char** argv)\n{\n  // List all embedded resources\n  for (const auto\u0026 res : myresources::embeddedResources())\n  {\n    std::cout \u003c\u003c \" - \" \u003c\u003c res.prefix \u003c\u003c res.name \u003c\u003c \", size=\" \u003c\u003c res.size \u003c\u003c std::endl;\n  }\n\n  // Find and access specific embedded resource file\n  // via operator[]\n  if (const auto res = myresources::embeddedResources()[\"sources/example.cc\"])\n  {\n    std::cout \u003c\u003c \" - \" \u003c\u003c res-\u003eprefix \u003c\u003c res-\u003ename \u003c\u003c \", size=\" \u003c\u003c res-\u003esize \u003c\u003c std::endl;\n    // res-\u003edata: pointer to data array of size res-\u003esize\n  }\n\n  // via get_resource function\n  if (const auto res = myresources::get_resource(\"sources/example.cc\"))\n  {\n    std::cout \u003c\u003c \" - \" \u003c\u003c res-\u003eprefix \u003c\u003c res-\u003ename \u003c\u003c \", size=\" \u003c\u003c res-\u003esize \u003c\u003c std::endl;\n  }\n\n  return 0;\n}\n```\n\n\n## Future Ideas/Todos\n\n* Do some benchmarking and compare current implementation with an implementation that uses\n  compile time maps (or unordered_maps) (See: https://github.com/serge-sans-paille/frozen)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjahnf%2Fcmake-resources","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjahnf%2Fcmake-resources","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjahnf%2Fcmake-resources/lists"}