Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document building picoquic #1611

Merged
merged 11 commits into from
Jan 28, 2024
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ commits changed the Picotls API by removing code for the now obsolete
ESNI draft; prior versions will not work with Picoquic.)
The code can use OpenSSL version 1.1.1 or OpenSSL version 3.0.

More information can be found in the [docs](doc/building_picoquic.md)

## Picoquic on Windows

To build Picoquic on Windows, you need to:
Expand Down
102 changes: 102 additions & 0 deletions doc/building_picoquic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Building PicoQUIC

See the 'Building Picoquic' section [README](../README.md) for building picoquic for the first time and installing the dependencies.

## Dependencies

Direct dependencies
- [Picotls implementation of TLS 1.3](https://github.com/h2o/picotls)

notBroman marked this conversation as resolved.
Show resolved Hide resolved
Fetching and installing this package can be done through an option in the CMake.

```shell
cmake -DPICOQUIC_FETCH_PTLS=Y .
```

This can be set in the cmake file as well by setting the `PICOQUIC_FETCH_PTLS` cmake property to `ON`.

notBroman marked this conversation as resolved.
Show resolved Hide resolved
Inherited dependencies
- [OpenSSL through PicoTLS](https://github.com/openssl/openssl)

TODO: Current issues and ongoing work

There is a current issue trying to enable the use of `mbedtls` instead of `openssl`.

notBroman marked this conversation as resolved.
Show resolved Hide resolved
## Targets

Targets are anything that is defined as an executable in `CMakeLists.txt`.
Available targets:

- picoquicdemo
- picolog_t
- picoquic_ct
- picohttp_ct
- pico_baton
- picoquic_sample
- thread_test

All of these targets are built when the `make .` or `cmake --build .` commands are used to build the project. After which the test program `picoquic_ct` can be used to verify the port.

`picoquicdemo` ([found in picoquicfirst/picoquicdemo.c](../picoquicfirst/picoquicdemo.c)) and `picoquic_sample` ([sample documentation](../sample/README.md)) are a good starting point for developing an application on top of this QUIC implementation.


## (Re)Building a Single Target

Targets defined in the `CMakeLists.txt`, listed above for convenience, can be build individually using cmake's `--target` option. The command `cmake --build . --target <target_name>` can be used to build a specific target and all it's dependcies. For example `cmake --build . --target picoquic_sample` will build the sample file transfer application in [sample/](../sample/README.md) as defined in the `CMakeLists.txt`. All the required components will also be built. This works if the command is issued in the top-level directory of the repository. This is useful for recompiling test programs and programs like `picoquic_sample` and `picoquicdemo` if they have been modified. Therefore reducing build times when making small changes.

This also works if `picoquic` has not been built as a whole before.

## Picoquic options

- building and fetching PTLS `-DPICOQUIC_FETCH_PTLS=Y`
- building with exported debug information `-DCMAKE_BUILD_TYPE=Debug`

These two options can be set when configuring cmake.

- adress sanitation `ASAN`
- undefined behaviour sanitation `UBSAN`

`ASAN` and `UBSAN` need to be set in the `CMakeLists.txt` using the `ENABLE_ASAN` and `ENABLE_UBSAN` options.

notBroman marked this conversation as resolved.
Show resolved Hide resolved
## Picoquic as a Dependency

When using CMake [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) can be used to fetch the `picoquic` repository from github.
A snipped that does this can be seen in the [quicrq](https://github.com/Quicr/quicrq) directory in the `dependencies` subdirectory and is shown below.

```cmake
# Enable fetching content
include(FetchContent)

# Fetch the picoquic library, which brings in picotls with it
FetchContent_Declare(
picoquic
GIT_REPOSITORY https://github.com/private-octopus/picoquic.git
GIT_TAG master
)

# Set the option to force picoquic to fetch the picotls
find_package(PTLS)
if(NOT PTLS_FOUND)
set(PICOQUIC_FETCH_PTLS ON)
end_if()

# Make dependencies available
FetchContent_MakeAvailable(picoquic)
```

FetchContent can be used to fetch a specific release or tag, if a certain version or release is desired.
This can be used as fine grain as choosing a single commit, be specifying the commit hash.

notBroman marked this conversation as resolved.
Show resolved Hide resolved
In the main `CMakeLists.txt` the subdirectory can be added using the `add_subdirectory(<directory_name>)` directive.

```cmake
# Add the subdirectory dependencies, where dependencies/CMakeLists.txt looks as above
add_subdirectory(dependencies)

# check if the package was loaded/is available and stop the build if it was not
find_package(picoquic REQUIRED)
```

notBroman marked this conversation as resolved.
Show resolved Hide resolved
Additionally `cmake` needs to be told where to find the imported dependency, using hints defined in a `cmake/Find<DependencyName>.cmake` file placed in the top-most directory in the repository.
The cmake documentation describes how to [Create CMake Package Configuration Files](https://cmake.org/cmake/help/book/mastering-cmake/chapter/Finding%20Packages.html).

Loading