llvm.org GIT mirror llvm / 83eff7a
[CMake] Detecting python modules should be cached Summary: This requres exec-ing python, which in a trace I ran of the CMake re-configure time took ~2% of the reconfigure time. Reviewers: phosek, smeenai, compnerd Subscribers: mgorny, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61402 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360196 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Bieneman 5 months ago
1 changed file(s) with 5 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
605605 string(REPLACE "." "_" module_name ${module})
606606 string(TOUPPER ${module_name} module_upper)
607607 set(FOUND_VAR PY_${module_upper}_FOUND)
608 if (DEFINED ${FOUND_VAR})
609 return()
610 endif()
608611
609612 execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" "import ${module}"
610613 RESULT_VARIABLE status
611614 ERROR_QUIET)
612615
613616 if(status)
614 set(${FOUND_VAR} 0 PARENT_SCOPE)
617 set(${FOUND_VAR} OFF CACHE BOOL "Failed to find python module '${module}'")
615618 message(STATUS "Could NOT find Python module ${module}")
616619 else()
617 set(${FOUND_VAR} 1 PARENT_SCOPE)
620 set(${FOUND_VAR} ON CACHE BOOL "Found python module '${module}'")
618621 message(STATUS "Found Python module ${module}")
619622 endif()
620623 endfunction()