{"id":13831285,"url":"https://github.com/mrexodia/zig-cross","last_synced_at":"2025-04-05T15:03:32.491Z","repository":{"id":61993537,"uuid":"495467734","full_name":"mrexodia/zig-cross","owner":"mrexodia","description":"Example of using as a CMake Toolchain for cross compiling.","archived":false,"fork":false,"pushed_at":"2025-02-17T15:27:55.000Z","size":50,"stargazers_count":138,"open_issues_count":1,"forks_count":9,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-29T14:12:40.709Z","etag":null,"topics":["cmake","cmake-toolchain","cpp","cross-compilation","cross-compiler-toolchain","zig"],"latest_commit_sha":null,"homepage":"https://zig.news/kristoff/cross-compile-a-c-c-project-with-zig-3599","language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrexodia.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-05-23T15:26:30.000Z","updated_at":"2025-03-27T19:09:53.000Z","dependencies_parsed_at":"2024-10-26T20:30:14.412Z","dependency_job_id":"31b69058-82da-4640-805c-cc69de6a4ff4","html_url":"https://github.com/mrexodia/zig-cross","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/mrexodia%2Fzig-cross","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrexodia%2Fzig-cross/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrexodia%2Fzig-cross/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrexodia%2Fzig-cross/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrexodia","download_url":"https://codeload.github.com/mrexodia/zig-cross/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353729,"owners_count":20925329,"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":["cmake","cmake-toolchain","cpp","cross-compilation","cross-compiler-toolchain","zig"],"created_at":"2024-08-04T10:01:23.711Z","updated_at":"2025-04-05T15:03:32.469Z","avatar_url":"https://github.com/mrexodia.png","language":"CMake","readme":"# zig-cross\r\n\r\nExample of using [zig](https://ziglang.org) as a CMake Toolchain for cross compiling.\r\n\r\nReference: https://zig.news/kristoff/cross-compile-a-c-c-project-with-zig-3599\r\n\r\n## Building\r\n\r\n- [Install zig](https://ziglang.org/learn/getting-started/#installing-zig) in your PATH (`choco install zig` on Windows)\r\n- `cmake -B build-aarch64 -G Ninja --toolchain aarch64-linux-gnu.cmake`\r\n- `cmake --build build-arch64`\r\n\r\nYou can create toolchains for other triples as well, just create a file named `aarch64-windows-gnu.cmake` with the following contents to build for Windows on ARM64:\r\n\r\n```cmake\r\ninclude(${CMAKE_CURRENT_LIST_DIR}/cmake/zig-toolchain.cmake)\r\n```\r\n\r\n## clangd\r\n\r\nTo get [clangd](https://clangd.llvm.org/) to work you need to first enable generation of `compile_commands.json`:\r\n\r\n```sh\r\ncmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON\r\n```\r\n\r\nAdditionally you need to pass pass the following arguments to `clangd`:\r\n\r\n```json\r\n\"clangd.arguments\": [\r\n    \"--log=verbose\",\r\n    \"--query-driver=**/zig-cc.cmd,**/zig-cc,**/zig-c++.cmd,**/zig-c++\",\r\n]\r\n```\r\n\r\nWithout these arguments `clangd` will not query the driver (`zig c++`) and the include paths will not be resolved correctly.\r\n","funding_links":[],"categories":["CMake"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrexodia%2Fzig-cross","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrexodia%2Fzig-cross","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrexodia%2Fzig-cross/lists"}