CMake,编译过程中不打印目录 [英] CMake , don't print directory when compiling process

查看:118
本文介绍了CMake,编译过程中不打印目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将项目更新为CMake,有一件事令人讨厌。构建源文件时,它会打印保存目标文件的目录。

I recently updated my project to CMake, one thing is annoying. When building source files it prints the directory where object files are saved.

[ 13%] Building CXX object a/CMakeFiles/a.dir/src/A.cpp.o
[ 14%] Building CXX object b/CMakeFiles/b.dir/src/B.cpp.o
[ 15%] Building CXX object c/CMakeFiles/c.dir/src/C.cpp.o

我想这样

[ 13%] Building CXX object A.cpp.o
[ 14%] Building CXX object B.cpp.o
[ 15%] Building CXX object C.cpp.o

我找不到

推荐答案

作为 @ Hugues Moreau评论了这些文本直接编码到CMake中,无法修改。

As @Hugues Moreau commented those texts are directly coded into CMake and can't be modified.

您可以-无需利用其他脚本来解析命令行或输出-
仅通过设置global RULE_MESSAGES 属性设置为 OFF 并添加您自己的 echo 呼叫。

You could - without utilizing another script parsing your command line or output - only suppress the output with setting global RULE_MESSAGES property to OFF and adding your own echo call.

注意:


  1. 它也省略了百分比和颜色信息

  2. 仅适用于 Makefiles 生成器

  1. It omits the percentage and color information also
  2. It works only for Makefiles generators

CMakeLists.txt

cmake_minimum_required(VERSION 2.8)

project(HelloWorld)

if(CMAKE_GENERATOR MATCHES "Makefiles")
    set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
    set(
        CMAKE_CXX_COMPILE_OBJECT 
        "$(CMAKE_COMMAND) -E echo Building <LANGUAGE> object $(@F)" 
        "${CMAKE_CXX_COMPILE_OBJECT}"
    )
endif()    

add_executable(HelloWorld main.cpp)

参考文献

  • GNU Make - Automatic Variables

这篇关于CMake,编译过程中不打印目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