aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorChris Kay <chris.kay@arm.com>2021-03-25 16:03:25 +0000
committerChris Kay <chris.kay@arm.com>2021-06-04 16:02:48 +0100
commitd259e347e6e3a630acfc1a811709ca05e5d3b92e (patch)
treeb022894809b349030541c1d97ff0f3b26ad1e261 /README.md
parent0c1a42a14754d97d3a1acf23e337b630f560c8f6 (diff)
downloadmbedtls-d259e347e6e3a630acfc1a811709ca05e5d3b92e.zip
mbedtls-d259e347e6e3a630acfc1a811709ca05e5d3b92e.tar.gz
mbedtls-d259e347e6e3a630acfc1a811709ca05e5d3b92e.tar.bz2
Add CMake package config file
This change enables automatic detection and consumption of Mbed TLS library targets from within other CMake projects. By generating an `MbedTLSConfig.cmake` file, consuming projects receive a more complete view of these targets, allowing them to be used as dependencies which properly inherit the transitive dependencies of the libraries. This is fairly fragile, as it seems Mbed TLS's libraries do not appear to properly model their dependencies on other targets, including third-party dependencies. It is, however, sufficient for building and linking the compiled Mbed TLS libraries when there are no third-party dependencies involved. Further work is needed for more complex use-cases, but this will likely meet the needs of most projects. Resolves #298. Probably useful for #2857. Signed-off-by: Chris Kay <chris.kay@arm.com>
Diffstat (limited to 'README.md')
-rw-r--r--README.md27
1 files changed, 27 insertions, 0 deletions
diff --git a/README.md b/README.md
index 3f41a0d..fdaab0a 100644
--- a/README.md
+++ b/README.md
@@ -181,6 +181,33 @@ Regarding variables, also note that if you set CFLAGS when invoking cmake,
your value of CFLAGS doesn't override the content provided by cmake (depending
on the build mode as seen above), it's merely prepended to it.
+#### Consuming Mbed TLS
+
+Mbed TLS provides a package config file for consumption as a dependency in other
+CMake projects. You can include Mbed TLS's CMake targets yourself with:
+
+ find_package(MbedTLS)
+
+If prompted, set `MbedTLS_DIR` to `${YOUR_MBEDTLS_INSTALL_DIR}/cmake`. This
+creates the following targets:
+
+- `MbedTLS::mbedcrypto` (Crypto library)
+- `MbedTLS::mbedtls` (TLS library)
+- `MbedTLS::mbedx509` (X509 library)
+
+You can then use these directly through `target_link_libraries()`:
+
+ add_executable(xyz)
+
+ target_link_libraries(xyz
+ PUBLIC MbedTLS::mbedtls
+ MbedTLS::mbedcrypto
+ MbedTLS::mbedx509)
+
+This will link the Mbed TLS libraries to your library or application, and add
+its include directories to your target (transitively, in the case of `PUBLIC` or
+`INTERFACE` link libraries).
+
#### Mbed TLS as a subproject
Mbed TLS supports being built as a CMake subproject. One can