Code Monkey home page Code Monkey logo

swift-cmake-examples's Introduction

Swift CMake Examples

This repository contains examples for using CMake to build Swift with different project layouts, including using CMake to build pure-Swift projects, and projects that use Swift-C++ interoperability.

Requirements

The projects in this repository have been tested with the 5.7.3 Linux container, as well as with the 5.7 compiler toolchain on macOS. For some of the examples with more advanced usage, you may need a newer CMake than what is shipped by the packages in your Linux distro.

  • CMake 3.22+*
  • Ninja 1.5+
  • Swift 5.7+*

* Unless noted otherwise.

These projects build with the Ninja generator (e.g cmake -G 'Ninja' ...) and likely do not work with the other generators.

Single Executable

Directory: 1_single_executable

This project demonstrates creating a simple executable written in Swift.

Executable with Library

Directory: 2_executable_library

This project demonstrates creating a single executable that links against a Swift library.

Bi-directional Swift/C++ Interop

Directory: 3_bidirectional_cxx_interop

This project demonstrates mixing Swift and C++ in a library using the Swift/C++ interoperability in Swift 5.9. Requires CMake 3.26, Swift 5.9, and Clang 11 or newer, or Apple Clang shipped in Xcode 12 or newer.

Requires:

  • CMake 3.26
  • Swift 5.9
  • Clang 11 or Apple Clang in Xcode 12 or newer

Swift Macros

Directory: 4_swift_macros

This project demonstrates how to build a custom macro in a CMake-based project using the Swift macro support introduced in Swift 5.9.

Requires:

  • Swift 5.9 (macOS: Swift 5.9.0, Windows and Linux: Swift 5.9.1)

swift-cmake-examples's People

Contributors

etcwilde avatar torarnv avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.