How to modify the makefile post build: gstrip item to adapt to the Cmake project

I am trying to build my project using Cmake to replace the work of the IDE(S32DS for GHS).

How to modify IDE makefile scripts to adapt to C make syntax?

-gstrip -r=.debug_frame S32K344_DEMO_20.elf
-@echo ’ ’

Script statements are used to address: The GHS toolchain does not generate DWARF Call Frame information that is suitable for unwinding the call stack.

I have already tried the C make statement:

set(CMAKE_STRIP “-gstrip”)
add_custom_command(TARGET ${target_name}.elf POST_BUILD
COMMAND ${CMAKE_STRIP} -r=.debug_frame ${target_name}.elf )

Does anyone have similar experience and can you give me some advice? Thank you very much.

How about this:

The - prefix is a Makefile syntax that won’t work as a straight command in CMake. Then the other change is to use $<TARGET_FILE> instead of hoping that the command is executed in the same directory as the file.