I'm trying to print messages after building process done using CMake.
I just want to inform the user after make
command is done without any error.
How can I do it? I tried add_custom_target()
but I cannot choose when to run.
Also, I tried add_custom_command()
, again it doesn't give me the right result.
Any idea?
Thank you for your idea in advance.
The CMake command-line tool displays STATUS messages on stdout and all other message types on stderr. The CMake GUI displays all messages in its log area. The interactive dialogs (ccmake and CMakeSetup) show STATUS messages one at a time on a status line and other messages in interactive pop-up boxes.
Check the log file Open the VS Code command pallette and run the CMake: Open the CMake Tools log file command to view this log file. This file is user-local, not workspace-local. This file includes all log entries since the extension was installed and may be very large.
A CMake script defines targets using the add_executable , add_library or add_custom_target commands. Once a target is created, it has properties that you can manipulate using the get_property and set_property commands. Unlike variables, targets are visible in every scope, even if they were defined in a subdirectory.
You could, indeed, do the following:
add_custom_target( FinalMessage ALL
${CMAKE_COMMAND} -E cmake_echo_color --cyan "Compilation is over!"
COMMENT "Final Message" )
add_dependencies( FinalMessage ${ALL_TARGETS} )
That custom target depending on the list of all the targets you previously defined, you make sure it will be run last.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With