In case this is useful to anyone in the future (including future me):
With ESP IDF v3.2, I had the following in my top-level CMakeLists.txt file:
execute_process(COMMAND "git" "describe" "--match=NeVeRmAtCh" "--always" "--abbrev=14" "--dirty"
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_output
OUTPUT_STRIP_TRAILING_WHITESPACE)
target_compile_definitions(main PUBLIC GIT_COMMIT="${git_output}")
This had the effect of including the option "-DGIT_COMMIT=..." whenever building code within the "main" component (my top-level component where my main() function is, amongst many others). I use this preprocessor definition within the code.
Now I'm migrating the project to ESP IDF v3.3, and I've discovered (above) that "main" isn't a valid target name any more, so I've tried to replace it with ${IDF_PROJECT_EXECUTABLE}, however that doesn't have the same effect - the compile-time definition -DGIT_COMMIT=... is not added to the compiler command line.
I moved this into main/CMakeLists.txt and using ${COMPONENT_TARGET} instead:
Code: Select all
target_compile_definitions(${COMPONENT_TARGET} PUBLIC GIT_COMMIT="${git_output}")
This seems to work and adds the preprocessor definition to the command line.
I'm not sure why it wouldn't work against the ${IDF_PROJECT_EXECUTABLE} target however.