cmake: Fix passing PYTHON path via CMake variable if using IDF as library

Closes https://github.com/espressif/esp-idf/issues/6285
This commit is contained in:
Angus Gratton 2021-03-31 17:35:00 +11:00 committed by bot
parent 4ba4b5780e
commit 632796887e
2 changed files with 12 additions and 6 deletions

View File

@ -130,9 +130,11 @@ function(__build_init idf_path)
# Create the build target, to which the ESP-IDF build properties, dependencies are attached to # Create the build target, to which the ESP-IDF build properties, dependencies are attached to
add_library(__idf_build_target STATIC IMPORTED) add_library(__idf_build_target STATIC IMPORTED)
set_default(python "python") # Set the Python path (which may be passed in via -DPYTHON=) and store in a build property
set_default(PYTHON "python")
file(TO_CMAKE_PATH ${PYTHON} PYTHON)
idf_build_set_property(PYTHON ${PYTHON})
idf_build_set_property(PYTHON ${python})
idf_build_set_property(IDF_PATH ${idf_path}) idf_build_set_property(IDF_PATH ${idf_path})
idf_build_set_property(__PREFIX idf) idf_build_set_property(__PREFIX idf)

View File

@ -6,11 +6,15 @@ cmake_minimum_required(VERSION 3.5)
# call. # call.
include(${CMAKE_CURRENT_LIST_DIR}/idf.cmake) include(${CMAKE_CURRENT_LIST_DIR}/idf.cmake)
# legacy variable for compatibility
set(IDFTOOL ${PYTHON} "${IDF_PATH}/tools/idf.py") set(IDFTOOL ${PYTHON} "${IDF_PATH}/tools/idf.py")
# Internally, the Python interpreter is already set to 'python'. Re-set here
# to be absolutely sure. # setting PYTHON variable here for compatibility only, new code should use
set_default(PYTHON "python") # idf_build_get_property(variable PYTHON)
idf_build_set_property(PYTHON ${PYTHON}) idf_build_get_property(PYTHON PYTHON)
if(NOT PYTHON)
message(FATAL_ERROR "Internal error, PYTHON build property not set correctly.")
endif()
# On processing, checking Python required modules can be turned off if it was # On processing, checking Python required modules can be turned off if it was
# already checked externally. # already checked externally.