There is an informative video on YouTube: "C++ Package Management for Beginners: vcpkg and Conan Tutorial" https://www.youtube.com/watch?v=8kiAklZGJJE
This repository uses the same example CMakeLists.txt and main.cpp to show how simple, straightforward, and powerful externpro is to streamline your C++ projects.
externpro is a CMake build platform and dependency provider with reusable CI (continuous integration) pipelines.
This tutorial walks through adopting externpro in a project repo:
- vendoring externpro as a
.devcontainersubmodule - running
xpInitto standardize presets + workflows + repo wiring - understanding the tag/build/release flow (
xpTag->xpBuild->xpRelease) - consuming externpro-produced dependencies via CMake
find_package()
What success looks like:
- your repo has an
xprobranch (typically the default branch) - your repo has the caller workflows needed to run
xpInit(and optionallyxpUpdate) - you can merge an
xpInitpull request to adopt externpro's standard presets + workflows + repo wiring - you can build and publish release artifacts usable by downstream projects across multiple compilers, operating systems, and processor architectures
-
fork https://github.com/externpro/tutorial into your github account/organization
- deselect "Copy the
mainbranch only" checkbox:- if you're going to start with the
initbranch (Path A) - if you want your fork to include the
v1.0tag (Path B can fetch the tag from upstream and push it to your fork)
- if you're going to start with the
- deselect "Copy the
This path avoids the local/manual initialization steps. You start from the init branch in GitHub and rename it to xpro.
Choose this path if you want the quickest on-ramp and prefer to do everything in GitHub.
In the repository's "Settings > General" page:
NOTE: The init branch includes commits that:
- add externpro as the
.devcontainersubmodule (but at an older tag) - add the
xpInitworkflow
This means you may be starting with an older externpro template until you run xpUpdate.
In this path (if you follow the instructions below explicitly), the externpro submodule added will point at the HEAD of the main branch of externpro. This path requires that you have git installed and configured locally and that you have write access to your fork (for the git push commands to succeed).
Choose this path if you want to understand (or customize) the wiring by applying it locally.
-
clone your fork to your local machine
NOTE: use a clone URL/auth method that gives you write access to your fork so the
git pushcommands below will succeed.NOTE: run these commands from the directory where you want the
tutorial/folder created.git clone https://github.com/your-username/tutorial -
initialize externpro
You can copy/paste this entire block into your terminal.
cd tutorial git remote add upstream https://github.com/externpro/tutorial git fetch --all # fetch all tags in case fork didn't include tags git checkout -b xpro v1.0 git submodule add https://github.com/externpro/externpro .devcontainer git commit -m "add externpro as submodule" -m "git submodule add https://github.com/externpro/externpro .devcontainer" mkdir -p .github/workflows cp .devcontainer/.github/wf-templates/xpinit.yml .github/workflows/ git add .github/workflows/xpinit.yml git commit -m "workflows: add xpinit" -m "cp .devcontainer/.github/wf-templates/xpinit.yml .github/workflows" git push origin xpro git push origin --tags # in case fork didn't include tags git fetch --all git branch --set-upstream-to=origin/xpro xpro -
set xpro as default branch in github repo settings
After completing either Path A or Path B, continue with the following steps:
-
configure github secrets (PAT)
Create a Personal Access Token (PAT) and add it as a repository secret so the
xpInitworkflow can access what it needs.NOTE: make sure GitHub Actions are enabled for your fork, and that you have permission to add repository secrets.
Follow the instructions here: https://github.com/externpro/externpro/blob/main/.github/docs/secrets-and-tokens.md
-
preconditions before running
xpInitBy following the previous steps (regardless of whether you used Path A or Path B), the preconditions should already be met (externpro is vendored as the
.devcontainersubmodule, and you have anxprobranch plus thexpInitworkflow). This link is included for completeness and to tie back to the authoritative documentation. -
run xpInit workflow
-
an
xpInitpull request should be automatically opened, which also launches a build on all platforms -
add the optional
release:taglabel to thexpInitpull request to launch workflows that tag, build, and create a draft release once the pull request is mergedUse
release:tagwhen you're ready to publish a versioned xpro package for downstream consumption.If you followed Path A, strongly consider:
- not adding the
release:taglabel - merging the PR
- running the
xpUpdateworkflow
- not adding the
-
merge the pull request to proceed (if you've added the label, you can watch the workflows proceed on the Actions tab and then publish the draft release on the Releases tab)
-
if you followed Path A, run the
xpUpdateworkflow to update the externpro submodule to point at the HEAD of themainbranch of externproRunning
xpUpdatewill also automatically open a pull request. Adding therelease:taglabel to that pull request would then launch thexpTag->xpBuild->xpReleaserelease flow when the pull is merged.
xpBuildruns on PRs targetingxpro(and on tag pushes, depending on template)- adding the
release:taglabel (then merging) triggersxpTag, which creates anxpv*tag - tag push triggers the tagged build; a successful tagged build triggers
xpReleaseto draft a GitHub Release
Release flow details: https://github.com/externpro/externpro/blob/main/.github/docs/release-flow.md
An xpro package is a release artifact plus its manifest metadata and generated CMake “use config”, so downstream repos can consume it via find_package().
set(xp_tutorial
REPO github.com/<username-or-org>/tutorial
TAG xpv1.0.1 # or <tag-from-release-notes>
MANIFEST_SHA256 <SHA256-from-release-notes>
)
find_package(tutorial)



