conan-io / conan-clion-plugin

CLion C/C++ IDE plugin for Conan Package Manager
Apache License 2.0
99 stars 27 forks source link

Conan plugin doesn't work with CMake presets? #162

Closed Divix55 closed 1 year ago

Divix55 commented 1 year ago

Hello, just checked new Conan Clion plugin and noticed one thing, plugin is making Clion constantly reload CMake project if my project is using CMake presets, which finally makes Clion hanging. Without presets, plugin is working great. My setup is: macOS 13.5 + Clion 2023.2.1 + Conan Plugin 1.0.1 + Conan 1.0.9.

image

Preset file:

{
  "version": 5,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 25,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "common",
      "hidden": true,
      "binaryDir": "${sourceDir}/build/${presetName}",
      "installDir": "${sourceDir}/build/target"
    },
    {
      "name": "debug",
      "inherits": "common",
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Debug"
      }
    }
  ]
}
czoido commented 1 year ago

Hi @Divix55,

Thanks a lot for reporting. I could not reproduce the CLion hang for a project that uses presets. Maybe if you give us more information about the structure of the project we could try to reproduce the problem and try to fix it.

Nevertheless, I think it could be possible to add Conan support in CLion for a project that already uses presets although for the moment it can't be done via the plugin. You could try to add these variables to the preset:

"CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "conan_provider.cmake",
"CONAN_COMMAND": "location of conan or don't declare if you use conan installed system-wide"
Divix55 commented 1 year ago

Hi @czoido, thanks for fast replay :)

Yes, I must say that workaround with manually added CMAKE_PROJECT_TOP_LEVEL_INCLUDES is working quite well :) I get in that case "Add Conan support to the project" popup with each time Im adding new dependency via plugin, but I can live with it.

But regarding initial bug, in my case it's reproducible all the time. Steps to reproduce it:

  1. Create new C++ project with default settings in Clion via File > New project > C++ executable.
  2. Add preset file.
  3. Load CMake profile from preset.
  4. Enable Conan plugin for that profile in Conan plugin configuration.

Actual result:

  1. Clion is constantly starting reloading cmake project (indicated by information on the bottom bar with progress status and blinking green icon on CMake tab on left side of the Clion window)

Expected result:

  1. Clion will reload CMake project once.

Here is part of Clion log file (not sure if its helpful).

