2

I use CMake in my project. Often I run a make before firing a test script, so that if the code has changed I don't test an outdated binary. If I see lines about compiling or linking etc I know something has changed. But if nothing has changed, I still see:

[100%] Built target foo

And I would really rather not see that at all. I mean, I don't want a silent build altogether - just in case no actions are necessary. How can I do that?

PS - Here's the result of make -rRd | grep 'Must remake':

    Must remake target 'cmake_check_build_system'.
  Must remake target 'all'.
  Must remake target 'CMakeFiles/tester.dir/all'.
Must remake target 'CMakeFiles/tester.dir/depend'.
Must remake target 'CMakeFiles/tester.dir/build'.
Must remake target 'all'.
Must remake target 'default_target'.

but nothing is actually done.

einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • Is nothing actually happening or do you have a target that is actually being run anyway? What does `make -d` output when this happens? – Etan Reisner Mar 11 '16 at 17:11
  • @EtanReisner: Like, a zillion lines... 36749 to be exact. [Here are the last few lines](http://pastebin.com/npqFFj3n). – einpoklum Mar 11 '16 at 18:27
  • `make -rRd` will be *much* less output but might break things if you use the default rules/variables. But instead of that you could try `make | grep 'Must remake target'` to see which targets make thinks actually need to get rebuilt. From just that output alone I can see that both `default_target` and `all` get rebuilt (but may not output anything) but the `tester` target also builds and outputs the `100%` message. So find the top of the block of lines about `tester` and see pastebin that (or see yourself why make thinks it needs to rebuild it). – Etan Reisner Mar 11 '16 at 18:36
  • @EtanReisner: `make -rRd` gives me 18k lines... but [here's the result of the grep](http://pastebin.com/tubJWna4). – einpoklum Mar 11 '16 at 19:28
  • I have absolutely no idea what those various targets are for (you'd have to see if CMake documents them or if you can figure it out from the makefiles) but they look like things that sort-of always run though `/depend` and `/build` sound like things that might be avoidable. You can look through the output to find out why make things they need to build. If you can find something that it thinks triggers a build that shouldn't be you might be able to fix the problem and improve things. But there may not be a problem like that at all. This might just be how CMake works, I don't know. – Etan Reisner Mar 11 '16 at 19:31
  • @EtanReisner: It's just CMake's internal mechanics. I think it gets make to trigger it to check stuff "itself" and to print to the output. – einpoklum Mar 11 '16 at 19:33

1 Answers1

-1

I use the following

make2() {
  # Exclude any output that contains 'Built target'
  make $@ | grep -v 'Built target';
  echo '-'
}

Then

make2 my_target_generated_by_cmake

Jacob Panikulam
  • 1,196
  • 1
  • 9
  • 12