mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-01 03:34:32 +02:00
cmake: allow embedding to depend on a target
This commit is contained in:
@@ -830,6 +830,24 @@ Place this line after the ``project()`` line in your project CMakeLists.txt file
|
|||||||
|
|
||||||
For an example of using this technique, see :example:`protocols/https_request` - the certificate file contents are loaded from the text .pem file at compile time.
|
For an example of using this technique, see :example:`protocols/https_request` - the certificate file contents are loaded from the text .pem file at compile time.
|
||||||
|
|
||||||
|
|
||||||
|
.. highlight:: cmake
|
||||||
|
|
||||||
|
It is also possible embed a generated file::
|
||||||
|
|
||||||
|
add_custom_command(OUTPUT my_processed_file.bin
|
||||||
|
COMMAND my_process_file_cmd my_unprocessed_file.bin)
|
||||||
|
target_add_binary_data(my_target "my_processed_file.bin" BINARY)
|
||||||
|
|
||||||
|
In the example above, ``my_processed_file.bin`` is generated from ``my_unprocessed_file.bin`` through some command ``my_process_file_cmd``, then embedded into the target.
|
||||||
|
|
||||||
|
To specify a dependence on a target, use the ``DEPENDS`` argument::
|
||||||
|
|
||||||
|
add_custom_target(my_process COMMAND ...)
|
||||||
|
target_add_binary_data(my_target "my_embed_file.bin" BINARY DEPENDS my_process)
|
||||||
|
|
||||||
|
The ``DEPENDS`` argument to ``target_add_binary_data`` ensures that the target executes first.
|
||||||
|
|
||||||
Code and Data Placements
|
Code and Data Placements
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
|
@@ -77,7 +77,7 @@ endfunction()
|
|||||||
# by converting it to a generated source file which is then compiled
|
# by converting it to a generated source file which is then compiled
|
||||||
# to a binary object as part of the build
|
# to a binary object as part of the build
|
||||||
function(target_add_binary_data target embed_file embed_type)
|
function(target_add_binary_data target embed_file embed_type)
|
||||||
cmake_parse_arguments(_ "" "RENAME_TO" "" ${ARGN})
|
cmake_parse_arguments(_ "" "RENAME_TO" "DEPENDS" ${ARGN})
|
||||||
idf_build_get_property(build_dir BUILD_DIR)
|
idf_build_get_property(build_dir BUILD_DIR)
|
||||||
idf_build_get_property(idf_path IDF_PATH)
|
idf_build_get_property(idf_path IDF_PATH)
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ function(target_add_binary_data target embed_file embed_type)
|
|||||||
-D "FILE_TYPE=${embed_type}"
|
-D "FILE_TYPE=${embed_type}"
|
||||||
-P "${idf_path}/tools/cmake/scripts/data_file_embed_asm.cmake"
|
-P "${idf_path}/tools/cmake/scripts/data_file_embed_asm.cmake"
|
||||||
MAIN_DEPENDENCY "${embed_file}"
|
MAIN_DEPENDENCY "${embed_file}"
|
||||||
DEPENDS "${idf_path}/tools/cmake/scripts/data_file_embed_asm.cmake"
|
DEPENDS "${idf_path}/tools/cmake/scripts/data_file_embed_asm.cmake" ${__DEPENDS}
|
||||||
WORKING_DIRECTORY "${build_dir}"
|
WORKING_DIRECTORY "${build_dir}"
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user