https://github.com/nitrix/libpq-cmake
A CMake port of libpq.
https://github.com/nitrix/libpq-cmake
Last synced: 7 days ago
JSON representation
A CMake port of libpq.
- Host: GitHub
- URL: https://github.com/nitrix/libpq-cmake
- Owner: nitrix
- License: unlicense
- Created: 2026-05-19T00:09:49.000Z (12 days ago)
- Default Branch: master
- Last Pushed: 2026-05-19T02:30:16.000Z (12 days ago)
- Last Synced: 2026-05-19T02:43:34.978Z (12 days ago)
- Language: CMake
- Homepage:
- Size: 47.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# libpq-cmake
A CMake port of [libpq](https://www.postgresql.org/docs/current/libpq.html) (the official C client library for PostgreSQL).
## Usage
The library is intended to be used as a Git submodule.
```sh
git submodule add https://github.com/nitrix/libpq-cmake vendor/libpq
```
```cmake
add_subdirectory(vendor/libpq)
target_add_library(foo libpq::libpq)
```
`libpq::libpq` resolves to the shared variant when `LIBPQ_BUILD_SHARED=ON`,
otherwise to the static one. The static and shared targets are also exposed
explicitly as `libpq::libpq_static` and `libpq::libpq_shared`.
## CMake options
| Option | Default | Description |
|----------------------|---------|-------------------------------------------------------|
| `LIBPQ_WITH_OPENSSL` | `ON` | Build TLS support (`USE_OPENSSL=1`, requires OpenSSL) |
| `LIBPQ_BUILD_SHARED` | `OFF` | Build shared libpq alongside the static one |
| `LIBPQ_BUILD_TESTS` | `OFF` | Build the `connect_test` smoke test |
| `LIBPQ_INSTALL` | `ON` | Generate install / `find_package` export rules |
## Needed for SSL
| Platform | Compiler | Postgres source on host | OpenSSL |
|-----------------------|------------------|--------------------------------------------|----------|
| Linux | gcc / clang ≥ 12 | apt `libssl-dev` | system |
| macOS | Apple clang | `brew install openssl@3` | Homebrew |
| Windows MSVC | MSVC 2022 | vcpkg `openssl:x64-windows` | vcpkg |
| Windows MSYS2 CLANG64 | clang 18+ | `pacman -S mingw-w64-clang-x86_64-openssl` | MSYS2 |
| Windows Cygwin | gcc | `libssl-devel` (Cygwin) | Cygwin |
## Credits
Entirely goes to the [postgres](https://github.com/postgres/postgres) project.
I made this repository for convenience only.
## License
Except for the work done by the postgres authors which has [its own license](https://github.com/postgres/postgres/blob/master/COPYRIGHT),
you may use this repository however you like.
See [UNLICENSE](UNLICENSE) for more information.