Swift and Cute Framework: Setting up a project with CMake Jun 6 · 5 min read · cute · cute-framework · cmake · swift · game-development Cute Framework is a simple, yet powerful C/C++ framework for building 2D games using the modern GPU pipeline. While C or C++ is fine, Swift is a modern language that many developers prefer for its safety and expressiveness. In this post, we will explore how to set up a project using Cute Framework with CMake, enabling you to write your game logic in Swift while leveraging the performance of C/C++ for rendering and other performance-critical tasks. Prerequisites Before we begin, ensure you have the following installed: Swift (latest version, preferably Swift 6 or later) CMake (we are going to use the most recent version 4.0, but 3.20+ should work just fine) Ninja (required for building Swift with CMake) Setting Up the Project Structure Create a new directory for your project and navigate into it: mkdir MyCuteGame cd MyCuteGame Create the following directory structure: mkdir src include touch CMakeLists.txt # Our CMake configuration file touch src/main.swift # Our main Swift file touch include/shim.h # Our C header file for Swift interoperability touch include/module.modulemap # Our C module map for Swift interoperability The next step is to configure the CMakeLists.txt file. Open it in your favorite text editor and add the following content: cmake_minimum_required(VERSION 4.0) # Set the project name and languages project( MyCuteGame LANGUAGES C CXX Swift # Ensure we include C, C++, and Swift ) # Set our game sources file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS src/*.swift) # Set our executable target add_executable(MyCuteGame ${SOURCES}) # Include FetchContent to download Cute Framework include(FetchContent) # Define cute as our Cute Framework dependency FetchContent_Declare( cute GIT_REPOSITORY https://github.com/RandyGaul/cute_framework ) # Fetch the Cute Framework FetchContent_MakeAvailable(cute) # Add the Cute Framework as a depen...
First seen: 2025-06-06 12:07
Last seen: 2025-06-06 23:09