aboutsummaryrefslogtreecommitdiff
path: root/cmake/scripts/common/ModuleHelpers.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/scripts/common/ModuleHelpers.cmake')
-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