8

This question is just out of curiosity as I noticed that only the last comment block was being printed.

add_custom_command(
 TARGET target_a
 POST_BUILD
 COMMAND command_A_to_do_something
 COMMENT "Comment A"
 COMMAND command_B_to_do_something_else
 COMMENT "Comment B"
)

Only "Comment B" is printed on the console. For this reason, I ended up splitting multiple commands to multiple add_custom_command blocks. Any ideas of how to get all comments printed?

Using CMake v3.5.2

einpoklum
  • 118,144
  • 57
  • 340
  • 684
sunam
  • 181
  • 3
  • 8

1 Answers1

9

I do this with CMake's command line abstraction for echo:

add_custom_command(
  TARGET target_a
  POST_BUILD
  COMMAND command_A_to_do_something
  COMMAND ${CMAKE_COMMAND} -E echo "Comment A"
  COMMAND command_B_to_do_something_else
  COMMAND ${CMAKE_COMMAND} -E echo "Comment B"
)
sunam
  • 181
  • 3
  • 8
Florian
  • 39,996
  • 9
  • 133
  • 149
  • You mean COMMAND instead of COMMENT right? Because COMMENT ${CMAKE_COMMAND} didn't work while the former did. Didn't know about command line abstraction. Thanks. – sunam Feb 09 '17 at 09:57
  • @sunam Ups, copy-and-paste failure from my side. And yes, thanks for the correcting it. – Florian Feb 09 '17 at 10:05