Skip to main content

Packaging GitHub repos example: libogg

Create the manifest file

The manifest file (called kmpkg.json) is a json file describing the package's metadata.

For libogg, we'll create the file ports/libogg/kmpkg.json with the following content:

{
"name": "libogg",
"version-string": "1.3.3",
"description": "Ogg is a multimedia container format, and the native file and stream format for the Xiph.org multimedia codecs.",
"homepage": "https://www.xiph.org/ogg/"
}

You can format the manifest file to our specifications with kmpkg format-manifest ports/libogg/kmpkg.json.

Create the portfile

portfile.cmake describes how to build and install the package. First we download the project from Github with kmpkg_from_github:

kmpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO xiph/ogg
REF v1.3.3
SHA512 0bd6095d647530d4cb1f509eb5e99965a25cc3dd9b8125b93abd6b248255c890cf20710154bdec40568478eb5c4cde724abfb2eff1f3a04e63acef0fbbc9799b
HEAD_REF master
)

The important parts to update are REPO for the GitHub repository path, REF for a stable tag/commit to use, and SHA512 with the checksum of the downloaded file (you can get this easily by setting it to 0, trying to install the package, and copying the checksum).

Finally, we configure the project with CMake, install the package, and copy over the license file:

kmpkg_cmake_configure(SOURCE_PATH ${SOURCE_PATH})
kmpkg_cmake_install()
kmpkg_install_copyright("${SOURCE_PATH}/COPYING")

Check the documentation for kmpkg_cmake_configure and kmpkg_cmake_install if your package needs additional options.

Now you can run kmpkg install libogg to build and install the package.

Suggested example portfiles

In the ports/ directory are many libraries that can be used as examples, including many that are not based on CMake.

  • Header only libraries
    • rapidjson
    • range-v3
  • MSBuild-based
    • chakracore
  • Non-CMake, custom buildsystem
    • openssl
    • ffmpeg