mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-06-26 04:49:30 -04:00
Implement patch keys
Signed-off-by: crueter <crueter@eden-emu.dev>
This commit is contained in:
parent
fd5e4ca409
commit
193efc4b82
3 changed files with 194 additions and 127 deletions
|
|
@ -75,43 +75,45 @@ set(CPM_FILE
|
|||
|
||||
set(CPM_PACKAGES "" CACHE INTERNAL "")
|
||||
|
||||
if(NOT CPM_DONT_UPDATE_MODULE_PATH AND NOT DEFINED CMAKE_FIND_PACKAGE_REDIRECTS_DIR)
|
||||
set(CPM_MODULE_PATH
|
||||
"${CMAKE_BINARY_DIR}/CPM_modules"
|
||||
CACHE INTERNAL ""
|
||||
)
|
||||
# remove old modules
|
||||
file(REMOVE_RECURSE ${CPM_MODULE_PATH})
|
||||
file(MAKE_DIRECTORY ${CPM_MODULE_PATH})
|
||||
# locally added CPM modules should override global packages
|
||||
set(CMAKE_MODULE_PATH "${CPM_MODULE_PATH};${CMAKE_MODULE_PATH}")
|
||||
endif()
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# Create a custom FindXXX.cmake module for a CPM package This prevents `find_package(NAME)` from
|
||||
# finding the system library
|
||||
# compute a hash of all patch file contents
|
||||
# if there are no patches, returns none
|
||||
function(cpm_compute_patch_key patches patch_key_out)
|
||||
if(NOT patches)
|
||||
set("${patch_key_out}" "none" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(combined "")
|
||||
foreach(PATCH ${patches})
|
||||
file(READ "${PATCH}" contents)
|
||||
string(APPEND combined "${contents}")
|
||||
endforeach()
|
||||
|
||||
string(SHA512 key "${combined}")
|
||||
set("${patch_key_out}" "${key}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Create a custom FindXXX.cmake module for a CPM package.
|
||||
# This prevents `find_package(NAME)` from finding the system library
|
||||
function(cpm_create_module_file Name)
|
||||
if(NOT CPM_DONT_UPDATE_MODULE_PATH)
|
||||
if(DEFINED CMAKE_FIND_PACKAGE_REDIRECTS_DIR)
|
||||
# Redirect find_package calls to the CPM package. This is what FetchContent does when you set
|
||||
# OVERRIDE_FIND_PACKAGE. The CMAKE_FIND_PACKAGE_REDIRECTS_DIR works for find_package in CONFIG
|
||||
# mode, unlike the Find${Name}.cmake fallback. CMAKE_FIND_PACKAGE_REDIRECTS_DIR is not defined
|
||||
# in script mode, or in CMake < 3.24.
|
||||
# https://cmake.org/cmake/help/latest/module/FetchContent.html#fetchcontent-find-package-integration-examples
|
||||
string(TOLOWER ${Name} NameLower)
|
||||
file(WRITE ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/${NameLower}-config.cmake
|
||||
"include(\"\${CMAKE_CURRENT_LIST_DIR}/${NameLower}-extra.cmake\" OPTIONAL)\n"
|
||||
"include(\"\${CMAKE_CURRENT_LIST_DIR}/${Name}Extra.cmake\" OPTIONAL)\n"
|
||||
)
|
||||
file(WRITE ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/${NameLower}-config-version.cmake
|
||||
"set(PACKAGE_VERSION_COMPATIBLE TRUE)\n" "set(PACKAGE_VERSION_EXACT TRUE)\n"
|
||||
)
|
||||
else()
|
||||
file(WRITE ${CPM_MODULE_PATH}/Find${Name}.cmake
|
||||
"include(\"${CPM_FILE}\")\n${ARGN}\nset(${Name}_FOUND TRUE)"
|
||||
)
|
||||
endif()
|
||||
# Redirect find_package calls to the CPM package.
|
||||
# This is what FetchContent does when you set
|
||||
# OVERRIDE_FIND_PACKAGE. The CMAKE_FIND_PACKAGE_REDIRECTS_DIR works for
|
||||
# find_package in CONFIG mode, unlike the Find${Name}.cmake fallback.
|
||||
# CMAKE_FIND_PACKAGE_REDIRECTS_DIR is not defined in script mode
|
||||
# https://cmake.org/cmake/help/latest/module/FetchContent.html#fetchcontent-find-package-integration-examples
|
||||
string(TOLOWER ${Name} NameLower)
|
||||
file(WRITE ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/${NameLower}-config.cmake
|
||||
"include(\"\${CMAKE_CURRENT_LIST_DIR}/${NameLower}-extra.cmake\" OPTIONAL)\n"
|
||||
"include(\"\${CMAKE_CURRENT_LIST_DIR}/${Name}Extra.cmake\" OPTIONAL)\n")
|
||||
|
||||
file(WRITE
|
||||
${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/${NameLower}-config-version.cmake
|
||||
"set(PACKAGE_VERSION_COMPATIBLE TRUE)\n"
|
||||
"set(PACKAGE_VERSION_EXACT TRUE)\n")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
|
@ -120,23 +122,15 @@ function(cpm_check_if_package_already_added CPM_ARGS_NAME CPM_ARGS_VERSION)
|
|||
if("${CPM_ARGS_NAME}" IN_LIST CPM_PACKAGES)
|
||||
CPMGetPackageVersion(${CPM_ARGS_NAME} CPM_PACKAGE_VERSION)
|
||||
if("${CPM_PACKAGE_VERSION}" VERSION_LESS "${CPM_ARGS_VERSION}")
|
||||
message(
|
||||
WARNING
|
||||
"${CPM_INDENT} Requires a newer version of ${CPM_ARGS_NAME} (${CPM_ARGS_VERSION}) than currently included (${CPM_PACKAGE_VERSION})."
|
||||
)
|
||||
message(WARNING
|
||||
"${CPM_INDENT} Requires a newer version of ${CPM_ARGS_NAME} (${CPM_ARGS_VERSION}) than currently included (${CPM_PACKAGE_VERSION}).")
|
||||
endif()
|
||||
cpm_get_fetch_properties(${CPM_ARGS_NAME})
|
||||
set(${CPM_ARGS_NAME}_ADDED NO)
|
||||
set(CPM_PACKAGE_ALREADY_ADDED
|
||||
YES
|
||||
PARENT_SCOPE
|
||||
)
|
||||
set(CPM_PACKAGE_ALREADY_ADDED YES PARENT_SCOPE)
|
||||
cpm_export_variables(${CPM_ARGS_NAME})
|
||||
else()
|
||||
set(CPM_PACKAGE_ALREADY_ADDED
|
||||
NO
|
||||
PARENT_SCOPE
|
||||
)
|
||||
set(CPM_PACKAGE_ALREADY_ADDED NO PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
|
@ -151,28 +145,33 @@ function(cpm_add_patches)
|
|||
# Find the patch program.
|
||||
find_program(PATCH_EXECUTABLE patch)
|
||||
if(CMAKE_HOST_WIN32 AND NOT PATCH_EXECUTABLE)
|
||||
# The Windows git executable is distributed with patch.exe. Find the path to the executable, if
|
||||
# it exists, then search `../usr/bin` and `../../usr/bin` for patch.exe.
|
||||
# The Windows git executable is distributed with patch.exe.
|
||||
# Find the path to the executable, if it exists, then search
|
||||
# `../usr/bin` and `../../usr/bin` for patch.exe.
|
||||
find_package(Git QUIET)
|
||||
if(GIT_EXECUTABLE)
|
||||
get_filename_component(extra_search_path ${GIT_EXECUTABLE} DIRECTORY)
|
||||
get_filename_component(extra_search_path_1up ${extra_search_path} DIRECTORY)
|
||||
get_filename_component(extra_search_path_2up ${extra_search_path_1up} DIRECTORY)
|
||||
find_program(
|
||||
PATCH_EXECUTABLE patch HINTS "${extra_search_path_1up}/usr/bin"
|
||||
"${extra_search_path_2up}/usr/bin"
|
||||
)
|
||||
get_filename_component(extra_search_path
|
||||
${GIT_EXECUTABLE} DIRECTORY)
|
||||
get_filename_component(extra_search_path_1up
|
||||
${extra_search_path} DIRECTORY)
|
||||
get_filename_component(extra_search_path_2up
|
||||
${extra_search_path_1up} DIRECTORY)
|
||||
find_program(PATCH_EXECUTABLE patch HINTS
|
||||
"${extra_search_path_1up}/usr/bin"
|
||||
"${extra_search_path_2up}/usr/bin")
|
||||
endif()
|
||||
endif()
|
||||
if(NOT PATCH_EXECUTABLE)
|
||||
message(FATAL_ERROR "Couldn't find `patch` executable to use with PATCHES keyword.")
|
||||
message(FATAL_ERROR
|
||||
"Couldn't find `patch` executable to use with PATCHES keyword.")
|
||||
endif()
|
||||
|
||||
# Ensure each file exists (or error out) and add it to the list.
|
||||
set(patch_args "")
|
||||
set(first_item True)
|
||||
foreach(PATCH_FILE ${ARGN})
|
||||
# Make sure the patch file exists, if we can't find it, try again in the current directory.
|
||||
# Make sure the patch file exists, if we can't find it,
|
||||
# try again in the current directory.
|
||||
if(NOT EXISTS "${PATCH_FILE}")
|
||||
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/${PATCH_FILE}")
|
||||
message(FATAL_ERROR "Couldn't find patch file: '${PATCH_FILE}'")
|
||||
|
|
@ -183,22 +182,20 @@ function(cpm_add_patches)
|
|||
# Convert to absolute path for use with patch file command.
|
||||
get_filename_component(PATCH_FILE "${PATCH_FILE}" ABSOLUTE)
|
||||
|
||||
# The first patch entry must be preceded by "PATCH_COMMAND" while the following items are
|
||||
# preceded by "&&".
|
||||
# The first patch entry must be preceded by "PATCH_COMMAND"
|
||||
# while the following items are preceded by "COMMAND".
|
||||
if(first_item)
|
||||
set(first_item False)
|
||||
list(APPEND patch_args "PATCH_COMMAND")
|
||||
else()
|
||||
list(APPEND patch_args "COMMAND")
|
||||
endif()
|
||||
|
||||
# Add the patch command to the list
|
||||
list(APPEND patch_args "${PATCH_EXECUTABLE}" "-p1" "-i" "${PATCH_FILE}")
|
||||
endforeach()
|
||||
|
||||
set(PATCH_COMMAND
|
||||
${patch_args}
|
||||
PARENT_SCOPE
|
||||
)
|
||||
set(PATCH_COMMAND ${patch_args} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(CPMAddPackage)
|
||||
|
|
@ -216,7 +213,11 @@ function(CPMAddPackage)
|
|||
|
||||
set(multiValueArgs URL OPTIONS PATCHES)
|
||||
|
||||
cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
|
||||
cmake_parse_arguments(CPM_ARGS
|
||||
""
|
||||
"${oneValueArgs}"
|
||||
"${multiValueArgs}"
|
||||
"${ARGN}")
|
||||
|
||||
if(CPM_ARGS_DOWNLOAD_ONLY)
|
||||
set(DOWNLOAD_ONLY ${CPM_ARGS_DOWNLOAD_ONLY})
|
||||
|
|
@ -255,8 +256,8 @@ function(CPMAddPackage)
|
|||
OPTIONS "${CPM_ARGS_OPTIONS}"
|
||||
SOURCE_SUBDIR "${CPM_ARGS_SOURCE_SUBDIR}"
|
||||
DOWNLOAD_ONLY "${DOWNLOAD_ONLY}"
|
||||
FORCE True
|
||||
)
|
||||
FORCE True)
|
||||
|
||||
cpm_export_variables(${CPM_ARGS_NAME})
|
||||
return()
|
||||
endif()
|
||||
|
|
@ -284,11 +285,12 @@ function(CPMAddPackage)
|
|||
set(fetch_source_dir ${CPM_ARGS_SOURCE_DIR})
|
||||
if(NOT IS_ABSOLUTE ${CPM_ARGS_SOURCE_DIR})
|
||||
get_filename_component(
|
||||
fetch_source_dir ${CPM_ARGS_SOURCE_DIR} REALPATH BASE_DIR ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
fetch_source_dir ${CPM_ARGS_SOURCE_DIR}
|
||||
REALPATH BASE_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif()
|
||||
if(NOT EXISTS ${fetch_source_dir})
|
||||
file(REMOVE_RECURSE "${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-subbuild")
|
||||
file(REMOVE_RECURSE
|
||||
"${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-subbuild")
|
||||
endif()
|
||||
else()
|
||||
set(download_directory
|
||||
|
|
@ -297,6 +299,77 @@ function(CPMAddPackage)
|
|||
set(fetch_source_dir ${download_directory})
|
||||
endif()
|
||||
|
||||
# compute expected patch key
|
||||
cpm_compute_patch_key("${CPM_ARGS_PATCHES}" expected_patch_key)
|
||||
set(patch_key_file "${download_directory}/.cpm_patch_key")
|
||||
|
||||
# source is already fetched and verified
|
||||
if(NOT DEFINED CPM_ARGS_SOURCE_DIR AND EXISTS ${download_directory})
|
||||
# read current patch key from stamp
|
||||
if(EXISTS "${patch_key_file}")
|
||||
file(READ "${patch_key_file}" current_patch_key)
|
||||
else()
|
||||
set(current_patch_key "")
|
||||
endif()
|
||||
|
||||
# if the patch key file is missing, either patches have changed or download
|
||||
# failed; in either case refetch
|
||||
if(NOT current_patch_key STREQUAL expected_patch_key)
|
||||
message(DEBUG "${CPM_INDENT} Package ${CPM_ARGS_NAME} missing "
|
||||
"or mismatched patch key, refetching")
|
||||
file(REMOVE_RECURSE "${download_directory}")
|
||||
file(REMOVE_RECURSE
|
||||
"${CMAKE_BINARY_DIR}/CMakeFiles/fc-stamp/${lower_case_name}")
|
||||
else()
|
||||
file(LOCK ${download_directory}/../cmake.lock RELEASE)
|
||||
|
||||
cpm_store_fetch_properties(
|
||||
${CPM_ARGS_NAME} "${download_directory}"
|
||||
"${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-build")
|
||||
|
||||
cpm_get_fetch_properties("${CPM_ARGS_NAME}")
|
||||
|
||||
if(CPM_ARGS_OPTIONS AND NOT DOWNLOAD_ONLY)
|
||||
foreach(OPTION ${CPM_ARGS_OPTIONS})
|
||||
cpm_parse_option("${OPTION}")
|
||||
set(${OPTION_KEY} "${OPTION_VALUE}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(NOT "${DOWNLOAD_ONLY}")
|
||||
cpm_create_module_file(${CPM_ARGS_NAME})
|
||||
endif()
|
||||
|
||||
if(NOT DOWNLOAD_ONLY)
|
||||
set(source_subdir ${download_directory})
|
||||
|
||||
if(DEFINED CPM_ARGS_SOURCE_SUBDIR)
|
||||
set(source_subdir ${source_subdir}/${CPM_ARGS_SOURCE_SUBDIR})
|
||||
endif()
|
||||
|
||||
if(EXISTS ${source_subdir}/CMakeLists.txt)
|
||||
set(addSubdirectoryExtraArgs "")
|
||||
if(${CPM_ARGS_EXCLUDE_FROM_ALL})
|
||||
list(APPEND addSubdirectoryExtraArgs EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
if(CPM_ARGS_SYSTEM)
|
||||
list(APPEND addSubdirectoryExtraArgs SYSTEM)
|
||||
endif()
|
||||
|
||||
add_subdirectory(
|
||||
${source_subdir}
|
||||
${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-build
|
||||
${addSubdirectoryExtraArgs})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(${CPM_ARGS_NAME}_ADDED YES)
|
||||
cpm_export_variables(${CPM_ARGS_NAME})
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(fetchContentDeclareExtraArgs "")
|
||||
if(${CPM_ARGS_EXCLUDE_FROM_ALL})
|
||||
list(APPEND fetchContentDeclareExtraArgs EXCLUDE_FROM_ALL)
|
||||
|
|
@ -307,7 +380,8 @@ function(CPMAddPackage)
|
|||
endif()
|
||||
|
||||
if(DEFINED CPM_ARGS_SOURCE_SUBDIR)
|
||||
list(APPEND fetchContentDeclareExtraArgs SOURCE_SUBDIR ${CPM_ARGS_SOURCE_SUBDIR})
|
||||
list(APPEND fetchContentDeclareExtraArgs
|
||||
SOURCE_SUBDIR ${CPM_ARGS_SOURCE_SUBDIR})
|
||||
endif()
|
||||
|
||||
if(CPM_ARGS_OPTIONS AND NOT DOWNLOAD_ONLY)
|
||||
|
|
@ -327,18 +401,13 @@ function(CPMAddPackage)
|
|||
endif()
|
||||
|
||||
if(NOT DEFINED CPM_ARGS_SOURCE_DIR)
|
||||
if(EXISTS ${download_directory})
|
||||
set(PACKAGE_INFO "${PACKAGE_INFO} at ${download_directory}")
|
||||
else()
|
||||
file(REMOVE_RECURSE ${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-subbuild)
|
||||
set(PACKAGE_INFO "${PACKAGE_INFO} to ${download_directory}")
|
||||
endif()
|
||||
|
||||
file(REMOVE_RECURSE
|
||||
${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-subbuild)
|
||||
file(LOCK ${download_directory}/../cmake.lock)
|
||||
endif()
|
||||
|
||||
if(NOT "${DOWNLOAD_ONLY}")
|
||||
cpm_create_module_file(${CPM_ARGS_NAME} "CPMAddPackage(\"${ARGN}\")")
|
||||
cpm_create_module_file(${CPM_ARGS_NAME})
|
||||
endif()
|
||||
|
||||
FetchContent_Declare(${CPM_ARGS_NAME}
|
||||
|
|
@ -346,8 +415,7 @@ function(CPMAddPackage)
|
|||
${fetchContentURLArgs}
|
||||
${fetchContentPatchArgs}
|
||||
SOURCE_DIR ${fetch_source_dir}
|
||||
DOWNLOAD_NO_PROGRESS TRUE
|
||||
)
|
||||
DOWNLOAD_NO_PROGRESS TRUE)
|
||||
|
||||
if(DOWNLOAD_ONLY)
|
||||
FetchContent_Populate(${CPM_ARGS_NAME}
|
||||
|
|
@ -355,20 +423,26 @@ function(CPMAddPackage)
|
|||
SOURCE_DIR "${fetch_source_dir}"
|
||||
BINARY_DIR "${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-build"
|
||||
SUBBUILD_DIR "${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-subbuild"
|
||||
DOWNLOAD_NO_PROGRESS TRUE
|
||||
)
|
||||
DOWNLOAD_NO_PROGRESS TRUE)
|
||||
else()
|
||||
FetchContent_MakeAvailable(${CPM_ARGS_NAME})
|
||||
endif()
|
||||
|
||||
# Write patch key.
|
||||
if(NOT DEFINED CPM_ARGS_SOURCE_DIR AND EXISTS ${download_directory})
|
||||
file(WRITE "${patch_key_file}" "${expected_patch_key}")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CPM_ARGS_SOURCE_DIR)
|
||||
file(LOCK ${download_directory}/../cmake.lock RELEASE)
|
||||
endif()
|
||||
|
||||
FetchContent_GetProperties(${CPM_ARGS_NAME})
|
||||
cpm_store_fetch_properties(
|
||||
${CPM_ARGS_NAME} ${${lower_case_name}_SOURCE_DIR} ${${lower_case_name}_BINARY_DIR}
|
||||
)
|
||||
${CPM_ARGS_NAME}
|
||||
${${lower_case_name}_SOURCE_DIR}
|
||||
${${lower_case_name}_BINARY_DIR})
|
||||
|
||||
cpm_get_fetch_properties("${CPM_ARGS_NAME}")
|
||||
|
||||
set(${CPM_ARGS_NAME}_ADDED YES)
|
||||
|
|
@ -378,22 +452,10 @@ endfunction()
|
|||
# export variables available to the caller to the
|
||||
# parent scope expects ${CPM_ARGS_NAME} to be set
|
||||
macro(cpm_export_variables name)
|
||||
set(${name}_SOURCE_DIR
|
||||
"${${name}_SOURCE_DIR}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
set(${name}_BINARY_DIR
|
||||
"${${name}_BINARY_DIR}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
set(${name}_ADDED
|
||||
"${${name}_ADDED}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
set(CPM_LAST_PACKAGE_NAME
|
||||
"${name}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
set(${name}_SOURCE_DIR "${${name}_SOURCE_DIR}" PARENT_SCOPE)
|
||||
set(${name}_BINARY_DIR "${${name}_BINARY_DIR}" PARENT_SCOPE)
|
||||
set(${name}_ADDED "${${name}_ADDED}" PARENT_SCOPE)
|
||||
set(CPM_LAST_PACKAGE_NAME "${name}" PARENT_SCOPE)
|
||||
endmacro()
|
||||
|
||||
# registers a package that has been added to CPM
|
||||
|
|
|
|||
|
|
@ -63,8 +63,9 @@ else()
|
|||
endif()
|
||||
|
||||
# Utility stuff
|
||||
function(cpm_utils_message level name message)
|
||||
message(${level} "[CPMUtil] ${name}: ${message}")
|
||||
function(cpm_utils_message level)
|
||||
string(REPLACE ";" " " message "${ARGN}")
|
||||
message(${level} "[CPMUtil] ${message}")
|
||||
endfunction()
|
||||
|
||||
# propagate a variable to parent scope
|
||||
|
|
@ -189,7 +190,7 @@ macro(parse_object object)
|
|||
get_json_element("${object}" git_host git_host "github.com")
|
||||
|
||||
if (NOT version)
|
||||
cpm_utils_message(FATAL_ERROR "${JSON_NAME}" "version is required")
|
||||
cpm_utils_message(FATAL_ERROR "${JSON_NAME}: version is required")
|
||||
endif()
|
||||
|
||||
if(ci)
|
||||
|
|
@ -241,8 +242,9 @@ macro(parse_object object)
|
|||
set(full_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")
|
||||
cpm_utils_message(FATAL_ERROR
|
||||
"${JSON_NAME} specifies patch"
|
||||
"${full_patch} which does not exist")
|
||||
endif()
|
||||
|
||||
list(APPEND patches "${full_patch}")
|
||||
|
|
@ -294,20 +296,18 @@ function(AddJsonPackage)
|
|||
endif()
|
||||
|
||||
if(NOT DEFINED CPMFILE_CONTENT)
|
||||
cpm_utils_message(FATAL_ERROR ${name}
|
||||
"No cpmfile present")
|
||||
return()
|
||||
cpm_utils_message(FATAL_ERROR "${name}: No cpmfile present")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED JSON_NAME)
|
||||
cpm_utils_message(FATAL_ERROR "json package" "No name specified")
|
||||
cpm_utils_message(FATAL_ERROR "AddJsonPackage: No name specified")
|
||||
endif()
|
||||
|
||||
string(JSON object ERROR_VARIABLE
|
||||
err GET "${CPMFILE_CONTENT}" "${JSON_NAME}")
|
||||
|
||||
if(err)
|
||||
cpm_utils_message(FATAL_ERROR ${JSON_NAME} "Not found in cpmfile")
|
||||
cpm_utils_message(FATAL_ERROR "${JSON_NAME} not found in cpmfile")
|
||||
endif()
|
||||
|
||||
parse_object(${object})
|
||||
|
|
@ -402,11 +402,11 @@ function(AddPackage)
|
|||
"${ARGN}")
|
||||
|
||||
if(NOT DEFINED PKG_ARGS_NAME)
|
||||
cpm_utils_message(FATAL_ERROR "AddPackage" "NAME is required")
|
||||
cpm_utils_message(FATAL_ERROR "AddPackage: NAME is required")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED PKG_ARGS_VERSION)
|
||||
cpm_utils_message(FATAL_ERROR "${PKG_ARGS_NAME}" "VERSION is required")
|
||||
cpm_utils_message(FATAL_ERROR "${PKG_ARGS_NAME}: VERSION is required")
|
||||
endif()
|
||||
|
||||
set(${PKG_ARGS_NAME}_CUSTOM_DIR "" CACHE STRING
|
||||
|
|
@ -448,11 +448,11 @@ function(AddPackage)
|
|||
endif()
|
||||
endif()
|
||||
else()
|
||||
cpm_utils_message(FATAL_ERROR ${PKG_ARGS_NAME}
|
||||
"No URL or repository defined")
|
||||
cpm_utils_message(FATAL_ERROR
|
||||
"${PKG_ARGS_NAME}: No URL or repository defined")
|
||||
endif()
|
||||
|
||||
cpm_utils_message(DEBUG ${PKG_ARGS_NAME} "Download URL is ${pkg_url}")
|
||||
cpm_utils_message(DEBUG "${PKG_ARGS_NAME} download URL is ${pkg_url}")
|
||||
|
||||
# TODO: maybe singular version/ref that detects sha/tag?
|
||||
if(DEFINED PKG_ARGS_SHA)
|
||||
|
|
@ -464,8 +464,7 @@ function(AddPackage)
|
|||
if(DEFINED PKG_ARGS_HASH)
|
||||
set(pkg_hash "SHA512=${PKG_ARGS_HASH}")
|
||||
else()
|
||||
cpm_utils_message(FATAL_ERROR ${PKG_ARGS_NAME}
|
||||
"No hash defined")
|
||||
cpm_utils_message(FATAL_ERROR "${PKG_ARGS_NAME}: No hash defined")
|
||||
endif()
|
||||
|
||||
#[[
|
||||
|
|
@ -547,18 +546,22 @@ function(AddPackage)
|
|||
if (PKG_ARGS_PATCHES)
|
||||
list(APPEND EXTRA_ARGS PATCHES "${PKG_ARGS_PATCHES}")
|
||||
endif()
|
||||
|
||||
if (PKG_ARGS_OPTIONS)
|
||||
list(APPEND EXTRA_ARGS OPTIONS "${PKG_ARGS_OPTIONS}")
|
||||
endif()
|
||||
|
||||
if (PKG_ARGS_SOURCE_SUBDIR)
|
||||
list(APPEND EXTRA_ARGS SOURCE_SUBDIR "${PKG_ARGS_SOURCE_SUBDIR}")
|
||||
endif()
|
||||
|
||||
if (PKG_ARGS_DOWNLOAD_ONLY OR PKG_ARGS_MODULE_PATH)
|
||||
list(APPEND EXTRA_ARGS DOWNLOAD_ONLY ON)
|
||||
endif()
|
||||
|
||||
message(STATUS
|
||||
"[CPMUtil] Using bundled package ${PKG_ARGS_NAME}@${PKG_ARGS_VERSION} (${pkg_key})")
|
||||
cpm_utils_message(STATUS
|
||||
"Using bundled package"
|
||||
"${PKG_ARGS_NAME}@${PKG_ARGS_VERSION} (${pkg_key})")
|
||||
|
||||
CPMAddPackage(
|
||||
NAME ${PKG_ARGS_NAME}
|
||||
|
|
@ -612,18 +615,20 @@ function(AddCIPackage)
|
|||
"${multiValueArgs}"
|
||||
${ARGN})
|
||||
|
||||
# TODO: use cpm_utils_message
|
||||
if(NOT DEFINED PKG_ARGS_VERSION)
|
||||
message(FATAL_ERROR "[CPMUtil] VERSION is required")
|
||||
cpm_utils_message(FATAL_ERROR "VERSION is required")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED PKG_ARGS_NAME)
|
||||
message(FATAL_ERROR "[CPMUtil] NAME is required")
|
||||
cpm_utils_message(FATAL_ERROR "NAME is required")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED PKG_ARGS_REPO)
|
||||
message(FATAL_ERROR "[CPMUtil] REPO is required")
|
||||
cpm_utils_message(FATAL_ERROR "REPO is required")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED PKG_ARGS_PACKAGE)
|
||||
message(FATAL_ERROR "[CPMUtil] PACKAGE is required")
|
||||
cpm_utils_message(FATAL_ERROR "PACKAGE is required")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED PKG_ARGS_CMAKE_FILENAME)
|
||||
|
|
@ -674,7 +679,7 @@ function(AddCIPackage)
|
|||
elseif(APPLE)
|
||||
set(platname macos)
|
||||
else()
|
||||
cpm_utils_message(WARNING ${PKG_ARGS_NAME}
|
||||
cpm_utils_message(WARNING
|
||||
"Unsupported platform ${CMAKE_SYSTEM_NAME} for CI packages")
|
||||
endif()
|
||||
|
||||
|
|
@ -689,7 +694,7 @@ function(AddCIPackage)
|
|||
elseif(ANDROID AND CPMUTIL_AMD64)
|
||||
set(archname x86_64)
|
||||
else()
|
||||
cpm_utils_message(WARNING ${PKG_ARGS_NAME}
|
||||
cpm_utils_message(WARNING
|
||||
"Unsupported platform/arch combo for CI packages")
|
||||
endif()
|
||||
|
||||
|
|
@ -707,7 +712,7 @@ function(AddCIPackage)
|
|||
endif()
|
||||
|
||||
# download sha512sum file
|
||||
# TODO:
|
||||
# TODO: CI pkgs
|
||||
set(sha512sum_url
|
||||
"https://${ARTIFACT_GIT_HOST}/${ARTIFACT_REPO}/releases/download/v${ARTIFACT_VERSION}/${ARTIFACT}.sha512sum")
|
||||
set(sha512sum_file
|
||||
|
|
|
|||
|
|
@ -223,6 +223,6 @@ jq --arg key "$PKG" --argjson new "$JSON" \
|
|||
'.[$key] = $new' "cpmfile.json" --indent 4 >"cpmfile.json.tmp" &&
|
||||
mv "cpmfile.json.tmp" cpmfile.json
|
||||
|
||||
"$SCRIPTS"/format.sh
|
||||
"$SCRIPTS"/../format.sh
|
||||
|
||||
echo "Added package $PKG to cpmfile.json. Include it in your project with AddJsonPackage($PKG)"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue