Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated launch targets #863

Closed
Zingam opened this issue Nov 1, 2019 · 11 comments
Closed

Duplicated launch targets #863

Zingam opened this issue Nov 1, 2019 · 11 comments
Labels
Feature: build Feature: debug/launch fixed (release pending) fixed in pre-release and is pending official release

Comments

@Zingam
Copy link
Contributor

Zingam commented Nov 1, 2019

Maybe this is fixed already but I am unable to find such issue.
Whenever I need to select a launch target I see duplicated entries:

Screenshot from 2019-11-01 13-41-51

Maybe whenever there is just one target in the project it should be selected by default and no select popup menu should be displayed.

@Zingam
Copy link
Contributor Author

Zingam commented Nov 7, 2019

I can still see the duplicated entries in 1.2.1.

@KoeMai
Copy link
Contributor

KoeMai commented Nov 17, 2019

I tried to reconstruct the dublicate entries. But I don´t see it. Are this duplicate launch configurations or execution targets? When is the dialog shown? How does the launch configuration looks like? And which tool versions are used?

@Zingam
Copy link
Contributor Author

Zingam commented Nov 18, 2019

When I click on "Debug" on the status bar. I have been observing this for a while now in a project I have.
I tried to quickly debug it but couldn't get any idea what was going on. The above screenshot was made on Ubuntu. Here a a couple of screenshot on Windows.

I may need investigate some more.

Here I clicked: [all] "Set the active target to build" on the status bar.

Untitled

Here I clicked: [Debug] "Select target to launch" on the status bar.

Untitled2

@KoeMai
Copy link
Contributor

KoeMai commented Nov 19, 2019

The project contains to executable targets from different projects (see cmake: project outline).
May be it is helps to add the project into the target description.

twoExecuableTargets

@Zingam
Copy link
Contributor Author

Zingam commented Nov 19, 2019

@KoeMai This is puzzling. I have just one add_executable in the source. Also that other library ThirdParty/glad also appears twice.
I use Visual Studio 2019 mostly and I don't observe that kind of duplicated executable targets there.

image

Edit: The library glad appears three times in the outline actually.

@Zingam
Copy link
Contributor Author

Zingam commented Nov 19, 2019

These are the debug targets as seen in VS2019 and exactly as expected:

image

@Zingam
Copy link
Contributor Author

Zingam commented Nov 24, 2019

The duplication of targets in the outline happens because I have multiple project commands in my CMakeLists.txt-s. When I removed all project commands but the one in the root CMakeLists.txt the Project outline started to look good.

The structure was:

  • project 1 in the root CMakeLists.txt adds project 2's and project 3's CMakeLists.txt
    • project 2 in sub-CMakeLists.txt(contains a library target) addsproject4'sCMakeLists.txt`
    • project 3 in sub-CMakeLists.txt (contains an executable target)
    • project 4 in sub-CMakeLists.txt (contains a library target)

I don't think that my CMakeLists.txt are wrong. I would blame the way the tree is constructed as the targets are included multiple times in the tree, probably once for each add_subdirectory./project command CMakeLists.txt.
I'll try to recreate this with a simpler project.

@Zingam
Copy link
Contributor Author

Zingam commented Nov 28, 2019

The CMake server returns a list of projects:

And the extension just puts them into the Outliner:

updateCodeModel(model: cms.CodeModelContent|null, exCtx: {launchTargetName: string|null, defaultTargetName: string}) {
    if (!model || model.configurations.length < 1) {
      return;
    }
    this._codeModel = model;
    const config = model.configurations[0];
    const updates: BaseNode[] = [];
    const new_children: BaseNode[] = [];
    for (const pr of config.projects) {
      const item = new ProjectNode(pr.name);
      item.update(pr, {...exCtx, nodesToUpdate: updates});
      new_children.push(item);
    }
    this._children = new_children;

    this._changeEvent.fire(null);
    for (const node of updates) {
      this._changeEvent.fire(node);
    }
  }

The CMake server returns all sub-branches of the project tree as a list of projects.
I cannot see a reason why the extension should iterate over all projects (calls to the command project()) and their sub-projects (subsequent calls to project()). I think it should just use the top-level project (or too-level projects when the extension starts supporting multiple top-level projects), which is the project in the root CMakeLists.txt file.

The top-level CMakeLists.txt file for a project must contain a literal, direct call to the project() command;

@Zingam
Copy link
Contributor Author

Zingam commented Dec 14, 2019

A simple sample project:

CMakeMultiProject.zip

@bobbrow
Copy link
Member

bobbrow commented Dec 31, 2019

Thanks for the example. I created a PR for this.

@bobbrow
Copy link
Member

bobbrow commented Dec 31, 2019

Ha, I spoke too soon. I only fixed the build selector. I need to fix the launch one too.

@bobbrow bobbrow added the fixed (release pending) fixed in pre-release and is pending official release label Jan 22, 2020
@andreeis andreeis closed this as completed Feb 4, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Feature: build Feature: debug/launch fixed (release pending) fixed in pre-release and is pending official release
Projects
None yet
Development

No branches or pull requests

4 participants