cmake: fix error on building idf as lib when env IDF_PATH is not set

This commit is contained in:
Renz Christian Bagaporo 2018-11-29 14:51:21 +08:00
parent 759185b16c
commit ba6058ba58
2 changed files with 12 additions and 15 deletions

View file

@ -2,13 +2,20 @@
# Load cmake modules
#
if(NOT IDF_PATH)
set(IDF_PATH $ENV{IDF_PATH})
endif()
get_property(__idf_environment_set GLOBAL PROPERTY __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
"${IDF_PATH}/tools/cmake"
"${IDF_PATH}/tools/cmake/third_party"

View file

@ -2,15 +2,7 @@
#
cmake_minimum_required(VERSION 3.5)
# 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})
include(${CMAKE_CURRENT_LIST_DIR}/idf_functions.cmake)
# Set the path of idf.py.
set(IDFTOOL ${PYTHON} "${IDF_PATH}/tools/idf.py")
@ -24,8 +16,6 @@ endfunction()
function(_project)
endfunction()
include(${IDF_PATH}/tools/cmake/idf_functions.cmake)
macro(project name)
# Bridge existing documented variable names with library namespaced variables in order for old projects to work.