Ver Fonte

fix binaries embedding for IDF 3.3

Ivan Grokhotkov há 4 anos atrás
pai
commit
2888863ef1
1 ficheiros alterados com 9 adições e 10 exclusões
  1. 9 10
      examples/esp32_example/main/CMakeLists.txt

+ 9 - 10
examples/esp32_example/main/CMakeLists.txt

@@ -1,23 +1,22 @@
-set(srcs  main.c
-          binaries.c
-          ../../common/example_common.c
-)
-
+set(srcs main.c ../../common/example_common.c)
 set(include_dirs . ../../common)
 set(include_dirs . ../../common)
 
 
 if ("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER "4.0")
 if ("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER "4.0")
     idf_component_register(SRCS ${srcs}
     idf_component_register(SRCS ${srcs}
                            INCLUDE_DIRS ${include_dirs})
                            INCLUDE_DIRS ${include_dirs})
+    set(target ${COMPONENT_LIB})
 else()
 else()
     # remove when dropping IDF 3.3 support
     # remove when dropping IDF 3.3 support
     set(COMPONENT_SRCS ${srcs})
     set(COMPONENT_SRCS ${srcs})
     set(COMPONENT_ADD_INCLUDEDIRS ${include_dirs})
     set(COMPONENT_ADD_INCLUDEDIRS ${include_dirs})
     register_component()
     register_component()
+    set(target ${COMPONENT_TARGET})
 endif()
 endif()
 
 
-set_property(SOURCE binaries.c PROPERTY GENERATED 1)
-
+# Embed binaries into the app.
+# In ESP-IDF this can also be done using EMBED_FILES option of idf_component_register.
+# Here an external tool is used to make file embedding similar with other ports.
 include(${CMAKE_CURRENT_LIST_DIR}/../../common/bin2array.cmake)
 include(${CMAKE_CURRENT_LIST_DIR}/../../common/bin2array.cmake)
-
-create_resources(${CMAKE_CURRENT_LIST_DIR}/../../binaries/Hello-world binaries.c)
-
+create_resources(${CMAKE_CURRENT_LIST_DIR}/../../binaries/Hello-world ${CMAKE_BINARY_DIR}/binaries.c)
+set_property(SOURCE ${CMAKE_BINARY_DIR}/binaries.c PROPERTY GENERATED 1)
+target_sources(${target} PRIVATE ${CMAKE_BINARY_DIR}/binaries.c)