114 lines
3.2 KiB
Markdown
114 lines
3.2 KiB
Markdown
# tinyldap CMake build
|
|
|
|
This fork can be built with CMake in addition to the original Makefile.
|
|
The CMake build is out-of-tree friendly and can be used either as a top-level
|
|
project or via `add_subdirectory()`.
|
|
|
|
## Basic build
|
|
|
|
```sh
|
|
cmake -S . -B build
|
|
cmake --build build
|
|
ctest --test-dir build --output-on-failure
|
|
cmake --install build --prefix /usr/local
|
|
```
|
|
|
|
By default CMake builds a shared library, the server and the same command-line
|
|
tools that the original Makefile builds.
|
|
|
|
## Static and shared libraries
|
|
|
|
```sh
|
|
cmake -S . -B build \
|
|
-DTINYLDAP_BUILD_STATIC=ON \
|
|
-DTINYLDAP_BUILD_SHARED=ON
|
|
```
|
|
|
|
## Custom server and library name
|
|
|
|
`TINYLDAP_OUTPUT_NAME` controls the library basename and, unless overridden, the
|
|
server executable name:
|
|
|
|
```sh
|
|
cmake -S . -B build -DTINYLDAP_OUTPUT_NAME=nwdirectory
|
|
```
|
|
|
|
This builds `libnwdirectory.so` / `libnwdirectory.a` and a server named
|
|
`nwdirectory`.
|
|
|
|
For a different server name only:
|
|
|
|
```sh
|
|
cmake -S . -B build \
|
|
-DTINYLDAP_OUTPUT_NAME=nwdirectory \
|
|
-DTINYLDAP_SERVER_NAME=my-ldapd
|
|
```
|
|
|
|
## Include layout
|
|
|
|
Public headers are exported under an include subdirectory. By default it matches
|
|
`TINYLDAP_OUTPUT_NAME`:
|
|
|
|
```c
|
|
#include <tinyldap/ldap.h>
|
|
```
|
|
|
|
or with `-DTINYLDAP_OUTPUT_NAME=nwdirectory`:
|
|
|
|
```c
|
|
#include <nwdirectory/ldap.h>
|
|
```
|
|
|
|
The build tree has the same layout under `${binary_dir}/include`, which makes
|
|
submodule use straightforward.
|
|
|
|
## libowfat dependency
|
|
|
|
When libowfat is already present in the parent build, TinyLDAP uses the target
|
|
`libowfat::libowfat`. Otherwise it tries `find_package(libowfat CONFIG)` and
|
|
then a plain library lookup.
|
|
|
|
TinyLDAP sources use `#include <libowfat/...>`. If the libowfat build exports a
|
|
prefixed include directory such as `nwlibowfat`, set:
|
|
|
|
```sh
|
|
-DTINYLDAP_LIBOWFAT_INCLUDE_SUBDIR=nwlibowfat
|
|
```
|
|
|
|
When TinyLDAP is added below the CMake libowfat build, this is detected from
|
|
`LIBOWFAT_INSTALL_INCLUDE_SUBDIR` automatically.
|
|
|
|
If libowfat has been configured in a separate build tree but not installed yet,
|
|
pass that build directory directly:
|
|
|
|
```sh
|
|
cmake -S . -B build \
|
|
-DTINYLDAP_LIBOWFAT_BUILD_DIR=/path/to/mars-libowfat-build \
|
|
-DTINYLDAP_LIBOWFAT_INCLUDE_SUBDIR=nwlibowfat
|
|
```
|
|
|
|
TinyLDAP also detects this situation when the libowfat build directory is listed
|
|
in `CMAKE_PREFIX_PATH` and contains a build-tree `libowfat-config.cmake` without
|
|
an installed `libowfat-targets.cmake`.
|
|
|
|
## OpenSSL / MatrixSSL compat
|
|
|
|
TinyLDAP currently needs OpenSSL-style MD5 APIs for `auth.c` and `md5password.c`.
|
|
If the parent project already provides `OpenSSL::Crypto` via MatrixSSL's
|
|
OpenSSL-compat target, TinyLDAP will use it. Otherwise CMake falls back to the
|
|
system OpenSSL Crypto library.
|
|
|
|
For a separate MatrixSSL build tree that has not been installed, pass:
|
|
|
|
```sh
|
|
cmake -S . -B build \
|
|
-DTINYLDAP_MATRIXSSL_BUILD_DIR=/path/to/mars-matrixssl-build \
|
|
-DTINYLDAP_MATRIXSSL_INCLUDE_SUBDIR=nwmatrixssl
|
|
```
|
|
|
|
The MatrixSSL include subdirectory is auto-detected when possible. The imported
|
|
build-tree target adds the correct include root so TinyLDAP's
|
|
`#include <openssl/md5.h>` can resolve MatrixSSL's OpenSSL compatibility header.
|
|
If that build tree does not provide `openssl/md5.h`, TinyLDAP generates a small
|
|
build-local MD5 wrapper around MatrixSSL's `psMd5*` API.
|