简体   繁体   中英

Possible to get Eclipse CDT to force build of a CMake generated project, disregarding freshness of resources?

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?

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.

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.

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 ++构建项目属性

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM