summaryrefslogtreecommitdiff
path: root/Meta/CMake/utils.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Meta/CMake/utils.cmake')
-rw-r--r--Meta/CMake/utils.cmake17
1 files changed, 17 insertions, 0 deletions
diff --git a/Meta/CMake/utils.cmake b/Meta/CMake/utils.cmake
index 6783ee1277..9f48a64e1b 100644
--- a/Meta/CMake/utils.cmake
+++ b/Meta/CMake/utils.cmake
@@ -158,3 +158,20 @@ function(link_with_unicode_data target)
target_link_libraries("${target}" LibUnicodeData)
endif()
endfunction()
+
+function(remove_path_if_version_changed version version_file cache_path)
+ set(version_differs YES)
+
+ if (EXISTS "${version_file}")
+ file(STRINGS "${version_file}" active_version)
+ if (version STREQUAL active_version)
+ set(version_differs NO)
+ endif()
+ endif()
+
+ if (version_differs)
+ message(STATUS "Removing outdated ${cache_path} for version ${version}")
+ file(REMOVE_RECURSE "${cache_path}")
+ file(WRITE "${version_file}" "${version}")
+ endif()
+endfunction()