Commit graph

47 commits

Author SHA1 Message Date
Simon Hausmann
154d877d9f CMake: Add support for overriding the translation domain via a target property
This is useful in environments such as esp-idf, where the component name is something awkward like __esp_idf_main or so.
2025-03-14 14:46:29 +01:00
Olivier Goffart
278e140147 Fix typo 2025-02-25 09:18:46 +01:00
Olivier Goffart
1e814c9bdc
Stabilize the sdf-fonts feature
Enable the SDF feature by default in our compiler binaries

(Still disabled by default for other users because it takes up compile
time for something they probably don't need)
2025-02-19 21:24:53 +01:00
Olivier Goffart
014b58c81a
C++: allow to configure bundled translation 2024-11-18 15:57:08 +01:00
ArcticLampyrid
132e09130e feat(cpp): evaluate generator expression in the context of target
Link: https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#genex:TARGET_GENEX_EVAL
2024-10-02 11:41:09 +02:00
ArcticLampyrid
c145345827 feat(cpp): support generator expression for SLINT_EMBED_RESOURCES & SLINT_SCALE_FACTOR 2024-10-02 11:41:09 +02:00
Simon Hausmann
b0db6d78fd Prospective fix for downloadling slint-compiler for Slint releases
The GitHub release name has the git tag name, so a v prefix.
2024-09-23 17:23:02 +02:00
Simon Hausmann
069b157143 Unify Slint project version in CMake build 2024-08-29 11:23:09 +02:00
Simon Hausmann
90b2058e49 Make it possible to configure a CMake build with the slint-compiler to be downloaded at app configure time 2024-08-29 11:23:09 +02:00
Simon Hausmann
35de15ce4b Remove stray CMake cache variable setting
The same line exists unconditionally further down in the same file.
2024-08-28 11:16:55 +02:00
Simon Hausmann
5d03d6e1bd Simplify slint-compiler import location logic in SlintConfig.cmake.in
Instead of detecting the suffix, just copy across the corrosion-determined file name.

Amends 13975d9def
2024-08-25 21:05:55 +02:00
Simon Hausmann
13975d9def Fix locating the slint-compiler.exe on cmake cross-compiled packages
When cross-compiling CMAKE_EXECUTABLE_SUFFIX may not be set to .exe even
though the host is Windows, because this variable always refers to the
target. This is a missing feature in cmake, so work around it for now.
See also https://gitlab.kitware.com/cmake/cmake/-/issues/17553 I made a
similar workaround in Corrosion long time ago with commit
b8a6b26a0f2d526e0492df9fd88c0495b0b8a64f

The target prop line is duplicated in favor of introducing a variable,
that would otherwise be at risk of being visible in the user scope.
2024-08-23 18:10:11 +02:00
Simon Hausmann
c25a03d6f7 C++: Make it possible to split up the C++ code generated for a .slint file
Add a COMPILATION_UNITS argument to slint_target_sources that defines into how many .cpp files to split up a .slint file. The new default is now one.
2024-08-20 15:53:24 +02:00
Simon Hausmann
a727d87796 CMake: Make it possible to override the scale factor
Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
2024-08-14 11:00:50 +02:00
Simon Hausmann
964de46c51 C++: Make the system testing feature automatically enable debug info
While we haven't settled on the debug info feature and are
merely controlling it via environment variable, setting that can be very hard - especially when using Yocto.

To make life easier, let's do in C++ what we can't easily do for Rust but would like to:

When enabling system testing, automatically emit the necessary debug info, by setting the environment variable when calling the compiler.

This is done by adding SLINT_ENABLED_FEATURES and SLINT_DISABLED_FEATURES properties
on the Slint::Slint target that - as lists - export the list of features and their status.

This way we can compile Slint in once place and safely in the CMake code running in application
scope check about the available features.
2024-07-04 13:39:13 +02:00
Simon Hausmann
6f2a6c3f09 CMake: Add support for LIBRARY_PATHS to slint_target_sources
This makes it possible to use component libraries with C++.
2024-06-05 11:07:12 -07:00
Aurindam Jana
3523e86359
Simplify commercial license (#3063)
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
2024-05-31 14:06:17 +02:00
Aurindam Jana
9a3aa265d5
Update Royalty-free license (#5257)
Add clarification that Application may not expose Slint APIs.
2024-05-31 10:53:19 +02:00
Olivier Goffart
4856f387ee C++ Todo example: add test 2024-04-22 13:54:28 +02:00
Aurindam Jana
0cfeec1a31
Update Slint Community License (#4994)
Updated the version from 1.1 to 1.2 
Renamed the header to "Slint Royalty-free Desktop, Mobile, and Web Applications License"
Added definition of "Mobile Application" and grant of right
Moved "Limitations" to 3rd section and "License Conditions - Attributions" to 2nd section
Added flexibility to choose between showing "MadeWithSlint" as a dialog/splash screen or on a public webpage
Moved the para on copyright notices to section under "Limitations"
2024-04-15 15:18:55 +02:00
Wilston Oreo
bef532b5fc
Optional C++ namespaces (#4759)
Co-authored-by: Michael Winkelmann <michael@winkelmann.site>
2024-03-06 19:43:11 +01:00
Simon Hausmann
231dbd5695 Revert "Revert "Improve file type for SLINT_COMPILER cmake cache variable""
This reverts commit 292f487815.

Olivier had the brilliant idea of preceeding the path with a slash
on the Yocto side, so we can go back to the correct "type".
2023-10-06 14:56:28 +02:00
Simon Hausmann
292f487815 Revert "Improve file type for SLINT_COMPILER cmake cache variable"
This reverts commit 0773e51d92.

By the SLINT_COMPILER being a `FILEPATH`, cmake will convert any
relative path to an absolute path. That's not wanted for the Yocto
build, because there we pass
'$ENV{OECORE_NATIVE_SYSROOT}/usr/bin/slint-compiler', so that
the path is resolved dynamically against the environment variable that
the Yocto SDK sets.

CMake would convert this to an absolute path that points into the build
directory, i.e. it would be /home/blah/foo/\$ENV{...}
2023-10-06 13:05:30 +02:00
Simon Hausmann
0773e51d92 Improve file type for SLINT_COMPILER cmake cache variable
Use a FILEPATH to reflect that this is a path to a file and then the cmake configurator will
show a file dialog.
2023-10-02 13:15:20 +02:00
Olivier Goffart
14f7fe4ba2
cmake: add flags to only build the compiler
... and to use an external compiler

For example, this is how one only build the compiler:

```
cmake .. -DSLINT_BUILD_RUNTIME=OFF -DCMAKE_INSTALL_PREFIX=/tmp/slint_compiler
make install
```

And this only build the runtime
```
cmake .. -DSLINT_FEATURE_COMPILER=OFF -DCMAKE_INSTALL_PREFIX=/tmp/install_runtime
make install
```

And then this can be used in a project like so:
```
cmake .. -DCMAKE_PREFIX_PATH=/tmp/install_runtime/ -DSLINT_COMPILER=/tmp/install_compiler/bin/slint-compiler
```
2023-09-15 14:42:52 +02:00
Olivier Goffart
e46704465b C++: DEPFILE is supported on most generator in recent cmake versions 2023-08-30 09:54:03 +02:00
Olivier Goffart
de0836d1a0 C++: Fix ninja always rebuilding the .slint file
two bugs:
 - If the .slint file did not contain any import, the depfile would have
   no dependencies, and as a result, ninja would consider that it is
   always dirty.
 - In case the binary dir is a sub directory, the dependencies were
   relative to the wrong directory. Thgis is because the behavior
   changed in some version of cmake (see https://cmake.org/cmake/help/latest/policy/CMP0116.html)
   to avoid any problem, use the absolute paths

Fixes #3261
2023-08-30 09:54:03 +02:00
Simon Hausmann
e9286c1189 Make it possible to build the slint-cpp crate as a static library
This isn't supported on desktop yet, but on MCU it is.

Cargo is instructed to build a dylib and a staticlib, but corrosion
instructs rustc to build only either dylib or staticlib.

Corrosion listens to the BUILD_SHARED_LIBS option and will change the
default for the Slint::Slint INTERFACE_LINK_LIBRARIES to either
slint-cpp-shared or slint-cpp-static. This way the selection is
transparent to the users.
2023-07-21 18:32:45 +02:00
Aurindam Jana
5a4a7fee63
Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
Olivier Goffart
11dea135f7 Domain: slint-ui.com -> slint.dev 2023-06-16 10:55:08 +02:00
Tobias Hunger
04d1229685 Fix licnese information using xtask 2023-06-16 09:14:20 +02:00
Olivier Goffart
ce25fb65a6 Pass the translation domain to the runtime
For rust, it uses the crate name, for others, it needs to be passed in
the comment line
2023-06-05 16:34:59 +02:00
Tobias Hunger
6934b7b779 cmake: Fix SLINT_EMBED_RESOURCES
* Do not use the initialize_from feature introduced in cmake 3.23
2023-03-27 16:18:05 +02:00
Tobias Hunger
c5ecade881 Rename embed-resources parameters fro the Slint compiler 2023-03-27 09:27:44 +02:00
Tobias Hunger
5915f73918 cmake: Add support for SLINT_EMBED_RESOURCES as a target property 2023-03-27 09:27:44 +02:00
Jonathan Schwender
4ade9faa0d Update Corrosion to v0.3
This requires the following changes:
- Delay configuring SlintConfig.cmake:
  Corrosion sets the `IMPORTED` locations late to allow us to set
  OUTPUT_DIRECTORY target properties. The configuration of
  SlintConfig.cmake must be deferred until after Corrosion set the
  locations. Since we are writing to a config file Generator expressions
  are not an option.
- Remove BUILD_TYPE mapping from SlintConfig.cmake:
  As discussed in https://github.com/slint-ui/slint/pull/1785#issuecomment-1294630845
  remove the mapping of the build types since corrosion now always sets
  the `IMPORTED_LOCATION` property.

User facing improvements enabled by the update:
- Corrosion will not fail anymore if the user has a Rust toolchain >=1.60
  installed, but the default toolchain is < 1.60.
- Corrosion will respect OUTPUT_DIRECTORY properties and move target
  artifacts to the expected locations
2022-11-02 21:38:39 +01:00
Olivier Goffart
29d28dc73e C++: don't force the SLINT_STYLE cmake variable
Keep the default if unset, otherwise use whatever SLINT_STYLE was passed
2022-07-20 12:18:18 +02:00
Simon Hausmann
df2d6442d4 Make it possible to disable the slint compiler from the CMake build
This isn't always needed, for example when using only the interpreter API,
and its dependency to native libraries on Linux (namely fontconfig) makes it difficult to cross-compile with
CMake.

While cargo is invoked correctly for the native binary build, the library search paths
coming from CMake will be target specific, not host specific.

So for now this provides a way of disabling the compiler.
2022-03-22 12:59:52 +01:00
Tobias Hunger
526166090e cmake: Do not break when slint is build with empty CMAKE_BUILD_TYPE
Do not break building against slint using CMake from C++ when no
CMAKE_BUILD_TYPE was set when building Slint.

This just makes sure the build type is properly quoted, which makes sure
we keep a (empty) string token where CMake expects one.

Fixes: #1065
2022-03-17 18:18:20 +01:00
Tobias Hunger
ebe3a3c37c cpp: Fix cmake property mapping
Fix the mapping between a projects CMAKE_BUILD_TYPE and the build type
of the imported Slint library.

Fixes #1027
2022-03-09 19:53:06 +01:00
Tobias Hunger
4230ac2572
Update copyright information to reflect name change
Also run resue over the codebase and fix complaints from that tool.
2022-02-09 10:27:47 +01:00
Simon Hausmann
ef822cc1e8 Clean up target_sources macro
Finish the renaming inside
2022-02-02 10:39:38 +01:00
Olivier Goffart
03534039d6 Replace more .60 by .slint
Mainly an automated change with
    git grep -O"sed -i 's/\.60/.slint/g'" -w "\.60"

and some manual checks
2022-02-02 10:12:31 +01:00
Simon Hausmann
b1a70f9e58 Rename the SixtyFPS CMake interface 2022-02-02 09:58:26 +01:00
Simon Hausmann
c333b4de2b Rename the sixtyfps-cpp crate 2022-02-02 09:27:11 +01:00
Simon Hausmann
017da5b3b4 Rename the sixtyfps-compiler crate 2022-02-02 09:07:16 +01:00
Tobias Hunger
842f75e653 [reorg]: Move api/sixtyfps-rs/sixtyfps-* into api/rs 2022-01-31 18:24:33 +01:00