Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print messages after make done with cmake?

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.

like image 623
Genie Avatar asked Aug 11 '14 09:08

Genie


People also ask

How do I show messages in CMake?

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.

How do I view CMake logs?

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.

What is CMake script?

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.


1 Answers

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.

like image 71
xStan Avatar answered Nov 08 '22 11:11

xStan