aboutsummaryrefslogtreecommitdiff
path: root/cmake/scripts
diff options
context:
space:
mode:
authorfuzzard <fuzzard@kodi.tv>2022-06-28 13:36:51 +1000
committerfuzzard <fuzzard@kodi.tv>2022-09-28 14:17:10 +1000
commit98bd7aea2103717fc48b4a96bd47f3ae9f52a001 (patch)
tree9504477906151e65f20ecbd564374f830fbc7575 /cmake/scripts
parent9bb4857d56890557e7df8b028b68e00850231839 (diff)
[cmake] modulehelper function to get only version from a specific VERSION file
The use of this is to allow a find module to get a version of a dependency from a VERSION file without smashing the find module SETUP_BUILD_VARS variables to allow us to provide a version to a find_package call of the dependency
Diffstat (limited to 'cmake/scripts')
-rw-r--r--cmake/scripts/common/ModuleHelpers.cmake24
1 files changed, 24 insertions, 0 deletions
diff --git a/cmake/scripts/common/ModuleHelpers.cmake b/cmake/scripts/common/ModuleHelpers.cmake
index 472cdbd92b..e9657cea1e 100644
--- a/cmake/scripts/common/ModuleHelpers.cmake
+++ b/cmake/scripts/common/ModuleHelpers.cmake
@@ -67,6 +67,30 @@ function(get_versionfile_data)
endif()
endfunction()
+# Parse and set Version from VERSION dependency file
+# Used for retrieving version numbers for dependency libs to allow setting
+# a required version for find_package call
+# On return:
+# LIB_MODULENAME_VER will be set to parent scope (eg LIB_FMT_VER)
+function(get_libversion_data module libtype)
+
+ # Dependency path
+ set(LIB_MODULE_PATH "${CMAKE_SOURCE_DIR}/tools/depends/${libtype}/${module}")
+ string(TOUPPER ${module} MOD_UPPER)
+
+ if(NOT EXISTS "${LIB_MODULE_PATH}/${MOD_UPPER}-VERSION")
+ MESSAGE(FATAL_ERROR "${MOD_UPPER}-VERSION does not exist at ${LIB_MODULE_PATH}.")
+ else()
+ set(${MOD_UPPER}_FILE "${LIB_MODULE_PATH}/${MOD_UPPER}-VERSION")
+ endif()
+
+ file(STRINGS ${${MOD_UPPER}_FILE} ${MOD_UPPER}_VER REGEX "^[ \t]*VERSION=")
+
+ string(REGEX REPLACE ".*VERSION=([^ \t]*).*" "\\1" ${MOD_UPPER}_VER "${${MOD_UPPER}_VER}")
+
+ set(LIB_${MOD_UPPER}_VER ${${MOD_UPPER}_VER} PARENT_SCOPE)
+endfunction()
+
# Function to loop through list of patch files (full path)
# Sets to a PATCH_COMMAND variable and set to parent scope (caller)
# Used to test windows line endings and set appropriate patch commands