ml::docs | Installation Your First App Manifests Events Plugins Scenes Graphics Resources
← All Tutorials
Beginner 5 sections ~10 min C++17

Installation

Get Malena and SFML set up in your project with CMake. From a clean machine to a running window in under ten minutes.

Introduction

Prerequisites

Malena requires three things before you start:

DependencyVersionNotes
C++ compilerC++17 or laterClang 10+, GCC 9+, or MSVC 2019+
CMake3.21 or latercmake.org/download
SFML3.xMust be SFML 3 — not SFML 2
SFML 3 only. Malena uses the SFML 3 API throughout — std::optional<sf::Event>, sf::Event::MouseButtonReleased structured bindings, and more. SFML 2 is not compatible.

Installing SFML 3

macOS — Homebrew bash
brew install sfml
Ubuntu / Debian bash
sudo apt install libsfml-dev
Windows — vcpkg bash
vcpkg install sfml

Or build SFML 3 from source: github.com/SFML/SFML


1 Setup

Getting Malena

Clone the repository into your project or a common libraries folder:

Clone Malena bash
git clone https://github.com/daversmith/Malena.git

Or add it as a git submodule inside your project:

As a submodule bash
cd MyProject
git submodule add https://github.com/daversmith/Malena.git external/Malena
git submodule update --init --recursive
Tip: The submodule approach is recommended for projects you want to keep in sync with Malena updates. Run git submodule update --remote to pull the latest version at any time.

2 Setup

CMake integration

A minimal CMakeLists.txt for a new Malena application:

CMakeLists.txt 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 ────────────────────────────────────────────────────────────────────
find_package(SFML 3 COMPONENTS Graphics Window System Audio REQUIRED)

# ── Malena ────────────────────────────────────────────────────────────────────
# If cloned alongside your project:
add_subdirectory(Malena)
# If added as a submodule:
# add_subdirectory(external/Malena)

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

target_include_directories(MyApp PRIVATE src)

target_link_libraries(MyApp PRIVATE
    Malena::Malena
    sfml-graphics
    sfml-window
    sfml-system
    sfml-audio
)

Your project folder should look like this:

MyProject/
  CMakeLists.txt
  src/
    main.cpp
  Malena/  ← cloned or submodule
    CMakeLists.txt
    include/
    src/

Building

Configure and build bash
cd MyProject
cmake -B build
cmake --build build
Release build bash
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release

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 initialization() override
    {
        _box.setSize({200.f, 80.f});
        _box.setFillColor(sf::Color(83, 74, 183));
        _box.setPosition({300.f, 210.f});
        addComponent(_box);
    }

    void registerEvents() 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.