C++ docs: Add a getting started section

This combines the tutorial sub-section from the intro (a bit weird as sub-section there)
and the usage part of the cmake section into a getting started that
has a complete little C++ example.
This commit is contained in:
Simon Hausmann 2021-07-02 16:20:58 +02:00
parent 13bd828b96
commit 8f9a723e75
4 changed files with 89 additions and 38 deletions

View file

@ -86,37 +86,5 @@ and downloading the `cpp_bin` artifact.
After extracting the artifact you can place the `lib` directory into your `CMAKE_PREFIX_PATH` and `find_package(SixtyFPS)` should succeed
in locating the package.
## Usage
Once SixtyFPS is built, you can use it in your CMake application or library target in two steps:
1. Associate the `.60` files that you'd like to use by calling the `sixtyfps_target_60_sources` cmake command. The first parameter is
your application (or library) CMake target, and the parameters following are the names of the `.60` files. This will result in the
`.60` files to be compiled into C++ source code.
2. The generated C++ source code also needs the SixtyFPS run-time library. This dependency is satisfied by linking `SixtyFPS::SixtyFPS`
into your target with the `target_link_libraries` command.
A typical example looks like this:
```cmake
cmake_minimum_required(VERSION 3.16)
project(my_application LANGUAGES CXX)
# Note: Use find_package(SixtyFPS) instead of the following three commands, if you prefer the package
# approach.
include(FetchContent)
FetchContent_Declare(
SixtyFPS
GIT_REPOSITORY https://github.com/sixtyfpsui/sixtyfps.git
GIT_TAG v0.1.0
SOURCE_SUBDIR api/sixtyfps-cpp
)
FetchContent_MakeAvailable(SixtyFPS)
add_executable(my_application main.cpp)
sixtyfps_target_60_sources(my_application my_application_ui.60)
target_link_libraries(my_application PRIVATE SixtyFPS::SixtyFPS)
```
In the next section you will learn how to use the installed library in your application
and load `.60` UI files.