cmake does not honor --log-level in add_jar()

When running cmake on a project which has add_jar() in it, a message unconditionally appears during the jar building:

-- Clean class files from previous build

This message comes from this file (in my installation):


That message line looks like this:

message(STATUS "Clean class files from previous build")

The message appears during the build (ninja) regardless of what “–log-level” I set when running cmake. The file is called from

Modules/UseJava.cmake using ${CAMKE_COMMAND} … -P … ClearClassFiles.cmake.

Setting the CMAKE_MESSAGE_LOG_LEVEL variable also has no effect on that message. As far as I’m concerned, that’s not a necessary message during my build, but I cannot make it go away. Is there a way I can make the recursive cmake call honor the --log-level I’ve specified?


The --log-level and CMAKE_MESSAGE_LOG_LEVEL mechanisms from the top-level CMake configure don’t affect custom commands (such as the ClearClassFiles.cmake script). It doesn’t appear as though there’s a way to influence the logging of that command right now. I’d file an issue to add a way to suppress that message.

Thanks, I have done so

I see CMake Issue 22107, thanks.