我正在使用CMake构建工具模式来构建自定义目标。自定义目标调用我感兴趣的输出命令(例如,foo
)。
但在打印foo
的输出之前,CMake还打印了几行我不感兴趣的输出:
$ cmake --build . --target check
=== BUILD AGGREGATE TARGET ZERO_CHECK OF PROJECT delta WITH CONFIGURATION Debug ===
Check dependencies
PhaseScriptExecution CMake\ Rules build/delta.build/Debug/ZERO_CHECK.build/Script-6DF082DADA6745879D9E0B1F.sh
cd /Users/emlai/Code/delta
/bin/sh -c /Users/emlai/Code/delta/build/delta.build/Debug/ZERO_CHECK.build/Script-6DF082DADA6745879D9E0B1F.sh
echo ""
make -f /Users/emlai/Code/delta/build/CMakeScripts/ReRunCMake.make
make[1]: `/Users/emlai/Code/delta/build/CMakeFiles/cmake.check_cache' is up to date.
=== BUILD TARGET not OF PROJECT delta WITH CONFIGURATION Debug ===
Check dependencies
=== BUILD TARGET FileCheck OF PROJECT delta WITH CONFIGURATION Debug ===
Check dependencies
=== BUILD TARGET deltaAST OF PROJECT delta WITH CONFIGURATION Debug ===
Check dependencies
PhaseScriptExecution CMake\ PostBuild\ Rules build/src/ast/delta.build/Debug/deltaAST.build/Script-DFCB4F26C551468881A4AD63.sh
cd /Users/emlai/Code/delta
/bin/sh -c /Users/emlai/Code/delta/build/src/ast/delta.build/Debug/deltaAST.build/Script-DFCB4F26C551468881A4AD63.sh
echo "Creating symlinks"
Creating symlinks
/usr/local/Cellar/cmake/3.7.2/bin/cmake -E cmake_symlink_library /Users/emlai/Code/delta/build/src/ast/Debug/libdeltaAST.dylib /Users/emlai/Code/delta/build/src/ast/Debug/libdeltaAST.dylib /Users/emlai/Code/delta/build/src/ast/Debug/libdeltaAST.dylib
=== BUILD TARGET deltaSupport OF PROJECT delta WITH CONFIGURATION Debug ===
Check dependencies
PhaseScriptExecution CMake\ PostBuild\ Rules build/src/support/delta.build/Debug/deltaSupport.build/Script-7CAA0CC95B4E463993DC6A8F.sh
cd /Users/emlai/Code/delta
/bin/sh -c /Users/emlai/Code/delta/build/src/support/delta.build/Debug/deltaSupport.build/Script-7CAA0CC95B4E463993DC6A8F.sh
echo "Creating symlinks"
Creating symlinks
/usr/local/Cellar/cmake/3.7.2/bin/cmake -E cmake_symlink_library /Users/emlai/Code/delta/build/src/support/Debug/libdeltaSupport.dylib /Users/emlai/Code/delta/build/src/support/Debug/libdeltaSupport.dylib /Users/emlai/Code/delta/build/src/support/Debug/libdeltaSupport.dylib
=== BUILD TARGET deltaSema OF PROJECT delta WITH CONFIGURATION Debug ===
Check dependencies
PhaseScriptExecution CMake\ PostBuild\ Rules build/src/sema/delta.build/Debug/deltaSema.build/Script-73FADE92ABAA422B8804BD88.sh
cd /Users/emlai/Code/delta
/bin/sh -c /Users/emlai/Code/delta/build/src/sema/delta.build/Debug/deltaSema.build/Script-73FADE92ABAA422B8804BD88.sh
echo "Creating symlinks"
Creating symlinks
/usr/local/Cellar/cmake/3.7.2/bin/cmake -E cmake_symlink_library /Users/emlai/Code/delta/build/src/sema/Debug/libdeltaSema.dylib /Users/emlai/Code/delta/build/src/sema/Debug/libdeltaSema.dylib /Users/emlai/Code/delta/build/src/sema/Debug/libdeltaSema.dylib
=== BUILD TARGET deltaIRGen OF PROJECT delta WITH CONFIGURATION Debug ===
Check dependencies
PhaseScriptExecution CMake\ PostBuild\ Rules build/src/irgen/delta.build/Debug/deltaIRGen.build/Script-228C0796627D463597C57E83.sh
cd /Users/emlai/Code/delta
/bin/sh -c /Users/emlai/Code/delta/build/src/irgen/delta.build/Debug/deltaIRGen.build/Script-228C0796627D463597C57E83.sh
echo "Creating symlinks"
Creating symlinks
/usr/local/Cellar/cmake/3.7.2/bin/cmake -E cmake_symlink_library /Users/emlai/Code/delta/build/src/irgen/Debug/libdeltaIRGen.dylib /Users/emlai/Code/delta/build/src/irgen/Debug/libdeltaIRGen.dylib /Users/emlai/Code/delta/build/src/irgen/Debug/libdeltaIRGen.dylib
=== BUILD TARGET deltaParser OF PROJECT delta WITH CONFIGURATION Debug ===
Check dependencies
PhaseScriptExecution CMake\ PostBuild\ Rules build/src/parser/delta.build/Debug/deltaParser.build/Script-33329F75832D4A15AECE47BD.sh
cd /Users/emlai/Code/delta
/bin/sh -c /Users/emlai/Code/delta/build/src/parser/delta.build/Debug/deltaParser.build/Script-33329F75832D4A15AECE47BD.sh
echo "Creating symlinks"
Creating symlinks
/usr/local/Cellar/cmake/3.7.2/bin/cmake -E cmake_symlink_library /Users/emlai/Code/delta/build/src/parser/Debug/libdeltaParser.dylib /Users/emlai/Code/delta/build/src/parser/Debug/libdeltaParser.dylib /Users/emlai/Code/delta/build/src/parser/Debug/libdeltaParser.dylib
=== BUILD TARGET delta OF PROJECT delta WITH CONFIGURATION Debug ===
Check dependencies
=== BUILD AGGREGATE TARGET check OF PROJECT delta WITH CONFIGURATION Debug ===
Check dependencies
PhaseScriptExecution CMake\ Rules build/delta.build/Debug/check.build/Script-A3D22E5853C4469BA62E14D5.sh
cd /Users/emlai/Code/delta
/bin/sh -c /Users/emlai/Code/delta/build/delta.build/Debug/check.build/Script-A3D22E5853C4469BA62E14D5.sh
echo ""
<here's the output from foo>
有没有办法告诉CMake压制此信息,只打印foo
的输出?
答案 0 :(得分:-5)
一个半体面的解决方法:通过tail
管道输出以跳过前n行:
$ cmake --build . --target check | tail -n +90
(致Omitting the first line from any Linux command output的信用。)