Robotics StackExchange | Archived questions

How to output cmake's status message during colcon build?

Hi,

In one of my project, in the cmake, there are several message output, like

if(CUDA_VERBOSE)
  message("CUDA is available!")
  message("CUDA Libs: ${CUDA_LIBRARIES}")
  message("CUDA Headers: ${CUDA_INCLUDE_DIRS}")
endif()

I would like to check the cmake messages during a colcon build.

I tried this build command but failed:

colcon build --packages-select image_projection_based_fusion --event-handlers console_direct+ --cmake-args -DCUDA_VERBOSE:BOOL=ON

--event-handlers console_direct+ does enable some output messages, but they are not cmake message.

So, what's the correnct colcon arguments?

Asked by felixf4xu on 2023-05-13 10:01:28 UTC

Comments

Please see whether #q395456 and #q363112 sufficiently address this.

If they do, please mark yours as a duplicate and close it.

Asked by gvdhoorn on 2023-05-13 10:50:36 UTC

In neither of the answers to the two questions linked above could I find an answer to the OP's question, which was how to get cmake messages to display.

What does work btw are WARNING messages, like so:

message(WARNING "foo message")

But regular status messages do not display for me under colcon.

Asked by Bernd Pfrommer on 2023-07-10 06:04:20 UTC

The OP closed the question, so I assume he got things to work.

However, a quick test shows everything higher than message("some string") (ie: NOTICE) is included in the --event-handlers console_direct+ --cmake-args -DCMAKE_VERBOSE_MAKEFILE=ON output on my system (ie: message(STATUS "some string"), message(WARNING ..) and message(FATAL_ERROR ..) etc).

message("some string") gets routed to stderr by CMake, so they do end up in the Colcon build log, but are not shown in the terminal.

I believe recommended practice would be message(STATUS ..), but that's probably not going to be something many CMake projects do.

Asked by gvdhoorn on 2023-07-10 06:47:54 UTC

message("some string") shows up for me as part of the console_direct+ output when invoking Colcon like:

VERBOSE=1 colcon build --event-handlers console_direct+ --cmake-args -DCMAKE_VERBOSE_MAKEFILE=ON

Note that VERBOSE=1 typically only works for (GNU) Make driven builds.

This was mentioned by @Dirk Thomas in #q363112.

Asked by gvdhoorn on 2023-07-10 06:55:19 UTC

Note also:

message("some string") gets routed to stderr by CMake [..]

and this will cause Colcon to assume your package's build was not (completely) successful. It will not fail or abort the build (that would not be one of Colcon's responsibilities), but it will print a stderr summary at the end of the build.

Something like:

--- stderr: cmake_verbose_test
some string
CMake Warning at CMakeLists.txt:6 (message):
  message(WARNING)
---

Note the some string at the top there.

Asked by gvdhoorn on 2023-07-10 06:58:07 UTC

Answers