|
ORM C++
|
For a first working application without central catalog availability, start with the SQLite quickstart. This guide separates consumer installation from maintainer publishing.
VERSION.txt is the release version shared by CMake, vcpkg, and Conan. The current version is 0.6.0; use a stable major.minor.patch value and increase it before publishing changed sources. The library currently ships as a static library.
The Packages workflow validates packages on main, pull requests, and release. A successful push to release also publishes a GitHub source release and opens pull requests against the official microsoft/vcpkg and conan-io/conan-center-index repositories. Their maintainers review the requests; their infrastructure makes an accepted package available in the central catalog. An upstream GitHub release or a successful submission job does not mean the package is already available there. Until the initial requests are accepted, the central installation examples below will not resolve orm-cxx.
No private registry or Conan remote is required. SOCI and enabled database client libraries and fmt are dependencies of the package and are installed by the manager. The minimum SOCI version is 4.1.4, including MySQL TLS mode support. The pinned vcpkg baseline supplies SOCI 4.1.4 and Oracle libmysql 8.0.46; the Conan recipe uses SOCI 4.1.4 and its Oracle libmysqlclient dependency. Consumers require GCC 15+, Clang 18+, or MSVC 19.50+, CMake 3.31+, Ninja 1.11+, and the selected package manager. Standard-library headers are included normally; header units and import std are not required. On a minimal Linux host, vcpkg also needs ordinary host tools pkg-config, bison, flex and perl; the Packages workflow installs them. No manual SOCI or selected-client development-package installation is needed. Building the vcpkg Oracle client on Debian/Ubuntu also needs the system RPC and terminal development headers from libtirpc-dev and libncurses-dev when MySQL or MariaDB is selected. SQLite works in process; PostgreSQL, MySQL and MariaDB need a database server to connect to (the package supplies the client library, not a running server).
Add an orm-cxx dependency to the application's vcpkg.json:
This selects core-only. Backend features are independent and default to disabled: sqlite, postgresql, mysql and mariadb. For example, {"name": "orm-cxx", "features": ["mysql", "mariadb"]} enables those two providers with one shared SOCI MySQL driver and Oracle client. Select all four features to enable every adapter. Pin a builtin-baseline containing the accepted port for reproducible builds.
The port always builds the orm-cxx static library. x64-windows is supported and uses the dynamic Microsoft CRT selected by that triplet. Select x64-windows-static when the application and its dependencies must use the static Microsoft CRT:
On Linux the default x64-linux triplet is suitable.
The imported target propagates C++20, module source file sets, import metadata, and transitive linkage. Applications write import orm;; the module exposes the enabled backends as orm::config::sqliteBackendEnabled and orm::config::postgresqlBackendEnabled, orm::config::mysqlBackendEnabled and orm::config::mariadbBackendEnabled. No compiler macro definitions are exported. find_package(orm-cxx-reflection CONFIG REQUIRED) exposes the compiled orm-cxx::reflection target for import orm.reflection; without SOCI dependencies.
Use Conan 2 and a conanfile.txt:
Use the same find_package(orm-cxx) and target as above. Conan preserves the library's native CMake configs; CMakeDeps supplies the dependency configs and skips generating an orm-cxx replacement. The native config also exposes orm-cxx::reflection. Conan options are with_sqlite3, with_postgresql, with_mysql and with_mariadb; all default to False. Pass -o orm-cxx/*:with_mysql=True, for example, to conan install. MySQL and MariaDB share one SOCI with_mysql dependency and Oracle libmysqlclient. ConanCenter supplies available binaries; --build=missing builds configurations without a matching binary.
Authenticate GitHub CLI as wsekta, preserving SSH for Git operations:
The second command must print wsekta. Add the repository Actions secret PACKAGE_REGISTRY_TOKEN, containing a classic GitHub personal access token created by wsekta, with public_repo scope and a 30-day expiry. It must allow forking the public catalogs, pushing recipe branches to its forks, and opening upstream PRs. Use the GitHub secret input panel to store its value. The repository's ordinary GITHUB_TOKEN cannot perform these cross-repository operations. The script creates the forks automatically. Do not put tokens in files, recipes, workflow inputs, or commit messages.
Use VERSION.txt as the sole release version. The current module API uses 0.6.0; increase the minor version for incompatible changes while on 0.x. For a later release, increase it before preparing changed sources. Review the changes on main and wait for all its checks. Create release from that exact reviewed SHA, or fast-forward the existing branch to it. For example, for the first release only, substitute the approved commit SHA:
Release jobs only run for the release branch. PR builds receive no publication credentials. Published tags, commits, and source assets are immutable: the script requires the exact tested commit and bytes, and refuses a conflicting tag or hash. Pushes are never forced, open PRs are reused, and a closed unmerged submission requires maintainer action. Increase VERSION.txt when changing published sources. If a network failure interrupts an unpublished draft, rerunning completes missing assets after checking the assets already present. A missing token stops publishing with an actionable error instead of reporting false success.
For a configuration or transient failure, correct the configuration and rerun failed jobs for the same release run and SHA. A manual workflow dispatch on release is also safe while the branch still points to that SHA.
If only the submission script needs fixing after publication, commit the fix on main, then run only the affected catalog submission with the updated script and the original package-distribution artifact, including its original release.json, archive, checksums, and generated recipes. Download it from the successful release run and choose a new --work directory for each retry:
Authenticate these local commands as wsekta, or provide GH_TOKEN for that account. --expected-owner wsekta can explicitly select the same owner check. Do not rerun prepare_packages.py from the newer main, move the published tag, or run the complete release workflow from a moved release branch with the same version. A conflict in the immutable sources must be resolved before proceeding.
Install the packaging tools into a Python virtual environment:
On Windows, run in a Visual Studio developer shell and bootstrap with externals\vcpkg\bootstrap-vcpkg.bat. The default validation triplet is x64-windows-static on Windows and x64-linux on Linux. x64-windows is also supported and produces a static orm-cxx library with the triplet's dynamic CRT; use x64-windows-static when validating a fully static CRT configuration. --backends accepts core, all, and any canonical plus-separated subset of sqlite, postgresql, mysql and mariadb, such as mysql+mariadb. The default is core; CI checks all 16 independent subsets. Use a separate --work directory for each concurrent invocation. The Conan check defaults CONAN_HOME to build/conan-home and detects a profile there. To use an existing profile, pass --conan-profile=PROFILE. --conan-setting and --conan-conf are repeatable overrides (for example, --conan-setting=compiler.version=195 when multiple Visual Studio versions are installed). Use --conan-conf=tools.microsoft.msbuild:vs_version=18 to select Visual Studio 2026 explicitly. The vcpkg check follows the active developer shell's Visual Studio installation; an explicit VCPKG_VISUAL_STUDIO_PATH overrides that selection. Explicit CONAN_HOME values are honored.
The scripts generate an archive containing only this project's library sources and metadata, normalizing CRLF to LF so its bytes and checksums are stable across Windows and Linux checkouts. A temporary loopback HTTP server supplies that same archive to the actual recipes, including their checksum verification. Consumers build without the source tree or bundled dependency submodules. Every configuration builds typed Query, Update, and ProjectionQuery expressions. Consumer targets enable strict warnings and warnings-as-errors privately; those flags are not exported to applications. MSVC consumers inherit only the suppression of SOCI DLL/STL diagnostics C4251 and C4275, which MSVC otherwise re-emits at module import sites despite external header warning suppression. Consumers verify the four generated configuration flags, exact registry membership and compile failures for disabled provider types. Linux package CI starts real PostgreSQL, MySQL and MariaDB services and requires CRUD, projection and migration smoke tests for every selected provider. SQLite uses an in-memory database. Local live server checks use typed ORM_CXX_<BACKEND>_TEST_* fields; set ORM_CXX_REQUIRE_PACKAGE_DATABASE_TESTS=1 to require a successful live smoke for every selected adapter. Both managers check all 16 subsets on Linux and Windows. Windows vcpkg also checks SQLite and all four backends with the dynamic CRT triplet. Templates under packaging/ become the prepared versioned recipes under build/distribution.
Package recipes set ORM_CXX_USE_SYSTEM_SOCI=ON, disable developer tests and examples, then use cmake --install. An existing SOCI CMake package is required in this mode. Installed configs provide orm-cxx::orm-cxx and orm-cxx::reflection; full-library components are core, reflection, sqlite3, postgresql, mysql and mariadb. Requesting a disabled backend as a required CMake component fails at configuration time. Compatibility is limited to the same minor release series while the library is at version 0.x.
Packages install .cppm interface sources under share/orm-cxx/modules and CMake export metadata alongside their native configs. CMake generates BMIs in the consumer's build tree using that consumer's compiler. The package does not ship prebuilt BMIs as a portable API, and the static libraries still require a compatible compiler, standard library, CRT, and ABI configuration. Use the same C++20 standard and build type for package creation and consumption.
Both modules are the sole public API; public ORM headers are not installed. The normal repository/submodule build uses the same module targets.
References: GitHub CLI authentication, GitHub token scopes, vcpkg central submissions, ConanCenter contribution guide.