[Bf-blender-cvs] [3334ff0e323] master: CMake: warn Linux references old linux_centos7_x86_64 paths

Campbell Barton noreply at git.blender.org
Fri Dec 16 13:06:19 CET 2022


Commit: 3334ff0e32354fe45a2cc4f45aa653f21b39f6c5
Author: Campbell Barton
Date:   Fri Dec 16 23:00:52 2022 +1100
Branches: master
https://developer.blender.org/rB3334ff0e32354fe45a2cc4f45aa653f21b39f6c5

CMake: warn Linux references old linux_centos7_x86_64 paths

When the centos7 library dir is found, warn when the values of cached
variables reference it, listing the variables and their values.

===================================================================

M	CMakeLists.txt
M	build_files/cmake/macros.cmake

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 74bfb23a3a4..c9e0de18913 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2007,6 +2007,24 @@ if(0)
   print_all_vars()
 endif()
 
+set(LIBDIR_STALE)
+
+if(UNIX AND NOT APPLE)
+  # Only search for the path if it's found on the system.
+  if (EXISTS "../lib/linux_centos7_x86_64")
+    set(LIBDIR_STALE "/lib/linux_centos7_x86_64/")
+  endif()
+endif()
+
+if(LIBDIR_STALE)
+  print_cached_vars_containing_value(
+    "${LIBDIR_STALE}"
+    "\nWARNING: found cached references to old library paths!\n"
+    "\nIt is *strongly* recommended to reference updated library paths!\n"
+  )
+endif()
+unset(LIBDIR_STALE)
+
 # Should be the last step of configuration.
 if(POSTCONFIGURE_SCRIPT)
   include(${POSTCONFIGURE_SCRIPT})
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 7064ca93e8b..dc07be70f84 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -1209,6 +1209,43 @@ function(print_all_vars)
   endforeach()
 endfunction()
 
+# Print a list of all cached variables with values containing `contents`.
+function(print_cached_vars_containing_value
+  contents
+  msg_header
+  msg_footer
+  )
+  set(_list_info)
+  set(_found)
+  get_cmake_property(_vars VARIABLES)
+  foreach(_var ${_vars})
+    if (DEFINED CACHE{${_var}})
+      # Skip "_" prefixed variables, these are used for internal book-keeping,
+      # not under user control.
+      string(FIND "${_var}" "_" _found)
+      if(NOT (_found EQUAL 0))
+        string(FIND "${${_var}}" "${contents}" _found)
+        if(NOT (_found EQUAL -1))
+          if(_found)
+            list(APPEND _list_info "${_var}=${${_var}}")
+          endif()
+        endif()
+      endif()
+    endif()
+  endforeach()
+  unset(_var)
+  unset(_vars)
+  unset(_found)
+  if(_list_info)
+    message(${msg_header})
+    foreach(_var ${_list_info})
+      message(" * ${_var}")
+    endforeach()
+    message(${msg_footer})
+  endif()
+  unset(_list_info)
+endfunction()
+
 macro(openmp_delayload
   projectname
   )



More information about the Bf-blender-cvs mailing list