FORGE KUI / learn

Build and package the settings app

Match the CRT, copy runtime libraries and check startup and form actions in an independent directory.

Version 3.61.7

Lesson 05
Before you start
A settings page with verified editing and saving
What you will build
Produce a copied folder that launches independently
Download project ↓settings-lab.zip

How the project includes its pages

CMake reads both HTML variants and app.css, inserts styles into the pages and generates generated_page.h. Both interfaces are compiled into the executable. Apps using loadFile or external fonts and images must still deploy those resources.

cmake
cmake_minimum_required(VERSION 3.20)
project(forge_kui_settings_lab LANGUAGES CXX)
if(NOT CMAKE_CXX_STANDARD)
  message(FATAL_ERROR "Set CMAKE_CXX_STANDARD to match the selected SDK package.")
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(MSVC)
  add_compile_options(/utf-8)
endif()
find_package(Kui 3 REQUIRED)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/app.css" APP_CSS)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/settings.zh.html" APP_HTML_ZH)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/settings.en.html" APP_HTML_EN)
string(REPLACE "<!-- APP_CSS -->" "<style>${APP_CSS}</style>" APP_HTML_ZH "${APP_HTML_ZH}")
string(REPLACE "<!-- APP_CSS -->" "<style>${APP_CSS}</style>" APP_HTML_EN "${APP_HTML_EN}")
configure_file(page.h.in generated_page.h @ONLY)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS app.css settings.zh.html settings.en.html)
add_executable(settings_lab main.cpp)
target_include_directories(settings_lab PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
target_link_libraries(settings_lab PRIVATE Kui::Kui)
kui_copy_runtime_dlls(settings_lab)
include(CTest)
if(BUILD_TESTING)
  add_executable(settings_state_test settings_state_test.cpp)
  add_test(NAME settings_state COMMAND settings_state_test)
endif()

Release and Debug

Release uses /MD with the Release core. Debug normally uses /MDd with the Debug core. If an existing consumer intentionally uses /MD in Debug, set Kui_USE_DEBUG_VARIANT OFF before find_package. Renaming or swapping a DLL does not fix an ABI mismatch.

Build and data-model regression

Configure and build, then run CTest. The regression checks trimming, length boundaries, preserved state after rejection and literal-text storage. Also launch the real window to check inputs and buttons.

powershell
$cxxStandard = Read-Host SDK-standard
cmake -S . -B build -A x64 "-DCMAKE_CXX_STANDARD=$cxxStandard" -DKui_DIR=G:/SDK/kui/cmake
cmake --build build --config Release --parallel 4
ctest --test-dir build -C Release --output-on-failure
.\build\Release\settings_lab.exe

Run from an independent directory

Create a staging directory and copy the executable and runtime DLLs from the build output. This packages the lesson app, not a new SDK release. Move staging elsewhere and check saving, restoring and validation states.

powershell
New-Item -ItemType Directory -Force staging
Copy-Item .\build\Release\settings_lab.exe .\staging\
Copy-Item .\build\Release\*.dll .\staging\
.\staging\settings_lab.exe --english

Delivery notes

Record SDK version, operating system, architecture, build configuration and third-party licenses. This exercise has no file persistence, real notifications or online service. Adding them requires error handling, a resource manifest and corresponding tests.

Practice and acceptance

Use these actions to check completion; there is no need to copy the same code into another project.

  • Copy Release output and its matching DLLs into a separate folder.
  • Run both languages from another working directory.
  • Embedded pages need no separate HTML, but added external assets must ship.
  • Check startup and saving without a developer PATH.