cmake: fix error on building idf as lib when env IDF_PATH is not set
This commit is contained in:
parent
759185b16c
commit
ba6058ba58
2 changed files with 12 additions and 15 deletions
|
@ -2,13 +2,20 @@
|
||||||
# Load cmake modules
|
# Load cmake modules
|
||||||
#
|
#
|
||||||
|
|
||||||
if(NOT IDF_PATH)
|
|
||||||
set(IDF_PATH $ENV{IDF_PATH})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
get_property(__idf_environment_set GLOBAL PROPERTY __IDF_ENVIRONMENT_SET)
|
get_property(__idf_environment_set GLOBAL PROPERTY __IDF_ENVIRONMENT_SET)
|
||||||
|
|
||||||
if(NOT __idf_environment_set)
|
if(NOT __idf_environment_set)
|
||||||
|
|
||||||
|
# Set IDF_PATH, as nothing else will work without this.
|
||||||
|
set(IDF_PATH "$ENV{IDF_PATH}")
|
||||||
|
if(NOT IDF_PATH)
|
||||||
|
# Documentation says you should set IDF_PATH in your environment, but we
|
||||||
|
# can infer it relative to tools/cmake directory if it's not set.
|
||||||
|
get_filename_component(IDF_PATH "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE)
|
||||||
|
endif()
|
||||||
|
file(TO_CMAKE_PATH "${IDF_PATH}" IDF_PATH)
|
||||||
|
set(ENV{IDF_PATH} ${IDF_PATH})
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH
|
set(CMAKE_MODULE_PATH
|
||||||
"${IDF_PATH}/tools/cmake"
|
"${IDF_PATH}/tools/cmake"
|
||||||
"${IDF_PATH}/tools/cmake/third_party"
|
"${IDF_PATH}/tools/cmake/third_party"
|
||||||
|
|
|
@ -2,15 +2,7 @@
|
||||||
#
|
#
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
# Set IDF_PATH, as nothing else will work without this.
|
include(${CMAKE_CURRENT_LIST_DIR}/idf_functions.cmake)
|
||||||
set(IDF_PATH "$ENV{IDF_PATH}")
|
|
||||||
if(NOT IDF_PATH)
|
|
||||||
# Documentation says you should set IDF_PATH in your environment, but we
|
|
||||||
# can infer it relative to tools/cmake directory if it's not set.
|
|
||||||
get_filename_component(IDF_PATH "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE)
|
|
||||||
endif()
|
|
||||||
file(TO_CMAKE_PATH "${IDF_PATH}" IDF_PATH)
|
|
||||||
set(ENV{IDF_PATH} ${IDF_PATH})
|
|
||||||
|
|
||||||
# Set the path of idf.py.
|
# Set the path of idf.py.
|
||||||
set(IDFTOOL ${PYTHON} "${IDF_PATH}/tools/idf.py")
|
set(IDFTOOL ${PYTHON} "${IDF_PATH}/tools/idf.py")
|
||||||
|
@ -24,8 +16,6 @@ endfunction()
|
||||||
function(_project)
|
function(_project)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
include(${IDF_PATH}/tools/cmake/idf_functions.cmake)
|
|
||||||
|
|
||||||
macro(project name)
|
macro(project name)
|
||||||
|
|
||||||
# Bridge existing documented variable names with library namespaced variables in order for old projects to work.
|
# Bridge existing documented variable names with library namespaced variables in order for old projects to work.
|
||||||
|
|
Loading…
Reference in a new issue