Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » refactoring fails in cmake generated projects(In cmake generated projects the source of the main project is also linked in subprojects. That seems to cause refactoring to fail horribly.)
refactoring fails in cmake generated projects [message #1847517] Sat, 30 October 2021 10:19 Go to next message
Ravenous Bugblatterbeast is currently offline Ravenous BugblatterbeastFriend
Messages: 25
Registered: April 2020
Junior Member
When I let cmake generate an eclipse project from a checkout I face severe problems with refactoring.

I am using this to generate:
cmake -G "Eclipse CDT4 - Unix Makefiles" -DCMAKE_ECLIPSE_VERSION=4.18 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=-j4 PATH_TO_REPOSITORY "${@:1}"


That will create a working project. However, the src of the main project is also linked in the subprojects (I have some depencies checked out from other repos).

When I am trying to refactor a class/function/variable name I mostly get a preview dialog in which some (not all) of the files are shown twice. Once from the main source and once from the source linked in the subprojects. Sometimes the preview dialog does not show. If that happens or if I happen to forget to uncheck one of the subproject sources, the refactoring goes horribly wrong (and this is not an overstatement).

I can just guess that eclipse is remembering the file pointer positions of each occurence and once you hit OK, it doesn't check what it's doing anymore. The result is something like this:

before refactoring:
void OldAndHopelesslyLongFunctionName(int a, int b) {
  int c;
  ...
}


expected result:
void NewName(int a, int b) {
  int c;
  ...
}


actual result:
void Newt c;
  ...
}


What's making this even more frustrating is that eclipse will automatically safe the refactored result without any chance of undoing.

Is there anyway around it? Maybe by just changing the cmake call or by adjusting the eclipse settings?

Kind regards
Re: refactoring fails in cmake generated projects [message #1847520 is a reply to message #1847517] Sat, 30 October 2021 11:09 Go to previous messageGo to next message
Ravenous Bugblatterbeast is currently offline Ravenous BugblatterbeastFriend
Messages: 25
Registered: April 2020
Junior Member
I've forgot to mention: When I delete the link in the subprojects it solves the issue until the next build after that the link is recreated.

Now it seems the cmake option -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE fixes that recreation. I've tried that option before but back then, I just deleted the cmake cache and not the link. That's why I thought it didn't help.

I think doing both (deleting the existing link and adding the option) fixed the issue.

I want to remark that the refactoring behaviour still seems a bit dangerous to me. I'm not denying that my setup was the reason for this issue but maybe the refactorer could have handled it in a better way (for example by detecting that it tried to change the very same file twice).

I think the issue is solved for me. Otherwise I'll get back to you.

Sorry to bother
Re: refactoring fails in cmake generated projects [message #1847528 is a reply to message #1847520] Sun, 31 October 2021 01:46 Go to previous messageGo to next message
Ravenous Bugblatterbeast is currently offline Ravenous BugblatterbeastFriend
Messages: 25
Registered: April 2020
Junior Member
Sorry again. I was wrong. ISSUE IS NOT SOLVED!

At some point (I think it was when I had to clean the cmake cache because I changed some warning levels) the link has been recreated and once again I didn't notice it and fell for the trap.
Re: refactoring fails in cmake generated projects [message #1856532 is a reply to message #1847528] Wed, 14 December 2022 10:19 Go to previous message
Ravenous Bugblatterbeast is currently offline Ravenous BugblatterbeastFriend
Messages: 25
Registered: April 2020
Junior Member
After buying a new workstation and having a fresh installation of eclipse, the problem still isn't solved for me.

As I mentioned before:
it seems that in eclipse projects created by cmake, the main project is also linked as a subproject
I suspect that the the code of the main project is refactored twice without double checking
deleting the link to the main project in the subprojects helps temporarily, but the link is automatically recreated (when cmake cache is cleared and possible in some other unclear conditions)

I'd highly appreciate a solution to this problem.
I've also posted a request in the cmake forum (https://discourse.cmake.org/t/generating-eclipse-project-with-subprojects-links-the-main-project-in-the-subprojects-too/4374) but I didn't get any replies.
Previous Topic:Generated makefile(s) line endings
Next Topic:problem with unicode symbols in UTF-8 files
Goto Forum:
  


Current Time: Fri Apr 26 10:24:29 GMT 2024

Powered by FUDForum. Page generated in 0.02828 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top