@@ -49,7 +49,7 @@ GoogleTest is used for testing.
4949
5050For information on integrating an SDK package please refer to the SDK specific README.
5151
52- ## CMake Usage
52+ ## CMake Options
5353
5454Various CMake options are available to customize the client/server SDK builds.
5555
@@ -66,30 +66,59 @@ Various CMake options are available to customize the client/server SDK builds.
6666| ` LD_DYNAMIC_LINK_OPENSSL ` | Whether OpenSSL is dynamically linked or not. | Off (static link) | N/A |
6767| ` LD_BUILD_REDIS_SUPPORT ` | Whether the server-side Redis Source is built or not. | Off | N/A |
6868
69- ** Note:** _ if building the SDKs as shared libraries, then unit tests won't be able to link correctly since the SDK's C++
70- symbols aren't exposed. To run unit tests, build a static library._
71-
7269> [ !WARNING]
7370> When building shared libraries C++ symbols are not exported, only the C API will be exported. This is because C++ does
74- > not have a stable ABI.
71+ > not have a stable ABI. For this reason, the SDK's unit tests are not built in shared library mode.
72+
73+ ## Building the SDK from Source
7574
76- Basic usage example :
75+ To configure the SDK's CMake project :
7776
7877``` bash
79- mkdir -p build && cd build
80- cmake -G" Unix Makefiles" ..
78+ # Use 'make' as the build system.
79+ cmake -B build -S . - G" Unix Makefiles"
8180```
8281
83- Slightly more advanced example - build shared libraries, and don't build any of the testing components :
82+ To pass in config options defined in the table above, add them using ` -D ` :
8483
8584``` bash
86- mkdir -p build && cd build
87- cmake -G" Unix Makefiles" -DLD_BUILD_SHARED_LIBS=On -DBUILD_TESTING=Off ..
85+ # Use 'make' as the build system, build shared libs, and disable testing.
86+ cmake -B build -S . -G" Unix Makefiles" \
87+ -DLD_BUILD_SHARED_LIBS=On \
88+ -DBUILD_TESTING=Off ..
8889```
8990
9091The example uses ` make ` , but you might instead use [ Ninja] ( https://ninja-build.org/ ) ,
9192MSVC, [ etc.] ( https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html )
9293
94+ ## Incorporating the SDK via ` add_subdirectory `
95+
96+ The SDK can be incorporated into an existing application using CMake via ` add_subdirectory. ` .
97+
98+ ``` cmake
99+ # Set SDK build options, for example:
100+ set(LD_BUILD_SHARED_LIBS On)
101+
102+ add_subdirectory(path-to-cpp-sdks-repo)
103+ target_link_libraries(your-app PRIVATE launchdarkly::client)
104+ # ... or launchdarkly::server
105+ ````
106+
107+ ## Incorporating the SDK via `find_package`
108+
109+ > [!WARNING]
110+ > Preliminary support for `find_package` is available. The package configuration is subject to change, do not expect it
111+ > to be stable as long as this notice is present.
112+
113+ If you've installed the SDK on the build system via `cmake --install`, you can consume it from
114+ the target application like so:
115+
116+ ```cmake
117+ find_package(launchdarkly REQUIRED)
118+ target_link_libraries(your-app PRIVATE launchdarkly::launchdarkly-cpp-client)
119+ # ... or launchdarkly::launchdarkly-cpp-server
120+ ```
121+
93122## LaunchDarkly overview
94123
95124[ LaunchDarkly] ( https://www.launchdarkly.com ) is a feature management platform that serves trillions of feature flags
0 commit comments