2023-09-06 14:01:27,971 [341477365]   INFO - #c.i.w.i.i.j.s.JpsGlobalModelSynchronizerImpl - Saving global entities to files
2023-09-06 14:01:33,644 [341483038]   INFO - #c.i.w.i.i.j.s.JpsGlobalModelSynchronizerImpl - Saving global entities to files
2023-09-06 14:01:33,779 [341483173]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:33,779 [341483173]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6839 in 1 ms: CIDR: apply roots
2023-09-06 14:01:33,782 [341483176]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 15 ms
2023-09-06 14:01:33,786 [341483180]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:33,786 [341483180]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6840 in 0 ms: CIDR: apply roots
2023-09-06 14:01:33,787 [341483181]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 2 ms
2023-09-06 14:01:33,859 [341483253]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:33,859 [341483253]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6841 in 0 ms: CIDR: apply roots
2023-09-06 14:01:33,936 [341483330]   INFO - #c.i.c.ComponentStoreImpl - Saving Project(name=untitled2, containerState=COMPONENT_CREATED, componentStore=<user path>/CLionProjects/untitled2)ProjectView took 69 ms, RunManager took 11 ms, editorHistoryManager took 60 ms
2023-09-06 14:01:33,949 [341483343]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 92 ms
2023-09-06 14:01:33,978 [341483372]   INFO - #c.i.w.i.i.j.s.JpsGlobalModelSynchronizerImpl - Saving global entities to files
2023-09-06 14:01:33,980 [341483374]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:33,980 [341483374]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6842 in 0 ms: CIDR: apply roots
2023-09-06 14:01:33,993 [341483387]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 14 ms
2023-09-06 14:01:33,996 [341483390]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:33,996 [341483390]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6843 in 0 ms: CIDR: apply roots
2023-09-06 14:01:34,021 [341483415]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 26 ms
2023-09-06 14:01:34,023 [341483417]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:34,023 [341483417]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6844 in 1 ms: CIDR: apply roots
2023-09-06 14:01:34,036 [341483430]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 14 ms
2023-09-06 14:01:34,039 [341483433]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:34,039 [341483433]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6845 in 0 ms: CIDR: apply roots
2023-09-06 14:01:34,040 [341483434]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 3 ms
2023-09-06 14:01:34,051 [341483445]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:34,051 [341483445]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6846 in 1 ms: CIDR: apply roots
2023-09-06 14:01:34,060 [341483454]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 10 ms
2023-09-06 14:01:34,063 [341483457]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:34,064 [341483458]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6847 in 1 ms: CIDR: apply roots
2023-09-06 14:01:34,072 [341483466]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 11 ms
2023-09-06 14:01:34,073 [341483467]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:34,073 [341483467]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6848 in 0 ms: CIDR: apply roots
2023-09-06 14:01:34,084 [341483478]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 11 ms
2023-09-06 14:01:34,086 [341483480]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:34,086 [341483480]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6849 in 0 ms: CIDR: apply roots
2023-09-06 14:01:34,095 [341483489]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 10 ms
2023-09-06 14:01:34,098 [341483492]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:34,098 [341483492]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6850 in 1 ms: CIDR: apply roots
2023-09-06 14:01:34,106 [341483500]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 10 ms
2023-09-06 14:01:34,109 [341483503]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:34,109 [341483503]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6851 in 1 ms: CIDR: apply roots
2023-09-06 14:01:34,119 [341483513]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 11 ms
2023-09-06 14:01:34,121 [341483515]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:34,121 [341483515]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6852 in 1 ms: CIDR: apply roots
2023-09-06 14:01:34,136 [341483530]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 16 ms
2023-09-06 14:01:34,139 [341483533]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:34,139 [341483533]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6853 in 1 ms: CIDR: apply roots
2023-09-06 14:01:34,139 [341483533]   INFO - #c.i.w.i.i.j.s.JpsGlobalModelSynchronizerImpl - Saving global entities to files
2023-09-06 14:01:34,148 [341483542]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 10 ms
2023-09-06 14:01:34,149 [341483543]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:34,149 [341483543]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6854 in 0 ms: CIDR: apply roots
2023-09-06 14:01:34,158 [341483552]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 9 ms
2023-09-06 14:01:34,160 [341483554]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:34,160 [341483554]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6855 in 0 ms: CIDR: apply roots
2023-09-06 14:01:34,168 [341483562]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 9 ms
2023-09-06 14:01:34,170 [341483564]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:34,170 [341483564]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6856 in 1 ms: CIDR: apply roots
2023-09-06 14:01:34,178 [341483572]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 9 ms
2023-09-06 14:01:34,180 [341483574]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
2023-09-06 14:01:34,180 [341483574]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Project model updated to version 6857 in 0 ms: CIDR: apply roots
2023-09-06 14:01:34,188 [341483582]   INFO - #c.j.c.c.c.w.CMakeWorkspace - Reloading CMake project took 9 ms
2023-09-06 14:01:34,213 [341483607]   INFO - #c.i.w.i.i.EntitiesOrphanageImpl - Update orphanage. 0 modules added
czoido commented 1 year ago

Hi @Divix55,

I could finally reproduce the bug. I think that should be fixed with the 2.0.2 version that we have just released. It will take a couple of hours to be available in the JetBrains Marketplace but you can try to "Install Plugin from disk" from the distributed file in the GitHub release:

Release: https://github.com/conan-io/conan-clion-plugin/releases/tag/v2.0.2 Plugin file: https://github.com/conan-io/conan-clion-plugin/releases/download/v2.0.2/Conan-2.0.2.zip

Could you please check if that still happens with 2.0.2?

Thanks a lot!

Divix55 commented 1 year ago

Yes, issue seems to be fixed in 2.0.2 :) Thanks