Browse Source

[cmake] Update CPMUtil

Notable changes

- Single cpmfile
- version/min_version/git_version have been fixed and replaced with
  version and min_version
- Docs rewrite
- Legacy options are gone
- Fixed update/version commands

Interactive adder is nonfunctional right now, will rewrite later

Signed-off-by: crueter <crueter@eden-emu.dev>
update-cpmutil
crueter 1 day ago
parent
commit
94e655b4e4
No known key found for this signature in database GPG Key ID: 425ACD2D4830EBC6
  1. 286
      CMakeModules/CPMUtil.cmake
  2. 453
      cpmfile.json
  3. 332
      docs/CPMUtil.md
  4. 21
      docs/CPMUtil/AddCIPackage.md
  5. 41
      docs/CPMUtil/AddDependentPackage.md
  6. 105
      docs/CPMUtil/AddJsonPackage.md
  7. 118
      docs/CPMUtil/AddPackage.md
  8. 28
      docs/CPMUtil/AddQt.md
  9. 70
      docs/CPMUtil/README.md
  10. 3
      externals/CMakeLists.txt
  11. 249
      externals/cpmfile.json
  12. 21
      tools/cpm/common.sh
  13. 10
      tools/cpm/format.sh
  14. 2
      tools/cpm/migrate.sh
  15. 2
      tools/cpm/package.sh
  16. 1
      tools/cpm/package/fetch.sh
  17. 10
      tools/cpm/package/rm.sh
  18. 46
      tools/cpm/package/update.sh
  19. 7
      tools/cpm/package/util/fix-hash.sh
  20. 3
      tools/cpm/package/util/interactive.sh
  21. 10
      tools/cpm/package/util/replace.sh
  22. 19
      tools/cpm/package/util/url.sh
  23. 76
      tools/cpm/package/vars.sh
  24. 21
      tools/cpm/package/vars/key.sh
  25. 34
      tools/cpm/package/version.sh
  26. 8
      tools/cpm/package/which.sh
  27. 9
      tools/cpmutil.sh

286
CMakeModules/CPMUtil.cmake

