mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-30 07:07:25 +00:00
Optional C++ namespaces (#4759)
Co-authored-by: Michael Winkelmann <michael@winkelmann.site>
This commit is contained in:
parent
43266f7f76
commit
bef532b5fc
11 changed files with 148 additions and 19 deletions
|
@ -5,23 +5,26 @@
|
|||
## `slint_target_sources`
|
||||
|
||||
```
|
||||
slint_target_sources(<target> <files>....)
|
||||
slint_target_sources(<target> <files>.... [NAMESPACE namespace])
|
||||
```
|
||||
|
||||
Use this function to tell cmake about the .slint files of your application, similar to the builtin cmake [target_sources](https://cmake.org/cmake/help/latest/command/target_sources.html) function.
|
||||
The function takes care of running the slint-compiler to convert `.slint` files to `.h` files in the build directory,
|
||||
and extend the include directories of your target so that the generated file is found when including it in your application.
|
||||
|
||||
The optional NAMESPACE argument will put the generated components in the given C++ namespace.
|
||||
|
||||
Given a file called `the_window.slint`, the following example will create a file called `the_window.h` that can
|
||||
be included from your .cpp file.
|
||||
be included from your .cpp file. Assuming the `the_window.slint` contains a component `TheWindow`, the output
|
||||
C++ class will be put in the namespace `ui`, resulting to `ui::TheWindow`.
|
||||
|
||||
```cmake
|
||||
add_executable(my_application main.cpp)
|
||||
target_link_libraries(my_application PRIVATE Slint::Slint)
|
||||
slint_target_sources(my_application the_window.slint)
|
||||
slint_target_sources(my_application the_window.slint NAMESPACE ui)
|
||||
```
|
||||
|
||||
|
||||
## Resource Embedding
|
||||
|
||||
By default, images from [`@image-url()`](slint-reference:src/language/syntax/types#images) or fonts that your Slint files reference are loaded from disk at run-time. This minimises build times, but requires that the directory structure with the files remains stable. If you want to build a program that runs anywhere, then you can configure the Slint compiler to embed such sources into the binary.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue