{"id":13831750,"url":"https://github.com/compnerd/swift-cmake-examples","last_synced_at":"2025-12-30T00:27:45.901Z","repository":{"id":55110698,"uuid":"188132457","full_name":"compnerd/swift-cmake-examples","owner":"compnerd","description":"Swift example projects","archived":false,"fork":false,"pushed_at":"2024-02-01T02:41:45.000Z","size":31,"stargazers_count":118,"open_issues_count":1,"forks_count":17,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-08-05T10:18:50.612Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/compnerd.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}},"created_at":"2019-05-23T00:28:33.000Z","updated_at":"2024-08-04T05:03:59.000Z","dependencies_parsed_at":"2024-01-15T15:25:39.406Z","dependency_job_id":"2e32a689-26a5-4718-994e-c07baf73fce1","html_url":"https://github.com/compnerd/swift-cmake-examples","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/compnerd%2Fswift-cmake-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compnerd%2Fswift-cmake-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compnerd%2Fswift-cmake-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compnerd%2Fswift-cmake-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/compnerd","download_url":"https://codeload.github.com/compnerd/swift-cmake-examples/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225565913,"owners_count":17489284,"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-08-04T10:01:39.049Z","updated_at":"2025-12-30T00:27:45.863Z","avatar_url":"https://github.com/compnerd.png","language":"CMake","funding_links":[],"categories":["CMake"],"sub_categories":[],"readme":"# CMake Examples for Swift\n\nThis repository contains example projects demonstrating how to setup a Swift project with CMake.  Make sure to use the CMake Ninja generator and Ninja build tool. These hopefully cover a wide variety of use cases.  Patches to add examples of missing use cases are welcome.\n\n## Projects\n- Hello Minimal\n  * Simple project with a pure Swift library and executable\n- Build Dependencies\n  * Simple project with a library that depends on an external package which is built as part of the build\n- Hello World\n  * Multi-library project with C and Swift code\n\n# Why Use This\n\nCMake is a meta-build system that allows you to generate the build rules using different build tools. It also makes it possible to setup the build in a way which supports cross-compiling for various targets (including Linux, Windows, and android).\n\n# How to build with CMake\n\nIf `swiftc` is not in your path, you will need to add `-DCMAKE_Swift_COMPILER=`\nwith the path to swiftc.\n\n\u003cdetails\u003e\n  \u003csummary\u003eLinux or macOS\u003c/summary\u003e\n\n\n```bash\ncmake -B build -D CMAKE_BUILD_TYPE=RelWithDebInfo -D BUILD_TESTING=YES -G Ninja -S .\nninja -C build\nninja -C build test\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eWindows\u003c/summary\u003e\n\n\u003e **NOTE:** we must build with the Release configuration on Windows as the Swift runtime\n\u003e in debug configuration is not distributed with the standard toolchain.  MSVCRT cannot\n\u003e be used in different configurations in the same process, and will result in runtime\n\u003e failures.\n\n```cmd\nset SWIFTFLAGS=-sdk %SDKROOT%\ncmake -B build -D CMAKE_BUILD_TYPE=Release -D CMAKE_Swift_FLAGS=%SWIFTFLAGS% -D BUILD_TESTING=YES -G Ninja -S .\nninja -C build\nninja -C build test\n```\n\u003c/details\u003e\n\nThis invocation builds the project in release mode with debug information.  This\nenables optimized builds with debug information (or release only).  Additionally, the standard\nCMake option `BUILD_TESTING` is used to enable tests.\n\n## What is supported\n\nThese project build on Linux, macOS, and Windows!\n\n- `CMAKE_BUILD_TYPE`\n  * `Debug` (no optimizations, debug info)\n  * `Release` (all optimizations, no debug info)\n  * `RelWithDebInfo` (all optimizations, debug info)\n  * `MinSizeRel` (optimized for size)\n\n- `MSVC_RUNTIME_LIBRARY` (*Windows Only*)\n  * `MultiThreadedDebugDLL` (`MDd`)\n  * `MultiThreadedDLL` (`MD`)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompnerd%2Fswift-cmake-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcompnerd%2Fswift-cmake-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompnerd%2Fswift-cmake-examples/lists"}