@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: Copyright 2026 crueter
# SPDX-License-Identifier: LGPL-3.0-or-later
set(CPM_SOURCE_CACHE "${PROJECT_SOURCE_DIR}/.cache/cpm" CACHE STRING "" FORCE)
cmake_minimum_required(VERSION 3.31)
if(MSVC OR ANDROID OR IOS)
set(BUNDLED_DEFAULT ON)
@ -9,15 +9,40 @@ else()
set(BUNDLED_DEFAULT OFF)
endif()
set(CPM_SOURCE_CACHE "${PROJECT_SOURCE_DIR}/.cache/cpm" CACHE STRING "" FORCE)
option(CPMUTIL_FORCE_BUNDLED
"Force bundled packages for all CPM depdendencies" ${BUNDLED_DEFAULT})
option(CPMUTIL_FORCE_SYSTEM
"Force system packages for all CPM dependencies (NOT RECOMMENDED)" OFF)
"Force system packages for all CPM dependencies" OFF)
set(CPMUTIL_PATCH_DIR "${PROJECT_SOURCE_DIR}/.patch" CACHE STRING
"Directory containing patches for packages")
cmake_minimum_required(VERSION 3.22)
include(CPM)
# Rudimentary target architecture detection
if (NOT DEFINED ARCHITECTURE)
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} processor)
if (processor MATCHES "x86|amd64")
set(CPMUTIL_AMD64 ON)
elseif(processor MATCHES "^aarch64|^arm64|^armv8\.*")
set(CPMUTIL_ARM64 ON)
elseif(processor MATCHES "riscv")
set(CPMUTIL_RISCV64 ON)
endif()
else()
# This block exists for compatibility with my own DetectArchitecture.cmake.
if (ARCHITECTURE_x86_64)
set(CPMUTIL_AMD64 ON)
elseif(ARCHITECTURE_arm64)
set(CPMUTIL_ARM64 ON)
elseif(ARCHITECTURE_riscv64)
set(CPMUTIL_RISCV64 ON)
endif()
endif()
# cpmfile parsing
set(CPMUTIL_JSON_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cpmfile.json")
@ -70,7 +95,6 @@ function(get_json_element object out member default)
if(out_type STREQUAL "ARRAY")
string(JSON _len LENGTH "${object}" ${member})
# array_to_list("${outvar}" ${_len} outvar)
set("${out}_LENGTH" "${_len}" PARENT_SCOPE)
endif()
@ -148,11 +172,12 @@ macro(parse_object object)
get_json_element("${object}" repo repo "")
get_json_element("${object}" ci ci OFF)
get_json_element("${object}" version version "")
get_json_element("${object}" min_version min_version "")
get_json_element("${object}" git_host git_host "github.com")
if(ci)
get_json_element("${object}" name name "${JSON_NAME}")
get_json_element("${object}" extension extension "tar.zst")
get_json_element("${object}" min_version min_version "")
get_json_element("${object}" raw_disabled disabled_platforms "")
if(raw_disabled)
@ -163,14 +188,10 @@ macro(parse_object object)
endif()
else()
get_json_element("${object}" hash hash "")
get_json_element("${object}" hash_suffix hash_suffix "")
get_json_element("${object}" sha sha "")
get_json_element("${object}" url url "")
get_json_element("${object}" key key "")
get_json_element("${object}" tag tag "")
get_json_element("${object}" artifact artifact "")
get_json_element("${object}" git_version git_version "")
get_json_element("${object}" git_host git_host "")
get_json_element("${object}" source_subdir source_subdir "")
get_json_element("${object}" bundled bundled "unset")
get_json_element("${object}" find_args find_args "")
@ -178,23 +199,17 @@ macro(parse_object object)
# okay here comes the fun part: REPLACEMENTS!
# first: tag gets %VERSION% replaced if applicable,
# with either git_version (preferred) or version
# with version
# second: artifact gets %VERSION% and %TAG% replaced
# accordingly (same rules for VERSION)
if(git_version)
set(version_replace ${git_version})
else()
set(version_replace ${version})
endif()
# TODO(crueter): fmt module for cmake
if(tag)
string(REPLACE "%VERSION%" "${version_replace}" tag ${tag})
string(REPLACE "%VERSION%" "${version}" tag ${tag})
endif()
if(artifact)
string(REPLACE "%VERSION%" "${version_replace}"
string(REPLACE "%VERSION%" "${version}"
artifact ${artifact})
string(REPLACE "%TAG%" "${tag}" artifact ${artifact})
endif()
@ -207,7 +222,7 @@ macro(parse_object object)
string(JSON _patch GET "${raw_patches}" "${IDX}")
set(full_patch
"${PROJECT_SOURCE_DIR}/.patch/${JSON_NAME}/${_patch}")
"${CPMUTIL_PATCH_DIR}/${JSON_NAME}/${_patch}")
if(NOT EXISTS ${full_patch})
cpm_utils_message(FATAL_ERROR ${JSON_NAME}
"specifies patch ${full_patch} which does not exist")
@ -242,14 +257,16 @@ function(AddJsonPackage)
# these are overrides that can be generated at runtime,
# so can be defined separately from the json
BUNDLED_PACKAGE
FORCE_BUNDLED_PACKAGE)
set(multiValueArgs OPTIONS)
set(optionArgs MODULE_PATH DOWNLOAD_ONLY)
cmake_parse_arguments(JSON "${optionArgs}" "${oneValueArgs}" "${multiValueArgs}"
cmake_parse_arguments(JSON
"${optionArgs}"
"${oneValueArgs}"
"${multiValueArgs}"
"${ARGN}")
list(LENGTH ARGN argnLength)
@ -260,8 +277,8 @@ function(AddJsonPackage)
endif()
if(NOT DEFINED CPMFILE_CONTENT)
cpm_utils_message(WARNING ${name}
"No cpmfile, AddJsonPackage is a no-op")
cpm_utils_message(FATAL_ERROR ${name}
"No cpmfile present")
return()
endif()
@ -304,12 +321,11 @@ function(AddJsonPackage)
AddPackage(
NAME "${package}"
VERSION "${version}"
MIN_VERSION "${min_version}"
URL "${url}"
HASH "${hash}"
HASH_SUFFIX "${hash_suffix}"
SHA "${sha}"
REPO "${repo}"
KEY "${key}"
PATCHES "${patches}"
OPTIONS "${options}"
FIND_PACKAGE_ARGUMENTS "${find_args}"
@ -317,7 +333,6 @@ function(AddJsonPackage)
FORCE_BUNDLED_PACKAGE "${JSON_FORCE_BUNDLED_PACKAGE}"
SOURCE_SUBDIR "${source_subdir}"
GIT_VERSION "${git_version}"
GIT_HOST "${git_host}"
ARTIFACT "${artifact}"
@ -339,25 +354,19 @@ function(AddPackage)
set(oneValueArgs
NAME
VERSION
GIT_VERSION
MIN_VERSION
GIT_HOST
REPO
TAG
ARTIFACT
SHA
BRANCH
HASH
HASH_SUFFIX
HASH_URL
HASH_ALGO
URL
GIT_URL
SOURCE_SUBDIR
KEY
SOURCE_SUBDIR
BUNDLED_PACKAGE
FORCE_BUNDLED_PACKAGE
FIND_PACKAGE_ARGUMENTS)
@ -366,7 +375,10 @@ function(AddPackage)
set(optionArgs MODULE_PATH DOWNLOAD_ONLY)
cmake_parse_arguments(PKG_ARGS "${optionArgs}" "${oneValueArgs}" "${multiValueArgs}"
cmake_parse_arguments(PKG_ARGS
"${optionArgs}"
"${oneValueArgs}"
"${multiValueArgs}"
"${ARGN}")
if(NOT DEFINED PKG_ARGS_NAME)
@ -385,6 +397,7 @@ function(AddPackage)
set(CPM_${PKG_ARGS_NAME}_SOURCE ${${PKG_ARGS_NAME}_CUSTOM_DIR})
endif()
# TODO: See if this can be delegated to subshells
if(NOT DEFINED PKG_ARGS_GIT_HOST)
set(git_host github.com)
else()
@ -393,42 +406,22 @@ function(AddPackage)
if(DEFINED PKG_ARGS_URL)
set(pkg_url ${PKG_ARGS_URL})
if(DEFINED PKG_ARGS_REPO)
set(pkg_git_url https://${git_host}/${PKG_ARGS_REPO})
else()
if(DEFINED PKG_ARGS_GIT_URL)
set(pkg_git_url ${PKG_ARGS_GIT_URL})
else()
set(pkg_git_url ${pkg_url})
endif()
endif()
set(pkg_git_url ${pkg_url})
elseif(DEFINED PKG_ARGS_REPO)
set(pkg_git_url https://${git_host}/${PKG_ARGS_REPO})
if(DEFINED PKG_ARGS_TAG)
set(pkg_key ${PKG_ARGS_TAG})
if(DEFINED PKG_ARGS_SHA)
set(pkg_url "${pkg_git_url}/archive/${PKG_ARGS_SHA}.tar.gz")
elseif(DEFINED PKG_ARGS_TAG)
set(tag "${PKG_ARGS_TAG}")
if(DEFINED PKG_ARGS_ARTIFACT)
set(artifact "${PKG_ARGS_ARTIFACT}")
set(pkg_url
"${pkg_git_url}/releases/download/${PKG_ARGS_TAG}/${PKG_ARGS_ARTIFACT}")
"${pkg_git_url}/releases/download/${tag}/${artifact}")
else()
set(pkg_url
${pkg_git_url}/archive/refs/tags/${PKG_ARGS_TAG}.tar.gz)
endif()
elseif(DEFINED PKG_ARGS_SHA)
set(pkg_url "${pkg_git_url}/archive/${PKG_ARGS_SHA}.tar.gz")
else()
if(DEFINED PKG_ARGS_BRANCH)
set(PKG_BRANCH ${PKG_ARGS_BRANCH})
else()
cpm_utils_message(WARNING ${PKG_ARGS_NAME}
"REPO defined but no TAG, SHA, BRANCH, or URL"
"specified, defaulting to master")
set(PKG_BRANCH master)
"${pkg_git_url}/archive/refs/tags/${tag}.tar.gz")
endif()
set(pkg_url ${pkg_git_url}/archive/refs/heads/${PKG_BRANCH}.tar.gz)
endif()
else()
cpm_utils_message(FATAL_ERROR ${PKG_ARGS_NAME}
@ -437,75 +430,24 @@ function(AddPackage)
cpm_utils_message(DEBUG ${PKG_ARGS_NAME} "Download URL is ${pkg_url}")
if(NOT DEFINED PKG_ARGS_KEY)
if(DEFINED PKG_ARGS_SHA)
string(SUBSTRING ${PKG_ARGS_SHA} 0 4 pkg_key)
cpm_utils_message(DEBUG ${PKG_ARGS_NAME}
"No custom key defined, using ${pkg_key} from sha")
elseif(DEFINED PKG_ARGS_GIT_VERSION)
set(pkg_key ${PKG_ARGS_GIT_VERSION})
cpm_utils_message(DEBUG ${PKG_ARGS_NAME}
"No custom key defined, using ${pkg_key}")
elseif(DEFINED PKG_ARGS_TAG)
set(pkg_key ${PKG_ARGS_TAG})
cpm_utils_message(DEBUG ${PKG_ARGS_NAME}
"No custom key defined, using ${pkg_key}")
elseif(DEFINED PKG_ARGS_VERSION)
set(pkg_key ${PKG_ARGS_VERSION})
cpm_utils_message(DEBUG ${PKG_ARGS_NAME}
"No custom key defined, using ${pkg_key}")
else()
cpm_utils_message(WARNING ${PKG_ARGS_NAME}
"Could not determine cache key, using CPM defaults")
endif()
else()
set(pkg_key ${PKG_ARGS_KEY})
endif()
if(DEFINED PKG_ARGS_HASH_ALGO)
set(hash_algo ${PKG_ARGS_HASH_ALGO})
if(DEFINED PKG_ARGS_SHA)
string(SUBSTRING ${PKG_ARGS_SHA} 0 4 pkg_key)
elseif(DEFINED PKG_ARGS_VERSION)
set(pkg_key ${PKG_ARGS_VERSION})
elseif(DEFINED PKG_ARGS_TAG)
set(pkg_key ${PKG_ARGS_TAG})
elseif(DEFINED PKG_ARGS_MIN_VERSION)
set(pkg_key ${PKG_ARGS_MIN_VERSION})
else()
set(hash_algo SHA512)
cpm_utils_message(FATAL_ERROR ${PKG_ARGS_NAME}
"Could not determine cache key")
endif()
if(DEFINED PKG_ARGS_HASH)
set(pkg_hash "${hash_algo}=${PKG_ARGS_HASH}")
elseif(DEFINED PKG_ARGS_HASH_SUFFIX)
# funny sanity check
string(TOLOWER ${hash_algo} hash_algo_lower)
string(TOLOWER ${PKG_ARGS_HASH_SUFFIX} suffix_lower)
if(NOT ${suffix_lower} MATCHES ${hash_algo_lower})
cpm_utils_message(WARNING
"Hash algorithm and hash suffix do not match, errors may occur")
endif()
set(hash_url ${pkg_url}.${PKG_ARGS_HASH_SUFFIX})
elseif(DEFINED PKG_ARGS_HASH_URL)
set(hash_url ${PKG_ARGS_HASH_URL})
set(pkg_hash "SHA512=${PKG_ARGS_HASH}")
else()
cpm_utils_message(WARNING ${PKG_ARGS_NAME}
"No hash or hash URL found")
endif()
if(DEFINED hash_url)
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/${PKG_ARGS_NAME}.hash)
# TODO(crueter): This is kind of a bad solution
# because "technically" the hash is invalidated each week
# but it works for now kjsdnfkjdnfjksdn
string(TOLOWER ${PKG_ARGS_NAME} lowername)
if(NOT EXISTS ${outfile} AND NOT EXISTS
${CPM_SOURCE_CACHE}/${lowername}/${pkg_key})
file(DOWNLOAD ${hash_url} ${outfile})
endif()
if(EXISTS ${outfile})
file(READ ${outfile} pkg_hash_tmp)
endif()
if(DEFINED ${pkg_hash_tmp})
set(pkg_hash "${hash_algo}=${pkg_hash_tmp}")
endif()
cpm_utils_message(FATAL_ERROR ${PKG_ARGS_NAME}
"No hash defined")
endif()
macro(set_precedence local force)
@ -575,10 +517,10 @@ function(AddPackage)
endif()
CPMAddPackage(
NAME "${PKG_ARGS_NAME}"
URL "${pkg_url}"
URL_HASH "${pkg_hash}"
CUSTOM_CACHE_KEY "${pkg_key}"
NAME ${PKG_ARGS_NAME}
URL ${pkg_url}
URL_HASH ${pkg_hash}
CUSTOM_CACHE_KEY ${pkg_key}
EXCLUDE_FROM_ALL ON
@ -593,15 +535,15 @@ function(AddPackage)
if(DEFINED PKG_ARGS_SHA)
set_property(GLOBAL APPEND PROPERTY CPM_PACKAGE_SHAS
${PKG_ARGS_SHA})
elseif(DEFINED PKG_ARGS_GIT_VERSION)
elseif(DEFINED PKG_ARGS_VERSION)
set_property(GLOBAL APPEND PROPERTY CPM_PACKAGE_SHAS
${PKG_ARGS_GIT_VERSION})
${PKG_ARGS_VERSION})
elseif(DEFINED PKG_ARGS_TAG)
set_property(GLOBAL APPEND PROPERTY CPM_PACKAGE_SHAS
${PKG_ARGS_TAG})
elseif(DEFINED PKG_ARGS_VERSION)
elseif(DEFINED PKG_ARGS_MIN_VERSION)
set_property(GLOBAL APPEND PROPERTY CPM_PACKAGE_SHAS
${PKG_ARGS_VERSION})
${PKG_ARGS_MIN_VERSION})
else()
cpm_utils_message(WARNING ${PKG_ARGS_NAME}
"Package has no specified sha, tag, or version")
@ -650,6 +592,7 @@ function(AddCIPackage)
"${multiValueArgs}"
${ARGN})
# TODO: use cpm_utils_message
if(NOT DEFINED PKG_ARGS_VERSION)
message(FATAL_ERROR "[CPMUtil] VERSION is required")
endif()
@ -689,45 +632,59 @@ function(AddCIPackage)
set(ARTIFACT_REPO ${PKG_ARGS_REPO})
set(ARTIFACT_PACKAGE ${PKG_ARGS_PACKAGE})
if(MSVC AND ARCHITECTURE_x86_64)
set(pkgname windows-amd64)
elseif(MSVC AND ARCHITECTURE_arm64)
set(pkgname windows-arm64)
elseif(MINGW AND ARCHITECTURE_x86_64)
set(pkgname mingw-amd64)
elseif(MINGW AND ARCHITECTURE_arm64)
set(pkgname mingw-arm64)
elseif(ANDROID AND ARCHITECTURE_x86_64)
set(pkgname android-x86_64)
elseif(ANDROID AND ARCHITECTURE_arm64)
set(pkgname android-aarch64)
elseif(PLATFORM_SUN)
set(pkgname solaris-amd64)
elseif(PLATFORM_FREEBSD)
set(pkgname freebsd-amd64)
elseif(PLATFORM_LINUX AND ARCHITECTURE_x86_64)
set(pkgname linux-amd64)
elseif(PLATFORM_LINUX AND ARCHITECTURE_arm64)
set(pkgname linux-aarch64)
elseif(APPLE AND NOT IOS)
set(pkgname macos-universal)
elseif(IOS AND ARCHITECTURE_arm64)
set(pkgname ios-aarch64)
endif()
if (DEFINED pkgname AND NOT "${pkgname}" IN_LIST DISABLED_PLATFORMS)
# TODO: Use amd64/aarch64 naming for everything.
# Also drop macos universal
if (MSVC)
set(platname windows)
elseif(MINGW)
set(platname mingw)
elseif(ANDROID)
set(platname android)
elseif(LINUX)
set(platname linux)
elseif(IOS)
set(platname ios)
elseif(APPLE)
set(platname macos)
else()
cpm_utils_message(WARNING ${PKG_ARGS_NAME}
"Unsupported platform ${CMAKE_SYSTEM_NAME} for CI packages")
endif()
if (APPLE AND NOT IOS)
set(archname universal)
elseif((WIN32 OR LINUX) AND CPMUTIL_AMD64)
set(archname amd64)
elseif(WIN32 and CPMUTIL_ARM64)
set(archname arm64)
elseif((IOS OR LINUX OR ANDROID) AND CPMUTIL_ARM64)
set(archname aarch64)
elseif(ANDROID AND CPMUTIL_AMD64)
set(archname x86_64)
else()
cpm_utils_message(WARNING ${PKG_ARGS_NAME}
"Unsupported platform/arch combo for CI packages")
endif()
if (DEFINED platname AND DEFINED archname)
set(pkgname ${platname}-${archname})
endif()
if (DEFINED pkgname
AND NOT "${pkgname}" IN_LIST DISABLED_PLATFORMS)
set(ARTIFACT
"${ARTIFACT_NAME}-${pkgname}-${ARTIFACT_VERSION}.${ARTIFACT_EXT}")
if (PKG_ARGS_MODULE_PATH)
list(APPEND EXTRA_ARGS MODULE_PATH)
set(EXTRA_ARGS MODULE_PATH)
endif()
AddPackage(
NAME ${ARTIFACT_PACKAGE}
REPO ${ARTIFACT_REPO}
TAG "v${ARTIFACT_VERSION}"
GIT_VERSION ${ARTIFACT_VERSION}
MIN_VERSION ${ARTIFACT_VERSION}
ARTIFACT ${ARTIFACT}
KEY "${pkgname}-${ARTIFACT_VERSION}"
@ -761,7 +718,6 @@ function(AddQt repo version)
REPO ${repo}
DISABLED_PLATFORMS
android-x86_64 android-aarch64
freebsd-amd64 solaris-amd64 openbsd-amd64
MODULE_PATH)
find_package(Qt6 REQUIRED PATHS ${Qt6_SOURCE_DIR} NO_DEFAULT_PATH)

453
cpmfile.json

@ -1,147 +1,404 @@
{
"openssl-ci": {
"biscuit": {
"hash": "1229f345b014f7ca544dedb4edb3311e41ba736f9aa9a67f88b5f26f3c983288c6bb6cdedcfb0b8a02c63088a37e6a0d7ba97d9c2a4d721b213916327cffe28a",
"min_version": "0.9.1",
"repo": "lioncash/biscuit",
"tag": "v%VERSION%",
"version": "0.19.0"
},
"boost": {
"artifact": "%TAG%-cmake.tar.xz",
"find_args": "CONFIG OPTIONAL_COMPONENTS headers context system fiber filesystem",
"hash": "6ae6e94664fe7f2fb01976b59b276ac5df8085c7503fa829d810fbfe495960cfec44fa2c36e2cb23480bc19c956ed199d4952b02639a00a6c07625d4e7130c2d",
"min_version": "1.57",
"package": "Boost",
"patches": [
"0001-clang-cl.patch"
],
"repo": "boostorg/boost",
"tag": "boost-%VERSION%",
"version": "1.90.0"
},
"boost_headers": {
"bundled": true,
"hash": "8a07d7a6f0065587d3005a83481a794704ae22e773b9f336fbd89ed230aaa7b4c86c03edcbae30bba8b3e20839c3131eaa2dceac037ef811533ef4eadc53b15b",
"repo": "boostorg/headers",
"tag": "boost-%VERSION%",
"version": "1.90.0"
},
"catch2": {
"hash": "7eea385d79d88a5690cde131fe7ccda97d5c54ea09d6f515000d7bf07c828809d61c1ac99912c1ee507cf933f61c1c47ecdcc45df7850ffa82714034b0fccf35",
"min_version": "3.0.1",
"package": "Catch2",
"patches": [
"0001-solaris-isnan-fix.patch"
],
"repo": "catchorg/Catch2",
"tag": "v%VERSION%",
"version": "3.13.0"
},
"cpp-jwt": {
"find_args": "CONFIG",
"hash": "d11cbd5ddb3197b4c5ca15679bcd76a49963e7b530b7dd132db91e042925efa20dfb2c24ccfbe7ef82a7012af80deff0f72ee25851312ae80381a462df8534b8",
"min_version": "1.4",
"options": [
"CPP_JWT_USE_VENDORED_NLOHMANN_JSON OFF"
],
"patches": [
"0001-fix-missing-decl.patch"
],
"repo": "arun11299/cpp-jwt",
"sha": "7f24eb4c32",
"version": "1.5.1"
},
"cubeb": {
"find_args": "CONFIG",
"hash": "8a4bcb2f83ba590f52c66626e895304a73eb61928dbc57777e1822e55378e3568366f17f9da4b80036cc2ef4ea9723c32abf6e7d9bbe00fb03654f0991596ab0",
"options": [
"USE_SANITIZERS OFF",
"BUILD_TESTS OFF",
"BUILD_TOOLS OFF",
"BUNDLE_SPEEX ON"
],
"repo": "mozilla/cubeb",
"sha": "fa02160712",
"version": "0.0.0"
},
"discord-rpc": {
"find_args": "MODULE",
"hash": "8213c43dcb0f7d479f5861091d111ed12fbdec1e62e6d729d65a4bc181d82f48a35d5fd3cd5c291f2393ac7c9681eabc6b76609755f55376284c8a8d67e148f3",
"package": "DiscordRPC",
"repo": "eden-emulator/discord-rpc",
"sha": "0d8b2d6a37",
"version": "3.4.1"
},
"enet": {
"find_args": "MODULE",
"hash": "a0d2fa8c957704dd49e00a726284ac5ca034b50b00d2b20a94fa1bbfbb80841467834bfdc84aa0ed0d6aab894608fd6c86c3b94eee46343f0e6d9c22e391dbf9",
"min_version": "1.3",
"repo": "lsalzman/enet",
"tag": "v%VERSION%",
"version": "1.3.18"
},
"ffmpeg": {
"bundled": true,
"hash": "ed177621176b3961bdcaa339187d3a7688c1c8b060b79c4bb0257cbc67ad7021ae5d5adca5303b45625abbbe3d9aafdd87ce777b8690ac295290d744c875489a",
"repo": "FFmpeg/FFmpeg",
"sha": "c7b5f1537d",
"version": "8.0.1"
},
"ffmpeg-ci": {
"ci": true,
"package": "OpenSSL",
"name": "openssl",
"repo": "crueter-ci/OpenSSL",
"version": "4.0.0-11b7b6ea3b",
"min_version": "3"
"min_version": "4.1",
"name": "ffmpeg",
"package": "FFmpeg",
"repo": "crueter-ci/FFmpeg",
"version": "8.0.1-c7b5f1537d"
},
"openssl-cmake": {
"repo": "jimmy-park/openssl-cmake",
"hash": "2cc185c924fd70e7d886257ca0caa42b3b8f7f712f2052b4f94dde74759e27022de76178460e18c9bdfc57c366583999e198fbb6052d4e7d91c099d15a0ca63e",
"git_version": "3.6.2",
"fmt": {
"hash": "f0da82c545b01692e9fd30fdfb613dbb8dd9716983dcd0ff19ac2a8d36f74beb5540ef38072fdecc1e34191b3682a8542ecbf3a61ef287dbba0a2679d4e023f2",
"min_version": "8",
"repo": "fmtlib/fmt",
"tag": "%VERSION%",
"bundled": true,
"version": "12.1.0"
},
"frozen": {
"hash": "b8dfe741c82bc178dfc9749d4ab5a130cee718d9ee7b71d9b547cf5f7f23027ed0152ad250012a8546399fcc1e12187efc68d89d6731256c4d2df7d04eef8d5c",
"package": "frozen",
"repo": "serge-sans-paille/frozen",
"sha": "61dce5ae18",
"version": "1.2.0"
},
"gamemode": {
"find_args": "MODULE",
"hash": "e87ec14ed3e826d578ebf095c41580069dda603792ba91efa84f45f4571a28f4d91889675055fd6f042d7dc25b0b9443daf70963ae463e38b11bcba95f4c65a9",
"min_version": "1.7",
"repo": "FeralInteractive/gamemode",
"sha": "ce6fe122f3",
"version": "1.8.2"
},
"httplib": {
"find_args": "MODULE GLOBAL",
"hash": "159ed94965018f2a371d45a3bfc1961e5fb1549e501ded70a6b4532d7fe99d0579c18b5195aff6e35f96f399b426cea2650ec9fb75ef80d4c9edeccb51f2e6c9",
"options": [
"OPENSSL_CONFIGURE_OPTIONS threads"
"HTTPLIB_REQUIRE_OPENSSL ON",
"HTTPLIB_DISABLE_MACOSX_AUTOMATIC_ROOT_CERTIFICATES ON"
],
"patches": [
"0001-cpmutil-compat.patch",
"0002-use-ccache.patch",
"0003-use-cmake-compiler-flags.patch",
"0004-use-shell-wrapper.patch"
]
"0001-mingw.patch"
],
"repo": "yhirose/cpp-httplib",
"tag": "v%VERSION%",
"version": "0.46.0"
},
"openssl": {
"repo": "openssl/openssl",
"package": "OpenSSL",
"min_version": "3",
"version": "3",
"hash": "29002ce50cb95a4f4f1d0e9d3f684401fbd4eac34203dc2eef3b6334af5d44aa46bf788b63a6f5c139c383eafb7269ae87a58a9a3ad5912903b9773e545ccc0a",
"git_version": "3.6.2",
"tag": "openssl-%VERSION%",
"lagoon": {
"hash": "b9380f99c6effaeccc6d8f81d4942e852c11ad28613df637e155451556ae5826f93765bee57a5c87a9740d2bd1db463ad0f55a947772fe9d57eeabae3efa373e",
"repo": "loongson-community/lagoon",
"tag": "%VERSION%",
"version": "1.0.0"
},
"libadrenotools": {
"hash": "f6526620cb752876edc5ed4c0925d57b873a8218ee09ad10859ee476e9333259784f61c1dcc55a2bcba597352d18aff22cd2e4c1925ec2ae94074e09d7da2265",
"patches": [
"0001-add-bundled-cert.patch"
]
"0001-linkerns-cpm.patch"
],
"repo": "eden-emulator/libadrenotools",
"sha": "8ba23b42d7",
"version": "1.0.0"
},
"boost": {
"package": "Boost",
"repo": "boostorg/boost",
"tag": "boost-%VERSION%",
"artifact": "%TAG%-cmake.tar.xz",
"hash": "6ae6e94664fe7f2fb01976b59b276ac5df8085c7503fa829d810fbfe495960cfec44fa2c36e2cb23480bc19c956ed199d4952b02639a00a6c07625d4e7130c2d",
"git_version": "1.90.0",
"version": "1.57",
"find_args": "CONFIG OPTIONAL_COMPONENTS headers context system fiber filesystem",
"libusb": {
"find_args": "MODULE",
"hash": "98c5f7940ff06b25c9aa65aa98e23de4c79a4c1067595f4c73cc145af23a1c286639e1ba11185cd91bab702081f307b973f08a4c9746576dc8d01b3620a3aeb5",
"patches": [
"0001-clang-cl.patch"
]
"0001-netbsd-gettime.patch"
],
"repo": "libusb/libusb",
"tag": "v%VERSION%",
"version": "1.0.29"
},
"fmt": {
"repo": "fmtlib/fmt",
"llvm-mingw": {
"artifact": "clang-rt-builtins.tar.zst",
"git_host": "git.eden-emu.dev",
"hash": "d902392caf94e84f223766e2cc51ca5fab6cae36ab8dc6ef9ef6a683ab1c483bfcfe291ef0bd38ab16a4ecc4078344fa8af72da2f225ab4c378dee23f6186181",
"repo": "eden-emu/llvm-mingw",
"tag": "%VERSION%",
"hash": "f0da82c545b01692e9fd30fdfb613dbb8dd9716983dcd0ff19ac2a8d36f74beb5540ef38072fdecc1e34191b3682a8542ecbf3a61ef287dbba0a2679d4e023f2",
"version": "8",
"git_version": "12.1.0"
"version": "20250828"
},
"lz4": {
"hash": "35c21a5d9cfb5bbf314a5321d02b36819491d2ee3cf8007030ca09d13ca4dae672247b7aeab553e973093604fc48221cb03dc92197c6efe8fc3746891363fdab",
"name": "lz4",
"repo": "lz4/lz4",
"sha": "ebb370ca83",
"hash": "35c21a5d9cfb5bbf314a5321d02b36819491d2ee3cf8007030ca09d13ca4dae672247b7aeab553e973093604fc48221cb03dc92197c6efe8fc3746891363fdab",
"source_subdir": "build/cmake"
"source_subdir": "build/cmake",
"version": "1.10.0"
},
"moltenvk": {
"artifact": "MoltenVK-macOS.tar",
"bundled": true,
"hash": "5695b36ca5775819a71791557fcb40a4a5ee4495be6b8442e0b666d0c436bec02aae68cc6210183f7a5c986bdbec0e117aecfad5396e496e9c2fd5c89133a347",
"repo": "V380-Ori/Ryujinx.MoltenVK",
"tag": "v%VERSION%-ryujinx",
"version": "1.4.1"
},
"nlohmann": {
"hash": "6cc1e86261f8fac21cc17a33da3b6b3c3cd5c116755651642af3c9e99bb3538fd42c1bd50397a77c8fb6821bc62d90e6b91bcdde77a78f58f2416c62fc53b97d",
"min_version": "3.8",
"package": "nlohmann_json",
"repo": "nlohmann/json",
"tag": "v%VERSION%",
"hash": "6cc1e86261f8fac21cc17a33da3b6b3c3cd5c116755651642af3c9e99bb3538fd42c1bd50397a77c8fb6821bc62d90e6b91bcdde77a78f58f2416c62fc53b97d",
"version": "3.8",
"git_version": "3.12.0"
"version": "3.12.0"
},
"zlib": {
"package": "ZLIB",
"repo": "madler/zlib",
"oaknut": {
"hash": "9697e80a7d5d9bcb3ce51051a9a24962fb90ca79d215f1f03ae6b58da8ba13a63b5dda1b4dde3d26ac6445029696b8ef2883f4e5a777b342bba01283ed293856",
"min_version": "2.0.1",
"repo": "eden-emulator/oaknut",
"tag": "v%VERSION%",
"hash": "16fea4df307a68cf0035858abe2fd550250618a97590e202037acd18a666f57afc10f8836cbbd472d54a0e76539d0e558cb26f059d53de52ff90634bbf4f47d4",
"version": "1.2",
"git_version": "1.3.2",
"options": [
"ZLIB_BUILD_SHARED OFF",
"ZLIB_INSTALL OFF"
]
"version": "2.0.3"
},
"zstd": {
"repo": "facebook/zstd",
"sha": "b8d6101fba",
"hash": "cc5ad4b119a9c2ea57f0b71eeff01113bb506e0d17000159c5409cb8236d22e38c52d5e9e97e7947a4bf1b2dfc44b6c503ab2d9aedbd59458435c6a2849cb029",
"version": "1.5",
"source_subdir": "build/cmake",
"find_args": "MODULE",
"oboe": {
"bundled": true,
"hash": "ce4011afe7345370d4ead3b891cd69a5ef224b129535783586c0ca75051d303ed446e6c7f10bde8da31fff58d6e307f1732a3ffd03b249f9ef1fd48fd4132715",
"repo": "google/oboe",
"tag": "%VERSION%",
"version": "1.10.0"
},
"openssl": {
"hash": "29002ce50cb95a4f4f1d0e9d3f684401fbd4eac34203dc2eef3b6334af5d44aa46bf788b63a6f5c139c383eafb7269ae87a58a9a3ad5912903b9773e545ccc0a",
"min_version": "3",
"package": "OpenSSL",
"patches": [
"0001-add-bundled-cert.patch"
],
"repo": "openssl/openssl",
"tag": "openssl-%VERSION%",
"version": "3.6.2"
},
"openssl-ci": {
"ci": true,
"min_version": "3",
"name": "openssl",
"package": "OpenSSL",
"repo": "crueter-ci/OpenSSL",
"version": "4.0.0-11b7b6ea3b"
},
"openssl-cmake": {
"bundled": true,
"hash": "2cc185c924fd70e7d886257ca0caa42b3b8f7f712f2052b4f94dde74759e27022de76178460e18c9bdfc57c366583999e198fbb6052d4e7d91c099d15a0ca63e",
"options": [
"ZSTD_BUILD_SHARED OFF"
]
"OPENSSL_CONFIGURE_OPTIONS threads"
],
"patches": [
"0001-cpmutil-compat.patch",
"0002-use-ccache.patch",
"0003-use-cmake-compiler-flags.patch",
"0004-use-shell-wrapper.patch"
],
"repo": "jimmy-park/openssl-cmake",
"tag": "%VERSION%",
"version": "3.6.2"
},
"opus": {
"package": "Opus",
"repo": "xiph/opus",
"sha": "a3f0ec02b3",
"hash": "9506147b0de35befda8633ff272981cc2575c860874791bd455b752f797fd7dbd1079f0ba42ccdd7bb1fe6773fa5e84b3d75667c2883dd1fb2d0e4a5fa4f8387",
"version": "1.3",
"find_args": "MODULE",
"hash": "9506147b0de35befda8633ff272981cc2575c860874791bd455b752f797fd7dbd1079f0ba42ccdd7bb1fe6773fa5e84b3d75667c2883dd1fb2d0e4a5fa4f8387",
"min_version": "1.3",
"options": [
"OPUS_PRESUME_NEON ON"
],
"package": "Opus",
"patches": [
"0001-disable-clang-runtime-neon.patch",
"0002-no-install.patch"
]
],
"repo": "xiph/opus",
"sha": "a3f0ec02b3",
"version": "1.5.2"
},
"boost_headers": {
"repo": "boostorg/headers",
"sha": "95930ca8f5",
"hash": "8a07d7a6f0065587d3005a83481a794704ae22e773b9f336fbd89ed230aaa7b4c86c03edcbae30bba8b3e20839c3131eaa2dceac037ef811533ef4eadc53b15b",
"bundled": true
"quazip": {
"hash": "609c240c7f029ac26a37d8fbab51bc16284e05e128b78b9b9c0e95d083538c36047a67d682759ac990e4adb0eeb90f04f1ea7fe2253bbda7e7e3bcce32e53dd8",
"min_version": "1.3",
"options": [
"QUAZIP_QT_MAJOR_VERSION 6",
"QUAZIP_INSTALL OFF",
"QUAZIP_ENABLE_QTEXTCODEC OFF",
"QUAZIP_BZIP2 OFF"
],
"package": "QuaZip-Qt6",
"repo": "stachenov/quazip",
"sha": "2e95c9001b",
"version": "1.5"
},
"llvm-mingw": {
"repo": "eden-emu/llvm-mingw",
"sdl3": {
"hash": "df5a323af7ac366661a3c0e887969c72584d232f3cc211419d59b0487b620b6b2859d4549c9e8df002ee489290062e466fcfddf7edc0872a37b1f2845e81c0f3",
"min_version": "3.2.10",
"package": "SDL3",
"repo": "libsdl-org/SDL",
"tag": "release-%VERSION%",
"version": "3.4.8"
},
"sdl3-ci": {
"ci": true,
"min_version": "3.2.10",
"name": "SDL3",
"package": "SDL3",
"repo": "crueter-ci/SDL3",
"version": "3.4.8-d57c3b685c"
},
"simpleini": {
"find_args": "MODULE",
"hash": "b937c18a7b6277d77ca7ebfb216af4984810f77af4c32d101b7685369a4bd5eb61406223f82698e167e6311a728d07415ab59639fdf19eff71ad6dc2abfda989",
"package": "SimpleIni",
"repo": "brofield/simpleini",
"tag": "v%VERSION%",
"version": "4.25"
},
"sirit": {
"artifact": "sirit-source-%VERSION%.tar.zst",
"find_args": "CONFIG",
"options": [
"SIRIT_USE_SYSTEM_SPIRV_HEADERS ON"
],
"repo": "eden-emulator/sirit",
"tag": "v%VERSION%",
"version": "1.0.5",
"hash": "10b3ff60bdcad428bb4f54360ff749212333a1d24c0b3ed99e466b1bfcf99d2db6cf596c0f965854a2095dfef9b7ce4e045edb070fa9f76eb3b295ab03a4a293"
},
"sirit-ci": {
"ci": true,
"name": "sirit",
"package": "sirit",
"repo": "eden-emulator/sirit",
"version": "1.0.5"
},
"spirv-headers": {
"hash": "cae8cd179c9013068876908fecc1d158168310ad6ac250398a41f0f5206ceff6469e2aaeab9c820bce9d1b08950c725c89c46e94b89a692be9805432cf749396",
"options": [
"SPIRV_WERROR OFF"
],
"package": "SPIRV-Headers",
"repo": "KhronosGroup/SPIRV-Headers",
"sha": "04f10f650d"
},
"tzdb": {
"artifact": "%VERSION%.tar.gz",
"git_host": "git.eden-emu.dev",
"hash": "cce65a12bf90f4ead43b24a0b95dfad77ac3d9bfbaaf66c55e6701346e7a1e44ca5d2f23f47ee35ee02271eb1082bf1762af207aad9fb236f1c8476812d008ed",
"package": "nx_tzdb",
"repo": "eden-emu/tzdb_to_nx",
"tag": "%VERSION%",
"version": "20250828",
"artifact": "clang-rt-builtins.tar.zst",
"hash": "d902392caf94e84f223766e2cc51ca5fab6cae36ab8dc6ef9ef6a683ab1c483bfcfe291ef0bd38ab16a4ecc4078344fa8af72da2f225ab4c378dee23f6186181"
"version": "230326"
},
"unordered-dense": {
"bundled": true,
"find_args": "CONFIG",
"hash": "d2106f6640f6bfb81755e4b8bfb64982e46ec4a507cacdb38f940123212ccf35a20b43c70c6f01d7bfb8c246d1a16f7845d8052971949cea9def1475e3fa02c8",
"package": "unordered_dense",
"patches": [
"0001-avoid-memset-when-clearing-an-empty-table.patch"
],
"repo": "martinus/unordered_dense",
"sha": "7b55cab841",
"version": "4.8.1"
},
"vulkan-headers": {
"hash": "d2846ea228415772645eea4b52a9efd33e6a563043dd3de059e798be6391a8f0ca089f455ae420ff22574939ed0f48ed7c6ff3d5a9987d5231dbf3b3f89b484b",
"min_version": "1.4.317",
"package": "VulkanHeaders",
"repo": "KhronosGroup/Vulkan-Headers",
"tag": "v%VERSION%",
"version": "1.4.345"
},
"vulkan-memory-allocator": {
"find_args": "CONFIG",
"hash": "deb5902ef8db0e329fbd5f3f4385eb0e26bdd9f14f3a2334823fb3fe18f36bc5d235d620d6e5f6fe3551ec3ea7038638899db8778c09f6d5c278f5ff95c3344b",
"package": "VulkanMemoryAllocator",
"repo": "GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator",
"tag": "v%VERSION%",
"version": "3.3.0"
},
"vulkan-utility-libraries": {
"hash": "114f6b237a6dcba923ccc576befb5dea3f1c9b3a30de7dc741f234a831d1c2d52d8a224afb37dd57dffca67ac0df461eaaab6a5ab5e503b393f91c166680c3e1",
"package": "VulkanUtilityLibraries",
"repo": "KhronosGroup/Vulkan-Utility-Libraries",
"tag": "v%VERSION%",
"version": "1.4.345"
},
"vulkan-validation-layers": {
"artifact": "android-binaries-%VERSION%.zip",
"hash": "8812ae84cbe49e6a3418ade9c458d3be6d74a3dffd319d4502007b564d580998056e8190414368ec11b27bc83993c7a0dad713c31bcc3d9553b51243efee3753",
"package": "VVL",
"repo": "KhronosGroup/Vulkan-ValidationLayers",
"tag": "vulkan-sdk-%VERSION%",
"git_version": "1.4.341.0",
"artifact": "android-binaries-%VERSION%.zip",
"hash": "8812ae84cbe49e6a3418ade9c458d3be6d74a3dffd319d4502007b564d580998056e8190414368ec11b27bc83993c7a0dad713c31bcc3d9553b51243efee3753"
"version": "1.4.341.0"
},
"quazip": {
"package": "QuaZip-Qt6",
"repo": "stachenov/quazip",
"sha": "2e95c9001b",
"hash": "609c240c7f029ac26a37d8fbab51bc16284e05e128b78b9b9c0e95d083538c36047a67d682759ac990e4adb0eeb90f04f1ea7fe2253bbda7e7e3bcce32e53dd8",
"version": "1.3",
"git_version": "1.5",
"xbyak": {
"hash": "b6475276b2faaeb315734ea8f4f8bd87ededcee768961b39679bee547e7f3e98884d8b7851e176d861dab30a80a76e6ea302f8c111483607dde969b4797ea95a",
"package": "xbyak",
"repo": "herumi/xbyak",
"tag": "v%VERSION%",
"version": "7.35.2"
},
"zlib": {
"hash": "16fea4df307a68cf0035858abe2fd550250618a97590e202037acd18a666f57afc10f8836cbbd472d54a0e76539d0e558cb26f059d53de52ff90634bbf4f47d4",
"min_version": "1.2",
"options": [
"QUAZIP_QT_MAJOR_VERSION 6",
"QUAZIP_INSTALL OFF",
"QUAZIP_ENABLE_QTEXTCODEC OFF",
"QUAZIP_BZIP2 OFF"
]
"ZLIB_BUILD_SHARED OFF",
"ZLIB_INSTALL OFF"
],
"package": "ZLIB",
"repo": "madler/zlib",
"tag": "v%VERSION%",
"version": "1.3.2"
},
"zstd": {
"find_args": "MODULE",
"hash": "cc5ad4b119a9c2ea57f0b71eeff01113bb506e0d17000159c5409cb8236d22e38c52d5e9e97e7947a4bf1b2dfc44b6c503ab2d9aedbd59458435c6a2849cb029",
"min_version": "1.5",
"options": [
"ZSTD_BUILD_SHARED OFF"
],
"repo": "facebook/zstd",
"sha": "b8d6101fba",
"source_subdir": "build/cmake",
"version": "1.5.7"
}
}

332
docs/CPMUtil.md

@ -0,0 +1,332 @@
# CPMUtil
CPMUtil is a wrapper around CPM that aims to reduce boilerplate and add useful utility functions to make dependency management a piece of cake.
- [CPMUtil](#cpmutil)
- [Global Options](#global-options)
- [About](#about)
- [Common Properties](#common-properties)
- [Standard Packages](#standard-packages)
- [Versioning](#versioning)
- [Patches](#patches)
- [Pre-built CI Packages](#pre-built-ci-packages)
- [Usage](#usage)
- [Addendum: Cache Storage](#addendum-cache-storage)
- [Addendum: Making Patches](#addendum-making-patches)
- [Addendum: Package Identification Lists](#addendum-package-identification-lists)
- [Addendum: Notes for Packagers](#addendum-notes-for-packagers)
- [Network Sandbox](#network-sandbox)
- [Unsandboxed](#unsandboxed)
- [Addendum: Dependent Packages](#addendum-dependent-packages)
- [Example: Vulkan](#example-vulkan)
- [Addendum: Module Path Packages](#addendum-module-path-packages)
- [Example: OpenSSL](#example-openssl)
- [Addendum: Adding Qt](#addendum-adding-qt)
## Global Options
- `CPMUTIL_FORCE_SYSTEM` (default `OFF`): Require all CPM dependencies to use system packages. NOT RECOMMENDED!
- You may optionally override this (section)
- `CPMUTIL_FORCE_BUNDLED` (default `ON` on MSVC and Android, `OFF` elsewhere): Require all CPM dependencies to use bundled packages.
- `CPMUTIL_PATCH_DIR` (default `${PROJECT_SOURCE_DIR}/.patch`): Path to patches used in packages. Stored as `<PATCH DIR>/json-package-name/0001-patch-name.patch`, etc.
- `CPM_SOURCE_CACHE` (default `${PROJECT_SOURCE_DIR}/.cache/cpm`): Where downloaded dependencies get stored.
## About
CPMUtil works by defining dependencies in a JSON file, `cpmfile.json`, and calling `AddJsonPackage`. These dependencies generally must define, at minimum:
- The repository and Git host
- A release artifact, commit, or tag archive to download
- A SHA512 sum for the downloaded artifact
And may optionally define other properties like:
- The minimum version for system packages
- The package name used for system packages (this defaults to the json key if undefined)
- In-tree source patches
- Options passed to CMake
- Options passed to find_package
For instance:
```json
"fmt": {
"repo": "fmtlib/fmt",
"tag": "12.1.0",
"hash": "f0da82c545b01692e9fd30fdfb613dbb8dd9716983dcd0ff19ac2a8d36f74beb5540ef38072fdecc1e34191b3682a8542ecbf3a61ef287dbba0a2679d4e023f2",
"min_version": "8",
"options": [
"FMT_TEST ON"
],
"patches": [
"0001-disable-reference-copy.patch"
]
}
```
Calling `AddJsonPackage(fmt)`:
- Searches for a system package named `fmt` of version 8 or higher
- If found, uses the system package and caches it for future use
- If not found:
- Downloads fmt 12.1.0 from the GitHub Archive into `.cache/cpm/fmt/12.1.0`
- Verifies the hash
- Applies the `0001-disable-reference-copy.patch` patch to the source tree
- Sets `FMT_TEST` to `ON`
- Adds the downloaded directory to CMake
- Now, future `find_package(fmt)` calls will use the downloaded package
There are two types of packages CPMUtil can define: standard and prebuilt CI packages. Some properties are common to both types, however.
## Common Properties
These JSON properties are used by standard and CI packages alike.
- `package`: The package name used by `find_package` to check for the existence of a system package.
- If unset, defaults to the JSON key
- `repo`: The Git repository the package is stored in, if applicable.
- `version`: The version of the package to download. This is required.
- `min_version`: The minimum required version of the package, if a system package is desired.
- `git_host`: The Git host the package is stored in, if applicable. Defaults to `github.com`.
## Standard Packages
Normal packages, like the prior `fmt` example, *must* also define:
- `hash`: The SHA512 hash of the downloaded artifact. CPMUtil generally computes this for you.
- A valid version/URL identifier:
- `url`: Download from a raw URL.
- `sha`: A short or fully-qualified Git commit sha. CPMUtil recommends using 10-character wide shas.
- `tag`: A Git tag. See [Versioning](#versioning) for its relation to `version`.
- `artifact`: A GitHub/Forgejo/Gitea release artifact (requires `tag`). See [Versioning](#versioning) for its relation to `tag` and `version`.
The following are optional to define:
- `source_subdir`: A subdirectory containing the `CMakeLists.txt` to configure a project. Useful for projects like `zstd`.
- `bundled`: Force the usage of a bundled package. Useful for packages where the system package is broken or nonexistent; e.g. including external fragment shaders.
- `find_args`: Additional arguments passed to `find_package`, e.g. `MODULE`
- `patches`: Array of in-tree patches to apply to the downloaded source code. See [#Patches](TODO).
- `options`: Array of CMake options to apply before configuring the package, e.g. `"FMT_TEST ON"`.
### Versioning
When using tags or artifacts, it may be cumbersome to repeat the version multiple times; especially if it's constantly changing. For this purpose, `tag` and `artifact` both support basic version text replacement.
`tag` can use `%VERSION%` to have its version replaced with the `version` defined for the package, e.g. for OpenSSL; when downloading, `tag` will evaluate to `openssl-3.6.2`:
```json
"openssl": {
"repo": "openssl/openssl",
"version": "3.6.2",
"tag": "openssl-%VERSION%"
}
```
`artifact` also supports `%VERSION%` replacement, and can also use `%TAG%` to be replaced by the computed tag. Take this Boost definition:
```json
"boost": {
"repo": "boostorg/boost",
"tag": "boost-%VERSION%",
"version": "1.90.0"
}
```
Boost's artifact for this version is stored in `boost-1.90.0-cmake.tar.xz`. Notice that the computed tag,`boost-1.90.0`, is in the name of the artifact! Thus, `artifact` can be either:
- `boost-%VERSION%-cmake.tar.xz`
- Or, even simpler: `%TAG%-cmake.tar.xz`
Future updates need only change the `version` identifier, and the artifact and tag will automatically be updated!
### Patches
CPMUtil is able to apply in-place source tree patches to downloaded packages. These are defined in JSON as an array of names, preferably using `git-format-patch`'s scheme of `<4 digit number>-patch-name.patch`. These are stored in `<CPMUTIL_PATCH_DIR>/<json-key>` (remember that `CPMUTIL_PATCH_DIR` defaults to `$ROOT/.patch`); e.g. `boost` patches would be in `.patch/boost`. Let's say we've made three patches and want to add them; in the Boost JSON definition, we would add:
```json
"patches": [
"0001-fix-clang-cl-compilation.patch",
"0002-fix-msvc-arm64-compilation.patch",
"0003-fix-bsd-linking.patch"
]
```
Then, when Boost is downloaded, it will apply these patches in order to the source tree.
To learn how to make patches, see [Addendum: Making Patches](#addendum-making-patches).
## Pre-built CI Packages
The definition and usage of CI packages is subject to change in the very near future.
CI packages are, in essence, prebuilt binary distributions for libraries. They exist for a few reasons:
- Creating static libraries for system packages that normally lack them, e.g. Qt/SDL
- Reducing duplicated compilation effort on rarely-changing externals, e.g. SDL
- Creating debloated prebuilt packages specifically for your project to reduce binary size, e.g. FFmpeg
CPMUtil is specifically designed to work with a small subset of prebuilt CI packages; namely, those that follow the format of the [crueter-ci spec](https://github.com/crueter-ci/spec/blob/master/README.md).
To use them, you must add `ci: true` to your package definition. Alongside the common properties, CI packages define the following:
- `name`: The artifacts' name prefix (required), e.g. `openssl`
- `extension`: The artifacts' extension (default `tar.zst`)
- `disabled_platforms`: CPMUtil-supported platforms that are not built into this repository.
- This is subject to change.
**Note that `package` is subject to removal here.**
Example:
```json
"sdl2": {
"repo": "crueter-ci/SDL2",
"package": "SDL2",
"min_version": "2.26.4",
"ci": true,
"version": "2.32.10-a65111bd2d",
"artifact": "SDL2"
},
```
## Usage
Once you've defined your package in `cpmfile.json`, simply call `AddJsonPackage(<JSON key>)` and go from there! Specific instructions differ between individual packages, so you're on your own from here.
If you're only concerned with basic usage, you can stop reading. For more advanced use cases and package management, read these addenda.
## Addendum: Cache Storage
CPMUtil stores downloaded packages within `.cache/cpm` by default (see `CPM_SOURCE_CACHE`). Subdirectories stored within are lowercase representations of the `find_package` name for the package; for instance, a `vulkan-headers` definition with `package: "VulkanHeaders"` would be stored in `.cache/cpm/vulkanheaders`.
Within these subdirectories, additional directories are created for each individual version:
- A four-character shorthand of `sha`, if defined
- If `sha` is not defined, the fully qualified `version` is used
CI packages use `<platform>-<architecture>-<version>` unconditionally.
## Addendum: Making Patches
CPMUtil currently lacks functionality to make patches; these will be added in the future. For now, here's how to go about it; you should familiarize yourself with CPMUtil's shell tooling, and Git, first.
- Clean-fetch your package:
- `rm -rf .cache/cpm/<lowercase package name>`
- `tools/cpmutil.sh package fetch <package JSON key>`
- `cd .cache/cpm/<lowercase package name>/<version>`
- Now, initialize a Git repository and commit:
- `git init`
- `git add .`
- `git commit -m "Initial Commit"`
- Now, make any changes you need within the source directory.
- Then, create your patch:
- `git commit -am "short summary of patch"`
- You may optionally choose to use `-av` instead to use your configured command-line editor. This also allows you to add a lengthy description.
- `git format-patch -1 HEAD`
- Your patch is now stored in `0001-short-summary-of-patch.patch` or similar.
- Copy this patch to the root of your repository.
- Rename the patch if needed, taking special note to ensure the starting number is correct
- For instance, if you already have 2 other patches, it should be renamed to `0003-...`
- Move the patch to `.patch/<package-json-key>`, creating the directory if it doesn't exist.
- Add your patch filename to the corresponding JSON definition.
## Addendum: Package Identification Lists
CPMUtil will create three lists of dependencies where `AddPackage` or similar was used. Each is in order of addition.
- `CPM_PACKAGE_NAMES`: The names of packages included by CPMUtil
- `CPM_PACKAGE_URLS`: The URLs to project/repo pages of packages
- `CPM_PACKAGE_SHAS`: Short version identifiers for each package
- If the package was included as a system package, `(system)` is appended thereafter
- Packages whose versions can't be deduced will be left as `unknown`.
For an example of how this might be implemented in an application, see Eden's implementation:
- [`dep_hashes.h.in`](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/src/dep_hashes.h.in)
- [`GenerateDepHashes.cmake`](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CMakeModules/GenerateDepHashes.cmake)
- [`deps_dialog.cpp`](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/src/yuzu/deps_dialog.cpp)
## Addendum: Notes for Packagers
If you are packaging a project that uses CPMUtil, read this!
### Network Sandbox
For sandboxed environments (e.g. Gentoo, nixOS) you must install all dependencies to the system beforehand and set `-DCPMUTIL_FORCE_SYSTEM=ON`. If a dependency is missing, get creating!
Alternatively, if CPMUtil pulls in a package that has no suitable way to install or use a system version, download it separately and pass `-DPackageName_DIR=/path/to/downloaded/dir` (e.g. shaders)
### Unsandboxed
For others (AUR, MPR, etc). CPMUtil will handle everything for you, including if some of the project's dependencies are missing from your distribution's repositories. See [`eden-git`](https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=eden-git) for an example.
## Addendum: Dependent Packages
Consider the following scenario: the Vulkan Headers and Vulkan Utility libraries are both pulled in by my project. In order for both to compile cleanly, their versions *must* match. However, a user may have the Vulkan Headers installed, but *not* the Vulkan Utility Libraries! This can cause a version mismatch where the Utility Libraries expect a much newer version of the Vulkan Headers than the user has installed.
To solve this, CPMUtil has an `AddDependentPackages` command. This takes a list of JSON package keys that *must* either ALL be installed to the system, or ALL be bundled.
### Example: Vulkan
Using the prior Vulkan example:
```json
"vulkan-headers": {
"repo": "KhronosGroup/Vulkan-Headers",
"package": "VulkanHeaders",
"min_version": "1.4.317",
"version": "1.4.342",
"tag": "v%VERSION%"
},
"vulkan-utility-libraries": {
"repo": "KhronosGroup/Vulkan-Utility-Libraries",
"package": "VulkanUtilityLibraries",
"version": "1.4.342",
"tag": "v%VERSION%"
}
```
In CMake:
```cmake
AddDependentPackages(vulkan-headers vulkan-utility-libraries)
```
Possible scenarios:
- The user has both Vulkan Headers and Vulkan Utility Libraries installed to the system, and both are new enough.
- Configuration proceeds without issue.
- The user has neither installed, or has a too-old version of Vulkan Headers installed
- Configuration proceeds without issue.
- The user has a valid Vulkan Headers installed, but not Vulkan Utility Libraries.
- CPMUtil instructs the user to either force bundled Vulkan Headers, or install Vulkan Utility Libraries.
- The user has both installed, but Vulkan Headers are too old.
- CPMUtil instructs the user to install a valid version of Vulkan Headers, or force bundled Vulkan Utility Libraries.
## Addendum: Module Path Packages
Sometimes, a prebuilt CI package may be packed in such a way that it's meant to be used in the context of a system install (e.g. pkgconfig or CMakeConfig files). In this case, CPMUtil normally will be unable to configure the downloaded subdirectory. To solve this, you can use `AddJsonPackage`'s `MODULE_PATH` mode, which adds the downloaded source directory to the `CMAKE_MODULE_PATH`.
### Example: OpenSSL
Say an OpenSSL CI package is packed to contain its CMake config files rather than a root `CMakeLists.txt`; in this case, you would call:
```cmake
AddJsonPackage(NAME openssl MODULE_PATH)
```
The `NAME` argument is also required, as the parsing is different from the standard single-argument function signature.
From here, calling `find_package(OpenSSL)` will use the bundled OpenSSL.
## Addendum: Adding Qt
If you'd like to use customized Qt builds, CPMUtil provides a convenience function that allows you to add Qt builds. This usage and setup is subject to change.
See [crueter-ci/Qt](https://github.com/crueter-ci/Qt) for an example of how one might build customized Qt. To add a Qt build to your project, use `AddQt(<repository> <version>)`, e.g.:
```cmake
AddQt(QDash-CI/Qt 6.11.1)
```
Then, call `find_package(Qt6 ...)` and it will pull Qt from your downloaded source.

21
docs/CPMUtil/AddCIPackage.md

@ -1,21 +0,0 @@
# AddPackage
- `VERSION` (required): The version to get (the tag will be `v${VERSION}`)
- `NAME` (required): Name used within the artifacts
- `REPO` (required): CI repository, e.g. `crueter-ci/OpenSSL`
- `PACKAGE` (required): `find_package` package name
- `EXTENSION`: Artifact extension (default `tar.zst`)
- `MIN_VERSION`: Minimum version for `find_package`. Only used if platform does not support this package as a bundled artifact
- `DISABLED_PLATFORMS`: List of platforms that lack artifacts for this package. Options:
- `windows-amd64`
- `windows-arm64`
- `mingw-amd64`
- `mingw-arm64`
- `android-x86_64`
- `android-aarch64`
- `solaris-amd64`
- `freebsd-amd64`
- `linux-amd64`
- `linux-aarch64`
- `macos-universal`
- `ios-aarch64`

41
docs/CPMUtil/AddDependentPackage.md

@ -1,41 +0,0 @@
# AddDependentPackage
Use `AddDependentPackage` when you have multiple packages that are required to all be from the system, OR bundled. This is useful in cases where e.g. versions must absolutely match.
## Versioning
Versioning must be handled by the package itself.
## Examples
### Vulkan
`cpmfile.json`
```json
{
"vulkan-headers": {
"repo": "KhronosGroup/Vulkan-Headers",
"package": "VulkanHeaders",
"version": "1.4.317",
"hash": "26e0ad8fa34ab65a91ca62ddc54cc4410d209a94f64f2817dcdb8061dc621539a4262eab6387e9b9aa421db3dbf2cf8e2a4b041b696d0d03746bae1f25191272",
"git_version": "1.4.342",
"tag": "v%VERSION%"
},
"vulkan-utility-libraries": {
"repo": "KhronosGroup/Vulkan-Utility-Libraries",
"package": "VulkanUtilityLibraries",
"hash": "8147370f964fd82c315d6bb89adeda30186098427bf3efaa641d36282d42a263f31e96e4586bfd7ae0410ff015379c19aa4512ba160630444d3d8553afd1ec14",
"git_version": "1.4.342",
"tag": "v%VERSION%"
}
}
```
`CMakeLists.txt`:
```cmake
AddDependentPackages(vulkan-headers vulkan-utility-libraries)
```
If Vulkan Headers are installed, but NOT Vulkan Utility Libraries, then CPMUtil will throw an error.

105
docs/CPMUtil/AddJsonPackage.md

@ -1,105 +0,0 @@
# AddJsonPackage
In each directory that utilizes `CPMUtil`, there must be a `cpmfile.json` that defines dependencies in a similar manner to the individual calls.
The cpmfile is an object of objects, with each sub-object being named according to the package's identifier, e.g. `openssl`, which can then be fetched with `AddJsonPackage(<identifier>)`. Options are designed to map closely to the argument names, and are always strings unless otherwise specified.
<!-- TOC -->
- [Options](#options)
- [Examples](#examples)
<!-- /TOC -->
## Options
- `package` -> `NAME` (`PACKAGE` for CI), defaults to the object key
- `repo` -> `REPO`
- `version` -> `VERSION`
- `ci` (bool)
If `ci` is `false`:
- `hash` -> `HASH`
- `hash_suffix` -> `HASH_SUFFIX`
- `sha` -> `SHA`
- `key` -> `KEY`
- `tag` -> `TAG`
- If the tag contains `%VERSION%`, that part will be replaced by the `git_version`, OR `version` if `git_version` is not specified
- `url` -> `URL`
- `artifact` -> `ARTIFACT`
- If the artifact contains `%VERSION%`, that part will be replaced by the `git_version`, OR `version` if `git_version` is not specified
- If the artifact contains `%TAG%`, that part will be replaced by the `tag` (with its replacement already done)
- `git_version` -> `GIT_VERSION`
- `git_host` -> `GIT_HOST`
- `source_subdir` -> `SOURCE_SUBDIR`
- `bundled` -> `BUNDLED_PACKAGE`
- `find_args` -> `FIND_PACKAGE_ARGUMENTS`
- `download_only` -> `DOWNLOAD_ONLY`
- `patches` -> `PATCHES` (array)
- `options` -> `OPTIONS` (array)
- `skip_updates`: Tells `check-updates.sh` to not check for new updates on this package.
Other arguments aren't currently supported. If you wish to add them, see the `AddJsonPackage` function in `CMakeModules/CPMUtil.cmake`.
If `ci` is `true`:
- `name` -> `NAME`, defaults to the object key
- `extension` -> `EXTENSION`, defaults to `tar.zst`
- `min_version` -> `MIN_VERSION`
- `extension` -> `EXTENSION`
- `disabled_platforms` -> `DISABLED_PLATFORMS` (array)
## Examples
In order: OpenSSL CI, Boost (tag + artifact), Opus (options + find_args), discord-rpc (sha + options + patches).
```json
{
"openssl": {
"ci": true,
"package": "OpenSSL",
"name": "openssl",
"repo": "crueter-ci/OpenSSL",
"version": "3.6.0",
"min_version": "1.1.1",
"disabled_platforms": [
"macos-universal",
"ios-aarch64"
]
},
"boost": {
"package": "Boost",
"repo": "boostorg/boost",
"tag": "boost-%VERSION%",
"artifact": "%TAG%-cmake.7z",
"hash": "e5b049e5b61964480ca816395f63f95621e66cb9bcf616a8b10e441e0e69f129e22443acb11e77bc1e8170f8e4171b9b7719891efc43699782bfcd4b3a365f01",
"git_version": "1.88.0",
"version": "1.57"
},
"opus": {
"package": "Opus",
"repo": "xiph/opus",
"sha": "5ded705cf4",
"hash": "0dc89e58ddda1f3bc6a7037963994770c5806c10e66f5cc55c59286fc76d0544fe4eca7626772b888fd719f434bc8a92f792bdb350c807968b2ac14cfc04b203",
"version": "1.3",
"find_args": "MODULE",
"options": [
"OPUS_BUILD_TESTING OFF",
"OPUS_BUILD_PROGRAMS OFF",
"OPUS_INSTALL_PKG_CONFIG_MODULE OFF",
"OPUS_INSTALL_CMAKE_CONFIG_MODULE OFF"
]
},
"discord-rpc": {
"repo": "discord/discord-rpc",
"sha": "963aa9f3e5",
"hash": "386e1344e9a666d730f2d335ee3aef1fd05b1039febefd51aa751b705009cc764411397f3ca08dffd46205c72f75b235c870c737b2091a4ed0c3b061f5919bde",
"options": [
"BUILD_EXAMPLES OFF"
],
"patches": [
"0001-cmake-version.patch",
"0002-no-clang-format.patch",
"0003-fix-cpp17.patch"
]
}
}
```

118
docs/CPMUtil/AddPackage.md

@ -1,118 +0,0 @@
# `AddPackage`
<!-- TOC -->
- [Identification/Fetching](#identificationfetching)
- [Hashing](#hashing)
- [Other Options](#other-options)
- [Extra Variables](#extra-variables)
- [System/Bundled Packages](#systembundled-packages)
- [Identification](#identification)
<!-- /TOC -->
## Identification/Fetching
- `NAME` (required): The package name (must be the same as the `find_package` name if applicable)
- `VERSION`: The minimum version of this package that can be used on the system
- `GIT_VERSION`: The "version" found within git
- `URL`: The URL to fetch.
- `REPO`: The repo to use (`owner/repo`).
- `GIT_HOST`: The Git host to use
- Defaults to `github.com`. Do not include the protocol, as HTTPS is enforced.
- `TAG`: The tag to fetch, if applicable.
- `ARTIFACT`: The name of the artifact, if applicable.
- `SHA`: Commit sha to fetch, if applicable.
- `BRANCH`: Branch to fetch, if applicable.
The following configurations are supported, in descending order of precedence:
- `URL`: Bare URL download, useful for custom artifacts
- If this is set, `GIT_URL` or `REPO` should be set to allow the dependency viewer to link to the project's Git repository.
- If this is NOT set, `REPO` must be defined.
- `REPO + TAG + ARTIFACT`: GitHub release artifact
- The final download URL will be `https://github.com/${REPO}/releases/download/${TAG}/${ARTIFACT}`
- Useful for prebuilt libraries and prefetched archives
- `REPO + TAG`: GitHub tag archive
- The final download URL will be `https://github.com/${REPO}/archive/refs/tags/${TAG}.tar.gz`
- Useful for pinning to a specific tag, better for build identification
- `REPO + SHA`: GitHub commit archive
- The final download URL will be `https://github.com/${REPO}/archive/${SHA}.zip`
- Useful for pinning to a specific commit
- `REPO + BRANCH`: GitHub branch archive
- The final download URL will be `https://github.com/${REPO}/archive/refs/heads/${BRANCH}.zip`
- Generally not recommended unless the branch is frozen
- `REPO`: GitHub master archive
- The final download URL will be `https://github.com/${REPO}/archive/refs/heads/master.zip`
- Generally not recommended unless the project is dead
## Hashing
Hashing is used for verifying downloads. It's highly recommended to use these.
- `HASH_ALGO` (default `SHA512`): Hash algorithm to use
Hashing strategies, descending order of precedence:
- `HASH`: Bare hash verification, useful for static downloads e.g. commit archives
- `HASH_SUFFIX`: Download the hash as `${DOWNLOAD_URL}.${HASH_SUFFIX}`
- The downloaded hash *must* match the hash algorithm and contain nothing but the hash; no filenames or extra content.
- `HASH_URL`: Download the hash from a separate URL
## Other Options
- `KEY`: Custom cache key to use (stored as `.cache/cpm/${packagename_lower}/${key}`)
- Default is based on, in descending order of precedence:
- First 4 characters of the sha
- `GIT_VERSION`
- Tag
- `VERSION`
- Otherwise, CPM defaults will be used. This is not recommended as it doesn't produce reproducible caches
- `DOWNLOAD_ONLY`: Whether or not to configure the downloaded package via CMake
- Useful to turn `OFF` if the project doesn't use CMake
- `SOURCE_SUBDIR`: Subdirectory of the project containing a CMakeLists.txt file
- `FIND_PACKAGE_ARGUMENTS`: Arguments to pass to the `find_package` call
- `BUNDLED_PACKAGE`: Set to `ON` to default to the bundled package
- `FORCE_BUNDLED_PACKAGE`: Set to `ON` to force the usage of the bundled package, regardless of CPMUTIL_FORCE_SYSTEM or `<package>_FORCE_SYSTEM`
- `OPTIONS`: Options to pass to the configuration of the package
- `PATCHES`: Patches to apply to the package, stored in `.patch/${packagename_lower}/0001-patch-name.patch` and so on
- Other arguments can be passed to CPM as well
## Extra Variables
For each added package, users may additionally force usage of the system/bundled package.
- `${package}_DIR`: Path to a separately-downloaded copy of the package. Note that versioning is not checked!
- `${package}_FORCE_SYSTEM`: Require the package to be installed on the system
- `${package}_FORCE_BUNDLED`: Force the package to be fetched and use the bundled version
## System/Bundled Packages
Descending order of precedence:
- If `${package}_FORCE_SYSTEM` is true, requires the package to be on the system
- If `${package}_FORCE_BUNDLED` is true, forcefully uses the bundled package
- If `CPMUTIL_FORCE_SYSTEM` is true, requires the package to be on the system
- If `CPMUTIL_FORCE_BUNDLED` is true, forcefully uses the bundled package
- If the `BUNDLED_PACKAGE` argument is true, forcefully uses the bundled package
- Otherwise, CPM will search for the package first, and if not found, will use the bundled package
## Identification
All dependencies must be identifiable in some way for usage in the dependency viewer. Lists are provided in descending order of precedence.
URLs:
- `GIT_URL`
- `REPO` as a Git repository
- You may optionally specify `GIT_HOST` to use a custom host, e.g. `GIT_HOST git.crueter.xyz`. Note that the git host MUST be GitHub-like in its artifact/archive downloads, e.g. Forgejo
- If `GIT_HOST` is unspecified, defaults to `github.com`
- `URL`
Versions (bundled):
- `SHA`
- `GIT_VERSION`
- `VERSION`
- `TAG`
- "unknown"
If the package is a system package, AddPackage will attempt to determine the package version and append `(system)` to the identifier. Otherwise, it will be marked as `unknown (system)`

28
docs/CPMUtil/AddQt.md

@ -1,28 +0,0 @@
# AddQt
Simply call `AddQt(<Qt Version>)` before any Qt `find_package` calls and everything will be set up for you. On Linux, the bundled Qt library is built as a shared library, and provided you have OpenSSL and X11, everything should just work.
On Windows, MinGW, and MacOS, Qt is bundled as a static library. No further action is needed, as the provided libraries automatically integrate the Windows/Cocoa plugins, alongside the corresponding Multimedia and Network plugins.
## Modules
The following modules are bundled into these Qt builds:
- Base (Gui, Core, Widgets, Network)
- Multimedia
- Declarative (Quick, QML)
- Linux: Wayland client
Each platform has the corresponding QPA built in and set as the default as well. This means you don't need to add `Q_IMPORT_PLUGIN`!
## Example
See an example in the [`tests/qt`](https://git.crueter.xyz/CMake/CPMUtil/src/branch/master/tests/qt/CMakeLists.txt) directory.
## Versions
The following versions have available builds:
- 6.9.3
See [`crueter-ci/Qt`](https://github.com/crueter-ci/Qt) for an updated list at any time.

70
docs/CPMUtil/README.md

@ -1,70 +0,0 @@
# CPMUtil
CPMUtil is a wrapper around CPM that aims to reduce boilerplate and add useful utility functions to make dependency management a piece of cake.
Global Options:
- `CPMUTIL_FORCE_SYSTEM` (default `OFF`): Require all CPM dependencies to use system packages. NOT RECOMMENDED!
- You may optionally override this (section)
- `CPMUTIL_FORCE_BUNDLED` (default `ON` on MSVC and Android, `OFF` elsewhere): Require all CPM dependencies to use bundled packages.
You are highly encouraged to read AddPackage first, even if you plan to only interact with CPMUtil via `AddJsonPackage`.
- [AddPackage](#addpackage)
- [AddCIPackage](#addcipackage)
- [AddJsonPackage](#addjsonpackage)
- [AddQt](#addqt)
- [Lists](#lists)
- [For Packagers](#for-packagers)
- [Network Sandbox](#network-sandbox)
- [Unsandboxed](#unsandboxed)
## AddPackage
The core of CPMUtil is the [`AddPackage`](./AddPackage.md) function. [`AddPackage`](./AddPackage.md) itself is fully CMake-based, and largely serves as an interface between CPM and the rest of CPMUtil.
## AddCIPackage
[`AddCIPackage`](./AddCIPackage.md) adds a package that follows [crueter's CI repository spec](https://github.com/crueter-ci).
## AddJsonPackage
[`AddJsonPackage`](./AddJsonPackage.md) is the recommended method of usage for CPMUtil.
## AddDependentPackage
[`AddDependentPackage`](./AddDependentPackage.md) allows you to add multiple packages such that all of them must be from the system OR bundled.
## AddQt
[`AddQt`](./AddQt.md) adds a specific version of Qt to your project.
## Lists
CPMUtil will create three lists of dependencies where `AddPackage` or similar was used. Each is in order of addition.
- `CPM_PACKAGE_NAMES`: The names of packages included by CPMUtil
- `CPM_PACKAGE_URLS`: The URLs to project/repo pages of packages
- `CPM_PACKAGE_SHAS`: Short version identifiers for each package
- If the package was included as a system package, `(system)` is appended thereafter
- Packages whose versions can't be deduced will be left as `unknown`.
For an example of how this might be implemented in an application, see Eden's implementation:
- [`dep_hashes.h.in`](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/src/dep_hashes.h.in)
- [`GenerateDepHashes.cmake`](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CMakeModules/GenerateDepHashes.cmake)
- [`deps_dialog.cpp`](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/src/yuzu/deps_dialog.cpp)
## For Packagers
If you are packaging a project that uses CPMUtil, read this!
### Network Sandbox
For sandboxed environments (e.g. Gentoo, nixOS) you must install all dependencies to the system beforehand and set `-DCPMUTIL_FORCE_SYSTEM=ON`. If a dependency is missing, get creating!
Alternatively, if CPMUtil pulls in a package that has no suitable way to install or use a system version, download it separately and pass `-DPackageName_DIR=/path/to/downloaded/dir` (e.g. shaders)
### Unsandboxed
For others (AUR, MPR, etc). CPMUtil will handle everything for you, including if some of the project's dependencies are missing from your distribution's repositories. That is pretty much half the reason I created this behemoth, after all.

3
externals/CMakeLists.txt

@ -6,8 +6,7 @@
# TODO(crueter): A lot of this should be moved to the root.
# otherwise we have to do weird shenanigans with library linking and stuff
include(CPMUtil)
# Or just add a CPMUtil thing to propagate packages
# Explicitly declare this option here to propagate to the oaknut CPM call
option(DYNARMIC_TESTS "Build tests" ${BUILD_TESTING})

249
externals/cpmfile.json

@ -1,249 +0,0 @@
{
"vulkan-memory-allocator": {
"package": "VulkanMemoryAllocator",
"repo": "GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator",
"tag": "v%VERSION%",
"hash": "deb5902ef8db0e329fbd5f3f4385eb0e26bdd9f14f3a2334823fb3fe18f36bc5d235d620d6e5f6fe3551ec3ea7038638899db8778c09f6d5c278f5ff95c3344b",
"find_args": "CONFIG",
"git_version": "3.3.0"
},
"sirit": {
"repo": "eden-emulator/sirit",
"git_version": "1.0.5",
"tag": "v%VERSION%",
"artifact": "sirit-source-%VERSION%.tar.zst",
"hash_suffix": "sha512sum",
"find_args": "CONFIG",
"options": [
"SIRIT_USE_SYSTEM_SPIRV_HEADERS ON"
]
},
"sirit-ci": {
"ci": true,
"package": "sirit",
"name": "sirit",
"repo": "eden-emulator/sirit",
"version": "1.0.5"
},
"httplib": {
"repo": "yhirose/cpp-httplib",
"tag": "v%VERSION%",
"hash": "159ed94965018f2a371d45a3bfc1961e5fb1549e501ded70a6b4532d7fe99d0579c18b5195aff6e35f96f399b426cea2650ec9fb75ef80d4c9edeccb51f2e6c9",
"git_version": "0.46.0",
"find_args": "MODULE GLOBAL",
"patches": [
"0001-mingw.patch"
],
"options": [
"HTTPLIB_REQUIRE_OPENSSL ON",
"HTTPLIB_DISABLE_MACOSX_AUTOMATIC_ROOT_CERTIFICATES ON"
]
},
"cpp-jwt": {
"version": "1.4",
"repo": "arun11299/cpp-jwt",
"sha": "7f24eb4c32",
"hash": "d11cbd5ddb3197b4c5ca15679bcd76a49963e7b530b7dd132db91e042925efa20dfb2c24ccfbe7ef82a7012af80deff0f72ee25851312ae80381a462df8534b8",
"find_args": "CONFIG",
"options": [
"CPP_JWT_USE_VENDORED_NLOHMANN_JSON OFF"
],
"patches": [
"0001-fix-missing-decl.patch"
]
},
"xbyak": {
"package": "xbyak",
"repo": "herumi/xbyak",
"tag": "v%VERSION%",
"hash": "b6475276b2faaeb315734ea8f4f8bd87ededcee768961b39679bee547e7f3e98884d8b7851e176d861dab30a80a76e6ea302f8c111483607dde969b4797ea95a",
"git_version": "7.35.2"
},
"oaknut": {
"repo": "eden-emulator/oaknut",
"version": "2.0.1",
"git_version": "2.0.3",
"tag": "v%VERSION%",
"hash": "9697e80a7d5d9bcb3ce51051a9a24962fb90ca79d215f1f03ae6b58da8ba13a63b5dda1b4dde3d26ac6445029696b8ef2883f4e5a777b342bba01283ed293856"
},
"lagoon": {
"repo": "loongson-community/lagoon",
"tag": "%VERSION%",
"version": "1.0.0",
"hash": "b9380f99c6effaeccc6d8f81d4942e852c11ad28613df637e155451556ae5826f93765bee57a5c87a9740d2bd1db463ad0f55a947772fe9d57eeabae3efa373e"
},
"libadrenotools": {
"repo": "eden-emulator/libadrenotools",
"sha": "8ba23b42d7",
"hash": "f6526620cb752876edc5ed4c0925d57b873a8218ee09ad10859ee476e9333259784f61c1dcc55a2bcba597352d18aff22cd2e4c1925ec2ae94074e09d7da2265",
"patches": [
"0001-linkerns-cpm.patch"
]
},
"oboe": {
"repo": "google/oboe",
"tag": "%VERSION%",
"hash": "ce4011afe7345370d4ead3b891cd69a5ef224b129535783586c0ca75051d303ed446e6c7f10bde8da31fff58d6e307f1732a3ffd03b249f9ef1fd48fd4132715",
"git_version": "1.10.0",
"bundled": true
},
"unordered-dense": {
"package": "unordered_dense",
"repo": "martinus/unordered_dense",
"sha": "7b55cab841",
"hash": "d2106f6640f6bfb81755e4b8bfb64982e46ec4a507cacdb38f940123212ccf35a20b43c70c6f01d7bfb8c246d1a16f7845d8052971949cea9def1475e3fa02c8",
"find_args": "CONFIG",
"bundled": true,
"patches": [
"0001-avoid-memset-when-clearing-an-empty-table.patch"
]
},
"enet": {
"repo": "lsalzman/enet",
"tag": "v%VERSION%",
"hash": "a0d2fa8c957704dd49e00a726284ac5ca034b50b00d2b20a94fa1bbfbb80841467834bfdc84aa0ed0d6aab894608fd6c86c3b94eee46343f0e6d9c22e391dbf9",
"version": "1.3",
"git_version": "1.3.18",
"find_args": "MODULE"
},
"spirv-headers": {
"package": "SPIRV-Headers",
"repo": "KhronosGroup/SPIRV-Headers",
"sha": "04f10f650d",
"hash": "cae8cd179c9013068876908fecc1d158168310ad6ac250398a41f0f5206ceff6469e2aaeab9c820bce9d1b08950c725c89c46e94b89a692be9805432cf749396",
"options": [
"SPIRV_WERROR OFF"
]
},
"cubeb": {
"repo": "mozilla/cubeb",
"sha": "fa02160712",
"hash": "8a4bcb2f83ba590f52c66626e895304a73eb61928dbc57777e1822e55378e3568366f17f9da4b80036cc2ef4ea9723c32abf6e7d9bbe00fb03654f0991596ab0",
"find_args": "CONFIG",
"options": [
"USE_SANITIZERS OFF",
"BUILD_TESTS OFF",
"BUILD_TOOLS OFF",
"BUNDLE_SPEEX ON"
]
},
"sdl3-ci": {
"ci": true,
"package": "SDL3",
"name": "SDL3",
"repo": "crueter-ci/SDL3",
"version": "3.4.8-d57c3b685c",
"min_version": "3.2.10"
},
"catch2": {
"package": "Catch2",
"repo": "catchorg/Catch2",
"tag": "v%VERSION%",
"hash": "7eea385d79d88a5690cde131fe7ccda97d5c54ea09d6f515000d7bf07c828809d61c1ac99912c1ee507cf933f61c1c47ecdcc45df7850ffa82714034b0fccf35",
"version": "3.0.1",
"git_version": "3.13.0",
"patches": [
"0001-solaris-isnan-fix.patch"
]
},
"discord-rpc": {
"package": "DiscordRPC",
"repo": "eden-emulator/discord-rpc",
"sha": "0d8b2d6a37",
"hash": "8213c43dcb0f7d479f5861091d111ed12fbdec1e62e6d729d65a4bc181d82f48a35d5fd3cd5c291f2393ac7c9681eabc6b76609755f55376284c8a8d67e148f3",
"find_args": "MODULE"
},
"simpleini": {
"package": "SimpleIni",
"repo": "brofield/simpleini",
"tag": "v%VERSION%",
"hash": "b937c18a7b6277d77ca7ebfb216af4984810f77af4c32d101b7685369a4bd5eb61406223f82698e167e6311a728d07415ab59639fdf19eff71ad6dc2abfda989",
"find_args": "MODULE",
"git_version": "4.25"
},
"sdl3": {
"package": "SDL3",
"repo": "libsdl-org/SDL",
"tag": "release-%VERSION%",
"hash": "df5a323af7ac366661a3c0e887969c72584d232f3cc211419d59b0487b620b6b2859d4549c9e8df002ee489290062e466fcfddf7edc0872a37b1f2845e81c0f3",
"git_version": "3.4.8",
"version": "3.2.10"
},
"moltenvk": {
"repo": "V380-Ori/Ryujinx.MoltenVK",
"tag": "v%VERSION%-ryujinx",
"git_version": "1.4.1",
"artifact": "MoltenVK-macOS.tar",
"hash": "5695b36ca5775819a71791557fcb40a4a5ee4495be6b8442e0b666d0c436bec02aae68cc6210183f7a5c986bdbec0e117aecfad5396e496e9c2fd5c89133a347",
"bundled": true
},
"gamemode": {
"repo": "FeralInteractive/gamemode",
"sha": "ce6fe122f3",
"hash": "e87ec14ed3e826d578ebf095c41580069dda603792ba91efa84f45f4571a28f4d91889675055fd6f042d7dc25b0b9443daf70963ae463e38b11bcba95f4c65a9",
"version": "1.7",
"find_args": "MODULE"
},
"biscuit": {
"repo": "lioncash/biscuit",
"tag": "v%VERSION%",
"hash": "1229f345b014f7ca544dedb4edb3311e41ba736f9aa9a67f88b5f26f3c983288c6bb6cdedcfb0b8a02c63088a37e6a0d7ba97d9c2a4d721b213916327cffe28a",
"version": "0.9.1",
"git_version": "0.19.0"
},
"libusb": {
"repo": "libusb/libusb",
"tag": "v%VERSION%",
"hash": "98c5f7940ff06b25c9aa65aa98e23de4c79a4c1067595f4c73cc145af23a1c286639e1ba11185cd91bab702081f307b973f08a4c9746576dc8d01b3620a3aeb5",
"find_args": "MODULE",
"git_version": "1.0.29",
"patches": [
"0001-netbsd-gettime.patch"
]
},
"ffmpeg": {
"repo": "FFmpeg/FFmpeg",
"sha": "c7b5f1537d",
"hash": "ed177621176b3961bdcaa339187d3a7688c1c8b060b79c4bb0257cbc67ad7021ae5d5adca5303b45625abbbe3d9aafdd87ce777b8690ac295290d744c875489a",
"bundled": true
},
"ffmpeg-ci": {
"ci": true,
"package": "FFmpeg",
"name": "ffmpeg",
"repo": "crueter-ci/FFmpeg",
"version": "8.0.1-c7b5f1537d",
"min_version": "4.1"
},
"tzdb": {
"package": "nx_tzdb",
"repo": "eden-emu/tzdb_to_nx",
"git_host": "git.eden-emu.dev",
"artifact": "%VERSION%.tar.gz",
"tag": "%VERSION%",
"hash": "cce65a12bf90f4ead43b24a0b95dfad77ac3d9bfbaaf66c55e6701346e7a1e44ca5d2f23f47ee35ee02271eb1082bf1762af207aad9fb236f1c8476812d008ed",
"version": "121125",
"git_version": "230326"
},
"vulkan-headers": {
"repo": "KhronosGroup/Vulkan-Headers",
"package": "VulkanHeaders",
"version": "1.4.317",
"hash": "d2846ea228415772645eea4b52a9efd33e6a563043dd3de059e798be6391a8f0ca089f455ae420ff22574939ed0f48ed7c6ff3d5a9987d5231dbf3b3f89b484b",
"git_version": "1.4.345",
"tag": "v%VERSION%"
},
"vulkan-utility-libraries": {
"repo": "KhronosGroup/Vulkan-Utility-Libraries",
"package": "VulkanUtilityLibraries",
"hash": "114f6b237a6dcba923ccc576befb5dea3f1c9b3a30de7dc741f234a831d1c2d52d8a224afb37dd57dffca67ac0df461eaaab6a5ab5e503b393f91c166680c3e1",
"git_version": "1.4.345",
"tag": "v%VERSION%"
},
"frozen": {
"package": "frozen",
"repo": "serge-sans-paille/frozen",
"sha": "61dce5ae18",
"hash": "b8dfe741c82bc178dfc9749d4ab5a130cee718d9ee7b71d9b547cf5f7f23027ed0152ad250012a8546399fcc1e12187efc68d89d6731256c4d2df7d04eef8d5c"
}
}

21
tools/cpm/common.sh

@ -3,35 +3,20 @@
# SPDX-FileCopyrightText: Copyright 2026 crueter
# SPDX-License-Identifier: LGPL-3.0-or-later
##################################
# CHANGE THESE FOR YOUR PROJECT! #
##################################
# TODO: cache cpmfile defs
# TODO: cache cpmfile defs?
must_install() {
for cmd in "$@"; do
command -v "$cmd" >/dev/null 2>&1 || { echo "-- $cmd must be installed" && exit 1; }
done
}
must_install jq find mktemp tar 7z unzip sha512sum git patch curl xargs
# How many levels to go (3 is 2 subdirs max)
MAXDEPTH=3
# For your project you'll want to change this to define what dirs you have cpmfiles in
# Remember to account for the MAXDEPTH variable!
# Adding ./ before each will help to remove duplicates
CPMFILES=$(find . -maxdepth "$MAXDEPTH" -name cpmfile.json | sort | uniq)
must_install jq find mktemp tar 7z unzip sha512sum git patch curl
# shellcheck disable=SC2016
PACKAGES=$(echo "$CPMFILES" | xargs jq -s 'reduce .[] as $item ({}; . * $item)')
PACKAGES=$(jq -s 'reduce .[] as $item ({}; . * $item)' cpmfile.json)
LIBS=$(echo "$PACKAGES" | jq -j 'keys_unsorted | join(" ")')
export PACKAGES
export CPMFILES
export LIBS
export DIRS
export MAXDEPTH

10
tools/cpm/format.sh

@ -1,9 +1,9 @@
#!/bin/sh -e
# SPDX-FileCopyrightText: Copyright 2025 crueter
# SPDX-FileCopyrightText: Copyright 2026 crueter
# SPDX-License-Identifier: LGPL-3.0-or-later
for file in $CPMFILES; do
jq --indent 4 <"$file" >"$file".new
mv "$file".new "$file"
done
file=cpmfile.json
jq --indent 4 -S <"$file" >"$file".new
mv "$file".new "$file"

2
tools/cpm/migrate.sh

@ -33,7 +33,7 @@ for i in $SUBMODULES; do
'{
($name): {
sha: $sha,
git_version: $ver,
version: $ver,
repo: $repo
} + (if $host != "" then {git_host: $host} else {} end)
}')

2
tools/cpm/package.sh

@ -18,7 +18,7 @@ Commands:
add Add a new package
rm Remove a package
version Change the version of a package
which Find which cpmfile a package is defined in
which Check if a package is defined
download Get the download URL for a package
EOF

1
tools/cpm/package/fetch.sh

@ -81,7 +81,6 @@ ci_package() {
windows-amd64 windows-arm64 \
mingw-amd64 mingw-arm64 \
android-aarch64 android-x86_64 \
solaris-amd64 freebsd-amd64 openbsd-amd64 \
linux-amd64 linux-aarch64 \
macos-universal ios-aarch64; do
echo "-- * platform $platform"

10
tools/cpm/package/rm.sh

@ -9,7 +9,7 @@ usage() {
cat <<EOF
Usage: cpmutil.sh package rm [PACKAGE]...
Delete a package or packages' cpmfile definition(s).
Delete a package or packages' cpmfile definition.
EOF
@ -19,12 +19,12 @@ EOF
[ $# -ge 1 ] || usage
for pkg in "$@"; do
JSON=$("$SCRIPTS"/which.sh "$pkg") || {
"$SCRIPTS"/which.sh "$pkg" || {
echo "!! No cpmfile definition for $pkg"
continue
}
jq --indent 4 "del(.\"$pkg\")" "$JSON" >"$JSON".tmp
mv "$JSON".tmp "$JSON"
echo "-- Removed $pkg from $JSON" || :
jq --indent 4 "del(.\"$pkg\")" cpmfile.json >cpmfile.json.new
mv cpmfile.json.new cpmfile.json
echo "-- Removed $pkg"
done

46
tools/cpm/package/update.sh

@ -82,13 +82,14 @@ for pkg in $packages; do
echo "-- Package $PACKAGE"
# TODO(crueter): Support for Forgejo updates w/ forgejo_token
# Use gh-cli to avoid ratelimits, if available
# TODO(crueter): Support for forgejo_token?
endpoint="/repos/$REPO/tags"
if command -v gh >/dev/null 2>&1; then
TAGS=$(gh api --method GET "$endpoint")
else
elif [ "$GIT_HOST" = github.com ]; then
TAGS=$(curl -sfL "https://api.github.com$endpoint")
else
TAGS=$(curl -sfL "https://$GIT_HOST/api/v1$endpoint")
fi
# filter out some commonly known annoyances
@ -102,7 +103,6 @@ for pkg in $packages; do
filter_out yotta # mbedtls
# ????????????????????????????????
filter_out vksc
# ignore betas/alphas (remove if needed)
@ -110,15 +110,15 @@ for pkg in $packages; do
filter_out beta
filter_out rc
# openssl
# Add package-specific overrides here, e.g. here for fmt:
[ "$PACKAGE" != fmt ] || filter_out v0.11
# Or for OpenSSL:
if [ "$PACKAGE" = openssl ]; then
filter_out rsaref
filter_in "openssl-"
fi
# Add package-specific overrides here, e.g. here for fmt:
[ "$PACKAGE" != fmt ] || filter_out v0.11
LATEST=$(echo "$TAGS" | jq -r '.[0].name')
if [ "$LATEST" = "null" ] ||
@ -127,45 +127,47 @@ for pkg in $packages; do
continue
fi
# TODO: This is identical to version.sh
if [ "$HAS_REPLACE" = "true" ]; then
# this just extracts the tag prefix
VERSION_PREFIX=$(echo "$ORIGINAL_TAG" | cut -d"%" -f1)
# then we strip out the prefix from the new tag, and make that our new git_version
# then we strip out the prefix from the new tag, and make that our new version
if [ -z "$VERSION_PREFIX" ]; then
NEW_GIT_VERSION="$LATEST"
NEW_VERSION="$LATEST"
else
NEW_GIT_VERSION=$(echo "$LATEST" | sed "s/$VERSION_PREFIX//g")
NEW_VERSION=$(echo "$LATEST" | sed "s/$VERSION_PREFIX//g")
fi
else
NEW_GIT_VERSION="$LATEST"
NEW_VERSION="$LATEST"
fi
_commit="$_commit
* $PACKAGE: $GIT_VERSION -> $NEW_GIT_VERSION"
* $PACKAGE: $VERSION -> $NEW_VERSION"
echo "-- * Version $LATEST available, current is $TAG"
if [ "$UPDATE" = "true" ]; then
if [ "$HAS_REPLACE" = "true" ]; then
NEW_JSON=$(echo "$JSON" | jq ".git_version = \"$NEW_GIT_VERSION\"")
JSON=$(echo "$JSON" | jq ".version = \"$NEW_VERSION\"")
else
NEW_JSON=$(echo "$JSON" | jq ".tag = \"$NEW_GIT_VERSION\"")
JSON=$(echo "$JSON" | jq ".tag = \"$NEW_VERSION\"")
fi
"$SCRIPTS"/util/replace.sh "$PACKAGE" "$NEW_JSON"
echo "-- * -- Updating hash"
export UPDATE
QUIET=true "$SCRIPTS"/util/fix-hash.sh "$PACKAGE"
# shellcheck disable=SC1091
. "$SCRIPTS"/vars.sh
HASH=$("$SCRIPTS"/util/url-hash.sh "$DOWNLOAD")
JSON=$(echo "$JSON" | jq ".hash = \"$HASH\"")
"$SCRIPTS"/util/replace.sh "$PACKAGE" "$JSON"
fi
done
if [ "$UPDATE" = "true" ] && [ "$COMMIT" = "true" ] && [ -n "$_commit" ]; then
for file in $CPMFILES; do
git add "$file"
done
git add "cpmfile.json"
git commit -m "Update dependencies
$_commit"
fi

7
tools/cpm/package/util/fix-hash.sh

@ -9,18 +9,13 @@
# re-read json files
# shellcheck disable=SC2016
PACKAGES=$(echo "$CPMFILES" | xargs jq -s 'reduce .[] as $item ({}; . * $item)')
PACKAGES=$(jq -s 'reduce .[] as $item ({}; . * $item)' cpmfile.json)
export PACKAGES
. "$SCRIPTS"/vars.sh
[ "$CI" = null ] || exit 0
[ "$HASH_URL" = null ] || exit 0
[ "$HASH_SUFFIX" = null ] || exit 0
[ "$HASH" != null ] || { echo "-- * Package has no hash specified" && exit 0; }
ACTUAL=$("$SCRIPTS"/util/url-hash.sh "$DOWNLOAD")
if [ "$ACTUAL" != "$HASH" ] && [ "$QUIET" != true ]; then

3
tools/cpm/package/util/interactive.sh

@ -3,6 +3,8 @@
# SPDX-FileCopyrightText: Copyright 2026 crueter
# SPDX-License-Identifier: LGPL-3.0-or-later
# TODO(crueter): Fix this pls
# This reads a single-line input from the user and also gives them
# help if needed.
# $1: The prompt itself, without any trailing spaces or whatever
@ -149,7 +151,6 @@ else
windows-amd64 windows-arm64
mingw-amd64 mingw-arm64
android-aarch64 android-x86_64
solaris-amd64 freebsd-amd64 openbsd-amd64
linux-amd64 linux-aarch64
macos-universal ios-aarch64"

10
tools/cpm/package/util/replace.sh

@ -1,13 +1,11 @@
#!/bin/sh -e
# SPDX-FileCopyrightText: Copyright 2025 crueter
# SPDX-FileCopyrightText: Copyright 2026 crueter
# SPDX-License-Identifier: LGPL-3.0-or-later
# Replace a specified package with a modified json.
FILE=$(echo "$CPMFILES" | xargs grep -l "\"$1\"")
jq --indent 4 --argjson repl "$2" ".\"$1\" *= \$repl" cpmfile.json >cpmfile.json.new
mv cpmfile.json.new cpmfile.json
jq --indent 4 --argjson repl "$2" ".\"$1\" *= \$repl" "$FILE" >"$FILE".new
mv "$FILE".new "$FILE"
echo "-- * -- Updated $FILE"
echo "-- * -- Updated cpmfile.json"

19
tools/cpm/package/vars/url.sh → tools/cpm/package/util/url.sh

@ -1,28 +1,23 @@
#!/bin/sh
#!/bin/sh -e
# SPDX-FileCopyrightText: Copyright 2025 crueter
# SPDX-FileCopyrightText: Copyright 2026 crueter
# SPDX-License-Identifier: LGPL-3.0-or-later
# Required vars: URL, GIT_HOST, REPO, TAG, ARTIFACT, BRANCH, SHA
# Get the download URL for a package
if [ "$URL" != "null" ]; then
DOWNLOAD="$URL"
elif [ "$REPO" != "null" ]; then
GIT_URL="https://$GIT_HOST/$REPO"
if [ "$TAG" != "null" ]; then
if [ "$SHA" != "null" ]; then
DOWNLOAD="${GIT_URL}/archive/${SHA}.tar.gz"
elif [ "$TAG" != "null" ]; then
if [ "$ARTIFACT" != "null" ]; then
DOWNLOAD="${GIT_URL}/releases/download/${TAG}/${ARTIFACT}"
else
DOWNLOAD="${GIT_URL}/archive/refs/tags/${TAG}.tar.gz"
fi
elif [ "$SHA" != "null" ]; then
DOWNLOAD="${GIT_URL}/archive/${SHA}.tar.gz"
else
if [ "$BRANCH" = null ]; then
BRANCH=master
fi
DOWNLOAD="${GIT_URL}/archive/refs/heads/${BRANCH}.tar.gz"
fi
else
echo "!! No repo or URL defined for $PACKAGE_NAME"

76
tools/cpm/package/vars.sh

@ -9,14 +9,16 @@ value() {
echo "$JSON" | jq -r ".$1"
}
[ -n "$PACKAGE" ] || { echo "Package was not specified" && exit 0; }
if [ -z "$JSON" ]; then
[ -n "$PACKAGE" ] || { echo "Package was not specified" && exit 0; }
# shellcheck disable=SC2153
JSON=$(echo "$PACKAGES" | jq -r ".\"$PACKAGE\" | select( . != null )")
# shellcheck disable=SC2153
JSON=$(echo "$PACKAGES" | jq -r ".\"$PACKAGE\" | select( . != null )")
if [ -z "$JSON" ]; then
echo "!! No cpmfile definition for $PACKAGE" >&2
exit 1
if [ -z "$JSON" ]; then
echo "!! No cpmfile definition for $PACKAGE" >&2
exit 1
fi
fi
# unset stuff
@ -31,7 +33,7 @@ export TAG="null"
export ARTIFACT="null"
export SHA="null"
export VERSION="null"
export GIT_VERSION="null"
export MIN_VERSION="null"
export DOWNLOAD="null"
export URL="null"
export KEY="null"
@ -39,9 +41,6 @@ export HASH="null"
export ORIGINAL_TAG="null"
export HAS_REPLACE="null"
export VERSION_REPLACE="null"
export HASH_URL="null"
export HASH_SUFFIX="null"
export HASH_ALGO="null"
########
# Meta #
@ -65,8 +64,12 @@ export GIT_HOST
# CI Package Parsing #
######################
MIN_VERSION=$(value "min_version")
VERSION=$(value "version")
export VERSION
export MIN_VERSION
if [ "$CI" = "true" ]; then
EXT=$(value "extension")
[ "$EXT" != null ] || EXT="tar.zst"
@ -79,7 +82,6 @@ if [ "$CI" = "true" ]; then
export EXT
export NAME
export DISABLED
export VERSION
return 0
fi
@ -91,15 +93,6 @@ fi
TAG=$(value "tag")
ARTIFACT=$(value "artifact")
SHA=$(value "sha")
GIT_VERSION=$(value "git_version")
[ "$GIT_VERSION" != null ] || GIT_VERSION="$VERSION"
if [ "$GIT_VERSION" != null ]; then
VERSION_REPLACE="$GIT_VERSION"
else
VERSION_REPLACE="$VERSION"
fi
if echo "$TAG" | grep -e "%VERSION%" >/dev/null; then
HAS_REPLACE=true
@ -109,30 +102,24 @@ fi
ORIGINAL_TAG="$TAG"
TAG=$(echo "$TAG" | sed "s/%VERSION%/$VERSION_REPLACE/g")
ARTIFACT=$(echo "$ARTIFACT" | sed "s/%VERSION%/$VERSION_REPLACE/g")
TAG=$(echo "$TAG" | sed "s/%VERSION%/$VERSION/g")
ARTIFACT=$(echo "$ARTIFACT" | sed "s/%VERSION%/$VERSION/g")
ARTIFACT=$(echo "$ARTIFACT" | sed "s/%TAG%/$TAG/g")
export TAG
export ARTIFACT
export SHA
export VERSION
export GIT_VERSION
export ORIGINAL_TAG
export HAS_REPLACE
export VERSION_REPLACE
###############
# URL Parsing #
###############
URL=$(value "url")
BRANCH=$(value "branch")
export BRANCH
export URL
. "$SCRIPTS"/vars/url.sh
. "$SCRIPTS"/util/url.sh
export DOWNLOAD
@ -140,9 +127,16 @@ export DOWNLOAD
# Key Parsing #
###############
KEY=$(value "key")
. "$SCRIPTS"/vars/key.sh
if [ "$SHA" != null ]; then
KEY=$(echo "$SHA" | cut -c1-4)
elif [ "$VERSION" != null ]; then
KEY="$VERSION"
elif [ "$TAG" != null ]; then
KEY="$TAG"
else
echo "!! No valid key could be determined for $PACKAGE_NAME. Must define one of: sha, tag, version"
exit 1
fi
export KEY
@ -150,27 +144,11 @@ export KEY
# Hash Parsing #
################
HASH_ALGO=$(value "hash_algo")
[ "$HASH_ALGO" != null ] || HASH_ALGO=sha512
HASH=$(value "hash")
if [ "$HASH" = null ]; then
HASH_SUFFIX="${HASH_ALGO}sum"
HASH_URL=$(value "hash_url")
if [ "$HASH_URL" = null ]; then
HASH_URL="${DOWNLOAD}.${HASH_SUFFIX}"
fi
HASH=$(curl "$HASH_URL" -Ss -L -o -)
else
HASH_URL=null
HASH_SUFFIX=null
echo "!! No hash defined for $PACKAGE_NAME" >&2
fi
export HASH_URL
export HASH_SUFFIX
export HASH
export HASH_ALGO
export JSON

21
tools/cpm/package/vars/key.sh

@ -1,21 +0,0 @@
#!/bin/sh -e
# SPDX-FileCopyrightText: Copyright 2025 crueter
# SPDX-License-Identifier: LGPL-3.0-or-later
if [ "$KEY" = null ]; then
if [ "$SHA" != null ]; then
KEY=$(echo "$SHA" | cut -c1-4)
elif [ "$GIT_VERSION" != null ]; then
KEY="$GIT_VERSION"
elif [ "$TAG" != null ]; then
KEY="$TAG"
elif [ "$VERSION" != null ]; then
KEY="$VERSION"
else
echo "!! No valid key could be determined for $PACKAGE_NAME. Must define one of: key, sha, tag, version, git_version"
exit 1
fi
fi
export KEY

34
tools/cpm/package/version.sh

@ -34,27 +34,29 @@ if [ "$HAS_REPLACE" = "true" ]; then
VERSION_PREFIX=$(echo "$ORIGINAL_TAG" | cut -d"%" -f1)
# then we strip out the prefix from the new tag, and make that our new git_version
if [ -z "$VERSION_PREFIX" ]; then
NEW_GIT_VERSION="$NEW_VERSION"
else
NEW_GIT_VERSION=$(echo "$NEW_VERSION" | sed "s/$VERSION_PREFIX//g")
if [ -n "$VERSION_PREFIX" ]; then
NEW_VERSION=$(echo "$NEW_VERSION" | sed "s/$VERSION_PREFIX//g")
fi
fi
if [ "$SHA" != null ]; then
NEW_JSON=$(echo "$JSON" | jq ".sha = \"$NEW_VERSION\"")
elif [ "$CI" = "true" ]; then
NEW_JSON=$(echo "$JSON" | jq ".version = \"$NEW_VERSION\"")
elif [ "$HAS_REPLACE" = "true" ]; then
NEW_JSON=$(echo "$JSON" | jq ".git_version = \"$NEW_GIT_VERSION\"")
JSON=$(echo "$JSON" | jq ".sha = \"$NEW_VERSION\"")
elif [ "$CI" = "true" ] || [ "$HAS_REPLACE" = "true" ]; then
JSON=$(echo "$JSON" | jq ".version = \"$NEW_VERSION\"")
else
NEW_JSON=$(echo "$JSON" | jq ".tag = \"$NEW_VERSION\"")
JSON=$(echo "$JSON" | jq ".tag = \"$NEW_VERSION\"")
fi
echo "-- * -- Updating $PACKAGE to version $NEW_VERSION"
"$SCRIPTS"/util/replace.sh "$PACKAGE" "$NEW_JSON"
echo "-- * Updating $PACKAGE to version $NEW_VERSION"
[ "$CI" != "true" ] || exit 0
echo "-- * -- Fixing hash"
. "$ROOTDIR"/common.sh
UPDATE=true QUIET=true "$SCRIPTS"/util/fix-hash.sh
# TODO: ci hash thing please
if [ "$CI" != true ]; then
echo "-- * -- Updating hash"
# shellcheck disable=SC1091
. "$SCRIPTS"/vars.sh
HASH=$("$SCRIPTS"/util/url-hash.sh "$DOWNLOAD")
JSON=$(echo "$JSON" | jq ".hash = \"$HASH\"")
fi
"$SCRIPTS"/util/replace.sh "$PACKAGE" "$JSON"

8
tools/cpm/package/which.sh

@ -3,10 +3,6 @@
# SPDX-FileCopyrightText: Copyright 2026 crueter
# SPDX-License-Identifier: LGPL-3.0-or-later
# check which file a package is in
# check if a package is defined
JSON=$(echo "$CPMFILES" | xargs grep -l "\"$1\"")
[ -n "$JSON" ] || { echo "!! No cpmfile definition for $1" >&2 && exit 1; }
echo "$JSON"
echo "$LIBS" | grep "$1" >/dev/null 2>&1

9
tools/cpmutil.sh

@ -25,9 +25,8 @@ General command-line utility for CPMUtil operations.
Commands:
package Run operations on a package or packages
format Format all cpmfiles
format Format cpmfile
update Update CPMUtil and its tooling
ls List all cpmfiles
migrate Convert submodules to a basic cpmfile
Package commands:
@ -37,7 +36,7 @@ Package commands:
add Add a new package
rm Remove a package
version Change the version of a package
which Find which cpmfile a package is defined in
which Check if a package is defined
download Get the download URL for a package
EOF
@ -49,10 +48,6 @@ export ROOTDIR
while :; do
case "$1" in
ls)
echo "$CPMFILES" | tr ' ' '\n'
break
;;
format | update | migrate)
"$SCRIPTS/$1".sh
break

Loading…
Cancel
Save