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

asked 2023-05-13 10:01:28 -0500

felixf4xu gravatar image

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?

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by felixf4xu
close date 2023-05-13 20:39:57.020004

Comments

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

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

gvdhoorn gravatar image gvdhoorn  ( 2023-05-13 10:50:36 -0500 )edit

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.

Bernd Pfrommer gravatar image Bernd Pfrommer  ( 2023-07-10 06:04:20 -0500 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2023-07-10 06:47:54 -0500 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2023-07-10 06:55:19 -0500 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2023-07-10 06:58:07 -0500 )edit