Foundations
Build System and Configuration
NAppGUI ships a fairly opinionated CMake stack. It configures compiler/toolkit settings,
bootstraps the nrc resource compiler, scans platform-specific source trees,
and exports an installable package for downstream applications.
Relevant Source Files
Top-Level Entry and Options
The root CMakeLists.txt defines three major options:
NAPPGUI_SHARED, NAPPGUI_DEMO, and NAPPGUI_WEB.
It then loads the version script, compiler configuration, utility helpers, checks WebView support,
generates the nrc tool, and finally expands the target list from CMakeTargets.cmake.
In other words, the build is not just a list of add_subdirectory calls. There is a fixed configure pipeline
that computes toolchain facts and build options first.
Target Discovery and Generation
nap_target(...) in NAppTarget.cmake recursively scans each module directory,
filters platform/toolkit-specific subdirectories like win, osx, gtk, and linux,
collects public headers, and then creates either a static/shared library or a platform-specific executable target.
The module list itself comes from CMakeTargets.cmake. That is the real build graph source of truth for the shipped libraries,
demos, and the tools/nrc resource compiler.
Resource Pipeline and NRC
Resource handling is built into the target helpers. nap_generate_tools() first configures and builds the separate
tools project so that nrc exists before the main configure/generate process continues.
Later, nap_resource_packs(...) walks res/ folders, adds them to the IDE view, and optionally compiles each
resource pack either as generated C/H sources (NRC_EMBEDDED) or as packed resources copied near the app (NRC_PACKED).
Windows manifests and icons, macOS bundle icons, and Linux desktop icons are all handled in the same layer.
Compiler and Platform Configuration
| Platform | Main Decisions Made By CMake |
|---|---|
| Windows | Detects architecture, configures MSVC/GCC/Clang flags, Unicode defines, runtime library model, and Win32 import/export settings. |
| macOS | Derives the base SDK, deployment target, architecture, Cocoa framework paths, and adds UniformTypeIdentifiers when deployment target is newer than 11. |
| Linux | Detects distro/toolchain, forces a toolkit choice through CMAKE_TOOLKIT, and currently supports GTK3 as the native GUI stack. |
WebView Gating
nap_check_webview_support() decides whether the build can enable browser widgets. The rules are platform-specific:
Windows requires MSVC 19+ and excludes MinGW, macOS requires a deployment target above 10.9.9999,
and Linux requires a matching WebKitGTK package.
When the check succeeds, NAPPGUI_WEB_SUPPORT is added to the osgui target and the right system libraries
are linked. That means the public webview API is always present, but backend behavior depends on compile-time capability.
Project Helpers and Installed Package
NAppProject.cmake provides scaffolding helpers for desktop apps, command apps, and new libraries. Those helpers can create
starter sources and resource folders, then call nap_desktop_app, nap_command_app, or nap_library.
The installed package exports nappgui-targets.cmake, generated define/option files, and a nappgui-config.cmake
that exposes NAPPGUI_LIBRARIES. In this checkout, that exported list includes encode but not inet or ogl3d.