5

I've found myself in an odd pattern using Eclipse. I have a project which depends on resources which are not properly accounted for in the eclipse project such that if I update only a header in the dependency Eclipse refuses to build when commanded to, apparently because it doesn't think it's necessary. As a result I end up constantly adding one space to a file and saving to get the CDT to do my bidding.

While it would be possible to integrate the dependencies into the project settings, the project is occasionally rewritten by the CMake auto-generate tool (which I have no interest in patching) which would overwrite the config, and require that I reconfigure the dependencies again and again.

What I'd like to be able to do is simply just tell Eclipse that it should ignore what it thinks should happen and obey the build command, and let the underlying make system do it's job (of determining what should and shouldn't be built).

TL;DR:

  • Eclipse CDT attempts to determine whether to build by watching the freshness of files
  • It only watches properly set up dependencies
  • I don't want to set up the dependencies because project frequently overwritten by CMake when I add files to the project

Anyone know how to override CDT's decision and force a build?

Catskul
  • 17,916
  • 15
  • 84
  • 113
  • Is it possible for you to use a Makefile within that project? If Eclipse performs the build based on a Makefile, you could include the headers within the Makefile and thus forcing a build. – Sebastian Apr 17 '12 at 16:45
  • It is currently using a makefile actually. The headers could in question could be included manually, but would be overwritten on the next autogen + need to be figured out by hand. – Catskul Apr 17 '12 at 18:57
  • Ok, I'm not that familiar with automake, but it's clearly possible to add dependencies for headers, e. g. like in [Makefile, header dependencies](http://stackoverflow.com/q/2394609/172695). So all, you need is a reference to the headers, which could partially generated by some make rules. Maybe this is also possible with automake. – Sebastian Apr 17 '12 at 19:52
  • Have you tried to create Make Target? `Project -> Make Target -> Create ... ` Then you can use that target and it should do whatever you define. – mip Apr 18 '12 at 20:50
  • Doesn't seem to work; it silently refuses to add targets. – Catskul Apr 19 '12 at 00:46
  • @Catskul create temporary projects with different settings and experiment a bit, because in my case it works. I mean I can force builds but also supply different set of commands. BTW I'm using standard CDT Eclipse 3.6.1 instalation. – mip Apr 19 '12 at 17:04
  • @doc, I don't doubt that it might work for fresh or even typical projects, but that won't solve my immediate problem unfortunately. – Catskul Apr 20 '12 at 15:34

3 Answers3

2

I am facing the same problem, I am developing a program in two parts (two static libraries), if I make a rebuild to one library, the Eclipse won't update the other, because it apparently doesn't watch for changes on static libraries.

The solution is to "Clean" the project before every build (Right click on a project -> Clean project) and then do the build. This effectivelly deletes all previous build results and starts building from scratch. I haven't figured yet out how to do it in a single button click, but this works for me.

Jakub Zaverka
  • 8,816
  • 3
  • 32
  • 48
0

Can you add the following to your makefile?

FORCE:

%.o : %.cpp FORCE
    $(CXX) -c $(CXXFLAGS) $< -o $@

Here FORCE is an empty target and hence is always fresh. Hence where ever FORCE is included in the dependency list, they would be built fresh in all builds.

suresh
  • 1,109
  • 1
  • 8
  • 24
0

Are you using Eclipse's internal builder? Because, when using the external builder setting, I don't experience any of the issues you mentioned. Even when editing some files outside of Eclipse, the build will still work in spite of Eclipse being completely unaware of the changes.

Eclipse C/C++ Build project properties

Pascal Kesseli
  • 1,620
  • 1
  • 21
  • 37