[PATCH] D61402: [CMake] Detecting python modules should be cached

Chris Bieneman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 1 14:24:11 PDT 2019


beanz created this revision.
beanz added reviewers: phosek, smeenai, compnerd.
Herald added a subscriber: mgorny.
Herald added a project: LLVM.

This requres exec-ing python, which in a trace I ran of the CMake re-configure time took ~2% of the reconfigure time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61402

Files:
  llvm/cmake/config-ix.cmake


Index: llvm/cmake/config-ix.cmake
===================================================================
--- llvm/cmake/config-ix.cmake
+++ llvm/cmake/config-ix.cmake
@@ -606,16 +606,19 @@
   string(REPLACE "." "_" module_name ${module})
   string(TOUPPER ${module_name} module_upper)
   set(FOUND_VAR PY_${module_upper}_FOUND)
+  if (DEFINED ${FOUND_VAR})
+    return()
+  endif()
 
   execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" "import ${module}"
     RESULT_VARIABLE status
     ERROR_QUIET)
 
   if(status)
-    set(${FOUND_VAR} 0 PARENT_SCOPE)
+    set(${FOUND_VAR} OFF CACHE BOOL "Failed to find python module '${module}'")
     message(STATUS "Could NOT find Python module ${module}")
   else()
-    set(${FOUND_VAR} 1 PARENT_SCOPE)
+  set(${FOUND_VAR} ON CACHE BOOL "Found python module '${module}'")
     message(STATUS "Found Python module ${module}")
   endif()
 endfunction()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61402.197640.patch
Type: text/x-patch
Size: 894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190501/ff4afa75/attachment.bin>


More information about the llvm-commits mailing list