]> granicus.if.org Git - esp-idf/commitdiff
cmake: fix error on building idf as lib when env IDF_PATH is not set
authorRenz Christian Bagaporo <renz@espressif.com>
Thu, 29 Nov 2018 06:51:21 +0000 (14:51 +0800)
committerRenz Christian Bagaporo <renz@espressif.com>
Thu, 29 Nov 2018 07:40:16 +0000 (15:40 +0800)
tools/cmake/idf_functions.cmake
tools/cmake/project.cmake

index 65ba66351e72029c5bf1691fd731dc8091460fdc..5cf0f18ddd312224f0906c5c30e852f942af9b60 100644 (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"
index e2aa7c19fa8558c6095488d76c730bfc1eafb845..04459a1e83bab5a039efb9cc4635cda0d0d11b99 100644 (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.