idf_component_register(SRCS "main.c" "uart_handler.c" "communication_handler.c" "client_handler.c" "message_parser.c" "message_builder.c" "message_handler.c" "ota_update.c" INCLUDE_DIRS ".") # Get the short Git commit hash of the current HEAD. # If not in a Git repository or git command fails, it will default to "N/A". execute_process( COMMAND git rev-parse --short HEAD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_COMMIT_HASH_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE GIT_HASH_RESULT ) # Fallback if git is not available or not in a git repo if(GIT_HASH_RESULT_CODE) set(GIT_COMMIT_HASH_SHORT "N/A") endif() # Add the Git hash as a preprocessor definition to your component. # This makes BUILD_GIT_HASH available in your C/C++ source files. target_compile_definitions(${COMPONENT_LIB} PRIVATE BUILD_GIT_HASH="${GIT_COMMIT_HASH_SHORT}" )