FTXUI 6.1.9 C++ functional terminal UI.

Loading...
Searching...
No Matches
CMake

This page explains how to depend on FTXUI using CMake.

# Methods of Integration

## Using FetchContent

This approach downloads FTXUI at configure time and doesn't require a system-wide install.

include(FetchContent)
FetchContent_Declare(ftxui
GIT_REPOSITORY https://github.com/ArthurSonzogni/FTXUI
GIT_TAG v6.1.9 # Replace with a version, tag, or commit hash
)
FetchContent_MakeAvailable(ftxui)
add_executable(main main.cpp)
target_link_libraries(main
PRIVATE ftxui::screen
PRIVATE ftxui::dom
PRIVATE ftxui::component
)

This ensures reproducible builds and easy dependency management.

## Using find_package

If FTXUI is installed system-wide or via a package manager (e.g. vcpkg or Conan), you can use:

find_package(ftxui REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main
PRIVATE ftxui::screen
PRIVATE ftxui::dom
PRIVATE ftxui::component
)

Make sure the package is visible in your `CMAKE_PREFIX_PATH`.

## Using git submodule

You can also add FTXUI as a Git submodule, keeping it as part of your repository:

git submodule add https://github.com/ArthurSonzogni/FTXUI external/ftxui
git submodule update --init --recursive

When cloning a repository that already includes FTXUI as a submodule, make sure to fetch submodules with:

git clone --recurse-submodules <your-repo>
# Or, if already cloned:
git submodule update --init --recursive

Then in your `CMakeLists.txt`:

add_subdirectory(external/ftxui)
add_executable(main main.cpp)
target_link_libraries(main
PRIVATE ftxui::screen
PRIVATE ftxui::dom
PRIVATE ftxui::component
)

This approach works well if you want to vendor FTXUI in your own repository.

# Optional CMake Flags

FTXUI supports the following CMake options:

Option | Description | Default
--- | --- | ---
FTXUI_BUILD_EXAMPLES | Build bundled examples | OFF
FTXUI_BUILD_DOCS | Build the documentation | OFF
FTXUI_BUILD_TESTS | Enable tests | OFF
FTXUI_ENABLE_INSTALL | Generate install targets | ON
FTXUI_MICROSOFT_TERMINAL_FALLBACK | Improve Windows compatibility | ON/OFF

To enable an option:

cmake -DFTXUI_BUILD_EXAMPLES=ON ..

# Verifying Integration

To confirm the setup is working, build and run a minimal example. If you need a complete template, see: ftxui-starter

Previous
Getting Started