aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md47
1 files changed, 43 insertions, 4 deletions
diff --git a/README.md b/README.md
index 180a68e4abbe..23d26dad2b92 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@
> at the top of the `Changes` file.
-# Expat, Release 2.6.3
+# Expat, Release 2.6.4
This is Expat, a C99 library for parsing
[XML 1.0 Fourth Edition](https://www.w3.org/TR/2006/REC-xml-20060816/), started by
@@ -43,9 +43,9 @@ This license is the same as the MIT/X Consortium license.
## Using libexpat in your CMake-Based Project
-There are two ways of using libexpat with CMake:
+There are three documented ways of using libexpat with CMake:
-### a) Module Mode
+### a) `find_package` with Module Mode
This approach leverages CMake's own [module `FindEXPAT`](https://cmake.org/cmake/help/latest/module/FindEXPAT.html).
@@ -70,7 +70,7 @@ target_include_directories(hello PRIVATE ${EXPAT_INCLUDE_DIRS})
target_link_libraries(hello PUBLIC ${EXPAT_LIBRARIES})
```
-### b) Config Mode
+### b) `find_package` with Config Mode
This approach requires files from…
@@ -98,6 +98,45 @@ add_executable(hello
target_link_libraries(hello PUBLIC expat::expat)
```
+### c) The `FetchContent` module
+
+This approach — as demonstrated below — requires CMake >=3.18 for both the
+[`FetchContent` module](https://cmake.org/cmake/help/latest/module/FetchContent.html)
+and its support for the `SOURCE_SUBDIR` option to be available.
+
+Please note that:
+- Use of the `FetchContent` module with *non-release* SHA1s or `master`
+ of libexpat is neither advised nor considered officially supported.
+- Pinning to a specific commit is great for robust CI.
+- Pinning to a specific commit needs updating every time there is a new
+ release of libexpat — either manually or through automation —,
+ to not miss out on libexpat security updates.
+
+For an example that pulls in libexpat via Git:
+
+```cmake
+cmake_minimum_required(VERSION 3.18)
+
+include(FetchContent)
+
+project(hello VERSION 1.0.0)
+
+FetchContent_Declare(
+ expat
+ GIT_REPOSITORY https://github.com/libexpat/libexpat/
+ GIT_TAG 000000000_GIT_COMMIT_SHA1_HERE_000000000 # i.e. Git tag R_0_Y_Z
+ SOURCE_SUBDIR expat/
+)
+
+FetchContent_MakeAvailable(expat)
+
+add_executable(hello
+ hello.c
+)
+
+target_link_libraries(hello PUBLIC expat)
+```
+
## Building from a Git Clone