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
parent 8ec8f61caa
commit 7a2c126054
2 changed files with 12 additions and 7 deletions

View File

@ -130,9 +130,11 @@ function(__build_init idf_path)
# Must be global so as to be accessible from any subdirectory in custom projects.
add_library(__idf_build_target STATIC IMPORTED GLOBAL)
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(__PREFIX idf)

View File

@ -6,12 +6,15 @@ cmake_minimum_required(VERSION 3.5)
# call.
include(${CMAKE_CURRENT_LIST_DIR}/idf.cmake)
# legacy variable for compatibility
set(IDFTOOL ${PYTHON} "${IDF_PATH}/tools/idf.py")
# Internally, the Python interpreter is already set to 'python'. Re-set here
# to be absolutely sure.
set_default(PYTHON "python")
file(TO_CMAKE_PATH ${PYTHON} PYTHON)
idf_build_set_property(PYTHON ${PYTHON})
# setting PYTHON variable here for compatibility only, new code should use
# idf_build_get_property(variable 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
# already checked externally.