How to configure CMake output

For example, when compiling .c files, I want cmake to simply print

CC    xxx.c

in stdout, for example linux kbuild.

+4
source share
2 answers

CMake output can be configured by suppressing the standard messages generated by CMake and outputting the user message to the script launcher. Add the following code to your external CMakeLists.txt:

set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_SOURCE_DIR}/custom_output.sh")

RULE_MESSAGES OFF . RULE_LAUNCH_COMPILE script custom_output.sh, CMake:

#!/bin/sh

# shell script invoked with the following arguments
# $(CXX) $(CXX_DEFINES) $(CXX_FLAGS) -o OBJECT_FILE -c SOURCE_FILE

# extract parameters
SOURCE_FILE="${@: -1:1}"
OBJECT_FILE="${@: -3:1}"

echo "CC `basename \"$SOURCE_FILE\"`"

# invoke compiler
exec "$@"

script.

, RULE_LAUNCH_LINK script.

+8

CMake, . , sed awk .

+1

Source: https://habr.com/ru/post/1017153/


All Articles