... 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
```
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
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.
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
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.
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