[cmake] using cmake -E echo instead of shell echo command (#6175)

The echo command of the host system may have slight variations between
shell built-in echo and the echo command provided by the OS.

Especially the Windows OS echo command is different from practical any
other echo command.

This means that the currently used `COMMAND echo -e "<text>"` does not
work universally.

This commit introduces `etc/cmake/print.cmake` which allow to print a
CMake list where each item is printed on a new line, to get the desired
behavior on the `print-ot-config` target.

Using `cmake -E echo <text>` ensures identical behaviour across
different systems.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Tejlmand Rasmussen
2021-02-16 20:30:01 +01:00
committed by GitHub
parent 8f57637aec
commit 32257403b0
2 changed files with 47 additions and 1 deletions
+5 -1
View File
@@ -194,4 +194,8 @@ endif()
add_subdirectory(tests)
add_custom_target(print-ot-config ALL COMMAND echo -e "$<JOIN:$<TARGET_PROPERTY:ot-config,INTERFACE_COMPILE_DEFINITIONS>,\"\\n\">")
add_custom_target(print-ot-config ALL
COMMAND ${CMAKE_COMMAND}
-DLIST="$<TARGET_PROPERTY:ot-config,INTERFACE_COMPILE_DEFINITIONS>"
-P ${PROJECT_SOURCE_DIR}/etc/cmake/print.cmake
)