Build reference

Choose and configure your build workflow.

This page is the reference for CMake, IDE, installed-package, repository, and offline workflows. Every path builds the same C++20 x64 or ARM64 library and links the exported mwfl::app target.

Building your first Windows application? Follow the 15-minute beginner tutorial first. It starts with installing Visual Studio and ends with a running window.
OSWindows 10 1809+ or Windows 11
ToolchainMSVC, Windows SDK
LanguageC++20, x64 / ARM64
BuildCMake 3.21+
Recommended

CMake project

Fetch a pinned release directly from your application. mwfl fetches its pinned WIL dependency and propagates the required include path, libraries, and C++20 setting.

cmake_minimum_required(VERSION 3.21)
project(my_app LANGUAGES CXX)

include(FetchContent)
FetchContent_Declare(mwfl
  GIT_REPOSITORY https://github.com/mwfl/mwfl.git
  GIT_TAG v0.1.0
  GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(mwfl)

add_executable(my_app WIN32 main.cpp)
target_link_libraries(my_app PRIVATE mwfl::app)
cmake -S . -B build -G "Visual Studio 18 2026" -A x64
cmake --build build --config Debug
Visual Studio 2022: replace the generator with Visual Studio 17 2022. The library supports VS 2022 or newer.
Reusable installation

Install once, consume with find_package

git clone --depth 1 https://github.com/mwfl/mwfl.git
cmake -S mwfl -B mwfl-build -G "Visual Studio 18 2026" -A x64
cmake --build mwfl-build --config Release
cmake --install mwfl-build --config Release --prefix C:/deps/mwfl
find_package(mwfl CONFIG REQUIRED)
add_executable(my_app WIN32 main.cpp)
target_link_libraries(my_app PRIVATE mwfl::app)

# configure
cmake -S . -B build -A x64 -DCMAKE_PREFIX_PATH=C:/deps/mwfl
IDE workflow

Visual Studio

Open the folder containing your CMake project with File → Open → Folder. Visual Studio detects CMakeLists.txt, configures CMake, and exposes my_app.exe in the startup-item selector.

  1. Install the Desktop development with C++ workload.
  2. In Individual components, enable a Windows 10/11 SDK.
  3. Select an x64-Debug or ARM64-Debug configuration; x86 is intentionally rejected.
  4. Choose the application target and press F5.

For an existing CMake-based Visual Studio solution, add the FetchContent block above. No manual include directory, library directory, or preprocessor configuration is required.

Editor workflow

VS Code

Install Microsoft’s C/C++ and CMake Tools extensions, then open the project folder from an x64 Native Tools command prompt or let CMake Tools discover the installed Visual Studio kit.

  1. Run CMake: Select a Kit and choose an amd64 MSVC kit.
  2. Run CMake: Configure.
  3. Choose Debug on the status bar and run CMake: Build.
  4. Select my_app as the launch target and run CMake: Debug.
{
  "cmake.generator": "Visual Studio 18 2026",
  "cmake.configureArgs": ["-A", "x64"],
  "cmake.buildDirectory": "${workspaceFolder}/build"
}

On Visual Studio 2022, use Visual Studio 17 2022. CMake Tools supplies IntelliSense from CMake’s compile model, so do not duplicate mwfl include paths in c_cpp_properties.json.

Application code

Your first mwfl window

#include <mwfl/mwfl.h>

class MainWindow final : public mwfl::WindowBase {
public:
    void BuildUI() override {
        SetTitle(L"My app");
        mwfl::ControlHost ui{*this};
        ui.Add(message_, L"Hello from mwfl");
        ui.Add(close_, L"Close");
        SetLayout(mwfl::Column().Margin(24.0_dip).Gap(12.0_dip)
            .Add(message_, mwfl::Auto())
            .Add(close_, mwfl::Fixed(36.0_dip)));
    }

    mwfl::EventResult OnCommand(const mwfl::CommandEvent& event) override {
        if (event.IsClicked(close_)) { Close(); return mwfl::EventResult::Handled(); }
        return mwfl::EventResult::Propagate();
    }
private:
    mwfl::Label message_;
    mwfl::Button close_;
};

int WINAPI wWinMain(HINSTANCE instance, HINSTANCE, PWSTR, int show) {
    return mwfl::RunApplication<MainWindow>(instance, show);
}
Contributors

Build this repository

git clone https://github.com/mwfl/mwfl.git
cd mwfl
./scripts/doctor.ps1 -VisualStudio 2026
cmake --preset vs2026-x64
cmake --build --preset vs2026-x64-debug
ctest --preset vs2026-x64-debug

The doctor checks Visual Studio, CMake, Git, the Windows SDK, and the selected architecture before a long build begins. Replace 2026/vs2026 with 2022/vs2022 to use the minimum supported toolchain.

# Fast local checks: formatting, configuration, focused tests, and docs
./scripts/verify.ps1 -Mode Fast -VisualStudio 2026

# Full release-equivalent verification
./scripts/verify.ps1 -Mode Full -VisualStudio 2026

Build a single example with cmake --build build/presets/vs2026-x64 --config Debug --target mwfl_hello. Its executable is under build/presets/vs2026-x64/examples/hello/Debug/. See the complete component gallery for source links and screenshots.

Explicit dependencies

Optional integrations

Desktop applications link mwfl::app and never fetch WebView2 or Scintilla. Enable only the component an application uses.

# Browser
cmake --preset vs2026-x64-webview2
cmake --build --preset vs2026-x64-webview2-debug --target mwfl_browser_demo

# Editor
cmake --preset vs2026-x64-scintilla
cmake --build --preset vs2026-x64-scintilla-debug --target mwfl_code_editor_demo

Installed consumers request COMPONENTS webview2 or COMPONENTS scintilla. Scintilla applications also call mwfl_deploy_scintilla(target). See the complete ownership, Runtime, and offline-test guide.

Controlled environments

Offline dependencies

cmake -S . -B build -A x64 \
  -DMWFL_WIL_SOURCE_DIR=C:/deps/wil

Set MWFL_DEPENDENCY_MODE=SYSTEM to prohibit downloads and locate a preinstalled WIL tree, or FETCH to require the pinned upstream revision. AUTO is the default. Explicit source directories always take priority.

You can also define WIL::WIL before adding mwfl. The build never silently selects an unidentified system copy.