[cmake] CPMUtil: formatting, git_host, new repos, more system deps, libusb (#392)
I promise I'm a UI developer - mbedtls can now be used as a system package - zycore can now be used as a system package - cleaned up dynarmic externals - fixed libusb incorrectly showing as bundled - add version/tag formatting to JSON - add custom GIT_HOST option for packages - moved some of my repos to my new git - slightly better version identification - combined VUL/VH since they are codependent (using my combo vendor) - fix cpmfile inclusion - remove libusb submodule This PR succeeds #383 since it includes it Co-authored-by: SDK Chan <sdkchan@eden-emu.dev> Reviewed-on: #392 Co-authored-by: crueter <crueter@crueter.xyz> Co-committed-by: crueter <crueter@crueter.xyz>
This commit is contained in:
parent
ecc99ce9ab
commit
428f136a75
39 changed files with 921 additions and 904 deletions
|
@ -11,10 +11,11 @@
|
|||
# Future crueter: Wow this was a lie and a half, at this point I might as well make my own CPN
|
||||
# haha just kidding... unless?
|
||||
|
||||
# TODO(crueter): Remember to get more than 6 hours of sleep whenever making giant cmake changes
|
||||
if (MSVC OR ANDROID)
|
||||
set(BUNDLED_DEFAULT OFF)
|
||||
else()
|
||||
set(BUNDLED_DEFAULT ON)
|
||||
else()
|
||||
set(BUNDLED_DEFAULT OFF)
|
||||
endif()
|
||||
|
||||
option(CPMUTIL_FORCE_BUNDLED
|
||||
|
@ -26,8 +27,7 @@ option(CPMUTIL_FORCE_SYSTEM
|
|||
cmake_minimum_required(VERSION 3.22)
|
||||
include(CPM)
|
||||
|
||||
# TODO(crueter): Better solution for separate cpmfiles e.g. per-directory
|
||||
set(CPMUTIL_JSON_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cpmfile.json" CACHE STRING "Location of cpmfile.json")
|
||||
set(CPMUTIL_JSON_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cpmfile.json")
|
||||
|
||||
if (EXISTS ${CPMUTIL_JSON_FILE})
|
||||
file(READ ${CPMUTIL_JSON_FILE} CPMFILE_CONTENT)
|
||||
|
@ -148,11 +148,32 @@ function(AddJsonPackage)
|
|||
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 "")
|
||||
get_json_element("${object}" raw_patches patches "")
|
||||
|
||||
# okay here comes the fun part: REPLACEMENTS!
|
||||
# first: tag gets %VERSION% replaced if applicable, with either git_version (preferred) or 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})
|
||||
endif()
|
||||
|
||||
if (artifact)
|
||||
string(REPLACE "%VERSION%" "${version_replace}" artifact ${artifact})
|
||||
string(REPLACE "%TAG%" "${tag}" artifact ${artifact})
|
||||
endif()
|
||||
|
||||
# format patchdir
|
||||
if (raw_patches)
|
||||
math(EXPR range "${raw_patches_LENGTH} - 1")
|
||||
|
@ -201,6 +222,8 @@ function(AddJsonPackage)
|
|||
SOURCE_SUBDIR "${source_subdir}"
|
||||
|
||||
GIT_VERSION ${git_version}
|
||||
GIT_HOST ${git_host}
|
||||
|
||||
ARTIFACT ${artifact}
|
||||
TAG ${tag}
|
||||
)
|
||||
|
@ -240,6 +263,7 @@ function(AddPackage)
|
|||
NAME
|
||||
VERSION
|
||||
GIT_VERSION
|
||||
GIT_HOST
|
||||
|
||||
REPO
|
||||
TAG
|
||||
|
@ -272,11 +296,17 @@ function(AddPackage)
|
|||
option(${PKG_ARGS_NAME}_FORCE_SYSTEM "Force the system package for ${PKG_ARGS_NAME}")
|
||||
option(${PKG_ARGS_NAME}_FORCE_BUNDLED "Force the bundled package for ${PKG_ARGS_NAME}")
|
||||
|
||||
if (NOT DEFINED PKG_ARGS_GIT_HOST)
|
||||
set(git_host github.com)
|
||||
else()
|
||||
set(git_host ${PKG_ARGS_GIT_HOST})
|
||||
endif()
|
||||
|
||||
if (DEFINED PKG_ARGS_URL)
|
||||
set(pkg_url ${PKG_ARGS_URL})
|
||||
|
||||
if (DEFINED PKG_ARGS_REPO)
|
||||
set(pkg_git_url https://github.com/${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})
|
||||
|
@ -285,7 +315,7 @@ function(AddPackage)
|
|||
endif()
|
||||
endif()
|
||||
elseif (DEFINED PKG_ARGS_REPO)
|
||||
set(pkg_git_url https://github.com/${PKG_ARGS_REPO})
|
||||
set(pkg_git_url https://${git_host}/${PKG_ARGS_REPO})
|
||||
|
||||
if (DEFINED PKG_ARGS_TAG)
|
||||
set(pkg_key ${PKG_ARGS_TAG})
|
||||
|
@ -316,25 +346,23 @@ function(AddPackage)
|
|||
|
||||
cpm_utils_message(STATUS ${PKG_ARGS_NAME} "Download URL is ${pkg_url}")
|
||||
|
||||
if (DEFINED PKG_ARGS_GIT_VERSION)
|
||||
set(git_version ${PKG_ARGS_GIT_VERSION})
|
||||
elseif(DEFINED PKG_ARGS_VERSION)
|
||||
set(git_version ${PKG_ARGS_VERSION})
|
||||
endif()
|
||||
|
||||
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 git_version)
|
||||
set(pkg_key ${git_version})
|
||||
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")
|
||||
|
@ -445,12 +473,15 @@ function(AddPackage)
|
|||
if (DEFINED PKG_ARGS_SHA)
|
||||
set_property(GLOBAL APPEND PROPERTY CPM_PACKAGE_SHAS
|
||||
${PKG_ARGS_SHA})
|
||||
elseif(DEFINED git_version)
|
||||
set_property(GLOBAL APPEND PROPERTY CPM_PACKAGE_SHAS
|
||||
${git_version})
|
||||
elseif (DEFINED PKG_ARGS_GIT_VERSION)
|
||||
set_property(GLOBAL APPEND PROPERTY CPM_PACKAGE_SHAS
|
||||
${PKG_ARGS_GIT_VERSION})
|
||||
elseif (DEFINED PKG_ARGS_TAG)
|
||||
set_property(GLOBAL APPEND PROPERTY CPM_PACKAGE_SHAS
|
||||
${PKG_ARGS_TAG})
|
||||
elseif(DEFINED PKG_ARGS_VERSION)
|
||||
set_property(GLOBAL APPEND PROPERTY CPM_PACKAGE_SHAS
|
||||
${PKG_ARGS_VERSION})
|
||||
else()
|
||||
cpm_utils_message(WARNING ${PKG_ARGS_NAME}
|
||||
"Package has no specified sha, tag, or version")
|
||||
|
@ -495,6 +526,7 @@ function(add_ci_package key)
|
|||
set(ARTIFACT_DIR ${${ARTIFACT_PACKAGE}_SOURCE_DIR} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# TODO(crueter): we could do an AddMultiArchPackage, multiplatformpackage?
|
||||
# name is the artifact name, package is for find_package override
|
||||
function(AddCIPackage)
|
||||
set(oneValueArgs
|
||||
|
|
17
CMakeModules/Findmbedtls.cmake
Normal file
17
CMakeModules/Findmbedtls.cmake
Normal file
|
@ -0,0 +1,17 @@
|
|||
# SPDX-FileCopyrightText: 2025 Eden Emulator Project
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_search_module(mbedtls QUIET IMPORTED_TARGET mbedtls)
|
||||
find_package_handle_standard_args(mbedtls
|
||||
REQUIRED_VARS mbedtls_LINK_LIBRARIES
|
||||
VERSION_VAR mbedtls_VERSION
|
||||
)
|
||||
|
||||
pkg_search_module(mbedcrypto QUIET IMPORTED_TARGET mbedcrypto)
|
||||
find_package_handle_standard_args(mbedcrypto
|
||||
REQUIRED_VARS mbedcrypto_LINK_LIBRARIES
|
||||
VERSION_VAR mbedcrypto_VERSION
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue