Installation
Get Malena into your project with CMake FetchContent — no manual cloning, automatic dependency management, and reproducible builds across every machine on your team.
Prerequisites
You only need two things installed before you start. FetchContent handles everything else.
| Dependency | Version | Notes |
|---|---|---|
| C++ compiler | C++17 or later | Clang 10+, GCC 9+, or MSVC 2019+ |
| CMake | 3.21 or later | cmake.org/download |
| Git | Any recent version | Required for FetchContent to clone sources |
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.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.
main for the latest changes. No submodule commits to manage, no system-library version mismatches.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:
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.
cd MyProject
cmake -B build # downloads Malena + SFML on first run
cmake --build build
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
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.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.
cd MyProject
git submodule add https://github.com/daversmith/Malena.git external/Malena
git submodule update --init --recursive
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:
brew install sfml
sudo apt install libsfml-dev
vcpkg install sfml
Option B — Local clone
Simplest for a quick experiment. Clone Malena next to your project and point add_subdirectory at it.
git clone https://github.com/daversmith/Malena.git
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
)
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.
#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;
}
You're set up
Malena is installed and working. Here's where to go next: