{"id":18003074,"url":"https://github.com/zmactep/cmake-metal-example","last_synced_at":"2025-04-04T09:20:36.307Z","repository":{"id":143004006,"uuid":"453165618","full_name":"zmactep/cmake-metal-example","owner":"zmactep","description":"Minimal example of C++ Metal project built with CMake","archived":false,"fork":false,"pushed_at":"2022-01-28T18:53:43.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-09T19:53:49.296Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","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/zmactep.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-01-28T17:56:07.000Z","updated_at":"2022-01-28T17:57:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"aac3d8d0-32f9-449f-8db4-970dbc22a0eb","html_url":"https://github.com/zmactep/cmake-metal-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmactep%2Fcmake-metal-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmactep%2Fcmake-metal-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmactep%2Fcmake-metal-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmactep%2Fcmake-metal-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zmactep","download_url":"https://codeload.github.com/zmactep/cmake-metal-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247149489,"owners_count":20891954,"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","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-29T23:25:21.831Z","updated_at":"2025-04-04T09:20:36.284Z","avatar_url":"https://github.com/zmactep.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"CMake Metal Minimal Example\r\n===========================\r\n\r\n\r\nWhat is it?\r\n-----------\r\n\r\nRecently, Apple announced [C++ interface](https://developer.apple.com/metal/cpp/) for its Metal Framework to use it without Swift or Objective-C. That is great, as many different bindings for high-level programming languages can be created now.\r\n\r\nOf course, Apple has a manual on working with these headers in XCode. But if you hate this IDE as I do, you would like to use CMake to build your project without it. So here we have a minimal example of how to build a Metal-based project using CLI.\r\n\r\nBuild\r\n-----\r\n\r\nAll the magic is stored in `compile.sh` file. But let us understand it.\r\n\r\n```bash\r\ncurl -o metal-cpp.zip https://developer.apple.com/metal/cpp/files/metal-cpp_macOS12_iOS15.zip\r\nunzip metal-cpp.zip\r\n```\r\n\r\nDownload and unzip headers from Apple Developer. All the staff will be in `metal-cpp` directory.\r\n\r\n```bash\r\nmkdir build\r\ncd build\r\ncmake ..\r\n```\r\n\r\nStandard CMake operations to create a Makefile. CMake will use `metal-cpp` as additional headers path, so `Metal/Metal.hpp` will be available.\r\n\r\n```bash\r\nxcrun -sdk macosx metal -c ../src/kernel.metal -o kernel.air\r\nxcrun -sdk macosx metallib kernel.air -o kernel.metallib\r\n```\r\n\r\nCMake cannot build Metal shaders by itself, so we have to do this work by ourselfs. The explanation of this lines can be found [here](https://developer.apple.com/documentation/metal/libraries/building_a_library_with_metal_s_command-line_tools).\r\n\r\n```bash\r\nmake\r\n```\r\n\r\nNothing to comment. Just build the executable.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzmactep%2Fcmake-metal-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzmactep%2Fcmake-metal-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzmactep%2Fcmake-metal-example/lists"}