ml::docs | Installation Your First App Manifests Events Messaging Plugins Scenes Resources
See all tutorials →
Beginner 4 sections ~10 min CMake 3.21+

Installation

Get Malena into your project with CMake FetchContent — no manual cloning, automatic dependency management, and reproducible builds across every machine on your team.

Introduction

Prerequisites

You only need two things installed before you start. FetchContent handles everything else.

DependencyVersionNotes
C++ compilerC++17 or laterClang 10+, GCC 9+, or MSVC 2019+
CMake3.21 or latercmake.org/download
GitAny recent versionRequired for FetchContent to clone sources
SFML 3 only. Malena uses the SFML 3 API — std::optional<sf::Event>, structured event bindings, and more. SFML 2 is not compatible. FetchContent will pull SFML 3 automatically so you do not need to install it separately.

1 Setup — Recommended

FetchContent recommended

CMake's built-in FetchContent module downloads and builds Malena and SFML 3 as part of your own build. There is nothing to clone or install manually — CMake does it all on the first configure.

Why FetchContent? Every developer on your team gets the exact same version of Malena and SFML without any manual setup steps. Pin to a release tag for stable builds, or track main for the latest changes. No submodule commits to manage, no system-library version mismatches.
CMakeLists.txt — FetchContent (recommended) cmake
cmake_minimum_required(VERSION 3.21)
project(MyApp VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(FetchContent)

# ── Malena ────────────────────────────────────────────────────────────────────
FetchContent_Declare(
    Malena
    GIT_REPOSITORY https://github.com/daversmith/Malena.git
    GIT_TAG        main            # or a specific release tag, e.g. v1.2.0
    GIT_SHALLOW    TRUE
)

FetchContent_MakeAvailable(SFML Malena)

# ── Your executable ───────────────────────────────────────────────────────────
add_executable(MyApp
    src/main.cpp
)

target_link_libraries(MyApp PRIVATE
    Malena::Malena
    SFML::Graphics
    SFML::Window
    SFML::System
    SFML::Audio
)

Your project folder only needs these files — no Malena/ or external/ directory required:

MyProject/
  CMakeLists.txt  ← the file above
  src/
    main.cpp
  build/  ← created by CMake; contains fetched sources

Configure and build

The first configure will download SFML and Malena into the build tree. Subsequent configures use the cached copy — no re-download unless the tag changes.

Configure and build bash
cd MyProject
cmake -B build              # downloads Malena + SFML on first run
cmake --build build
Release build bash
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
Pinning versions. Replace GIT_TAG main with a specific tag such as v1.2.0 to lock your build to a known-good release. This is strongly recommended for any project beyond personal experiments.

2 Setup — Alternatives

Alternatives

If you need direct access to the Malena source (e.g. to patch it, or to work offline), use a git submodule or a plain local clone instead.

Option A — Git submodule

Best for teams that want to track Malena changes through git history.

Add as a submodule bash
cd MyProject
git submodule add https://github.com/daversmith/Malena.git external/Malena
git submodule update --init --recursive
CMakeLists.txt — submodule cmake
cmake_minimum_required(VERSION 3.21)
project(MyApp VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# ── SFML 3 — install via package manager or FetchContent ──────────────────────
find_package(SFML 3 COMPONENTS Graphics Window System Audio REQUIRED)

# ── Malena — from submodule ───────────────────────────────────────────────────
add_subdirectory(external/Malena)

# ── Your executable ───────────────────────────────────────────────────────────
add_executable(MyApp src/main.cpp)

target_link_libraries(MyApp PRIVATE
    Malena::Malena
    SFML::Graphics SFML::Window SFML::System SFML::Audio
)

With the submodule approach you still need SFML 3 on the system. Install it via your package manager:

Install SFML 3 — macOS bash
brew install sfml
Install SFML 3 — Ubuntu / Debian bash
sudo apt install libsfml-dev
Install SFML 3 — Windows (vcpkg) bash
vcpkg install sfml

Option B — Local clone

Simplest for a quick experiment. Clone Malena next to your project and point add_subdirectory at it.

Clone alongside your project bash
git clone https://github.com/daversmith/Malena.git
CMakeLists.txt — local clone cmake
find_package(SFML 3 COMPONENTS Graphics Window System Audio REQUIRED)
add_subdirectory(Malena)   # cloned next to CMakeLists.txt

add_executable(MyApp src/main.cpp)
target_link_libraries(MyApp PRIVATE
    Malena::Malena
    SFML::Graphics SFML::Window SFML::System SFML::Audio
)

3 Setup

First build — verify your setup

Paste this into src/main.cpp. If it compiles and opens a purple window that responds to click and hover, your setup is complete.

src/main.cpp cpp
#include <Malena/Engine/App/Application.h>
#include <Malena/Graphics/Primitives/Rectangle.h>

class MyApp : public ml::Application
{
public:
    MyApp() : Application(800, 500, 32, "Malena works!") {}

    void onInit() override
    {
        _box.setSize({200.f, 80.f});
        _box.setFillColor(sf::Color(83, 74, 183));
        _box.setPosition({300.f, 210.f});
        addComponent(_box);
    }

    void onReady() override
    {
        _box.onClick([this]{
            _box.setFillColor(sf::Color(93, 202, 165));
        });
        _box.onHover([this]{
            _box.setFillColor(sf::Color(110, 95, 210));
        });
        _box.onUnhover([this]{
            _box.setFillColor(sf::Color(83, 74, 183));
        });
    }

private:
    ml::Rectangle _box;
};

int main()
{
    MyApp app;
    app.run();
    return 0;
}
Expected result: A dark window opens with a purple rectangle in the center. Hovering over it lightens it. Clicking it turns it teal. If you see this, Malena is fully set up.