[tools][cmake] fix type handling when generating CMake targets
[Root Cause]
Unexpected macro definition types during `scons --target=cmake`
could trigger a TypeError and abort CMakeLists.txt generation.
[Solution]
Add support for handling different macro definition types.
[Affect Area]
cmake.py
[Test Suggestion]
Run `scons --target=cmake` and verify CMakeLists.txt is generated
successfully with different macro definition formats.