diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -762,6 +762,19 @@ set(LLVM_PROFDATA_FILE "" CACHE FILEPATH "Profiling data file to use when compiling in order to improve runtime performance.") +# Find python before including config-ix, since it needs to be able to search +# for python modules. +if(LLVM_INCLUDE_TESTS) + # Lit test suite requires at least python 3.6 + set(LLVM_MINIMUM_PYTHON_VERSION 3.6) +else() + # FIXME: it is unknown if this is the actual minimum bound + set(LLVM_MINIMUM_PYTHON_VERSION 3.0) +endif() + +find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED + COMPONENTS Interpreter) + # All options referred to from HandleLLVMOptions have to be specified # BEFORE this include, otherwise options will not be correctly set on # first cmake run @@ -808,9 +821,6 @@ include(HandleLLVMOptions) -find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED - COMPONENTS Interpreter) - ###### # Configure all of the various header file fragments LLVM uses which depend on diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -1253,11 +1253,3 @@ append_if(SUPPORTS_FFILE_PREFIX_MAP "-ffile-prefix-map=${source_root}/=${LLVM_SOURCE_PREFIX}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) add_flag_if_supported("-no-canonical-prefixes" NO_CANONICAL_PREFIXES) endif() - -if(LLVM_INCLUDE_TESTS) - # Lit test suite requires at least python 3.6 - set(LLVM_MINIMUM_PYTHON_VERSION 3.6) -else() - # FIXME: it is unknown if this is the actual minimum bound - set(LLVM_MINIMUM_PYTHON_VERSION 3.0) -endif()