eclipse-cdt / cdt

Eclipse CDT™ C/C++ Development Tools
http://eclipse.org/cdt
Eclipse Public License 2.0
309 stars 201 forks source link

Indexer and Conan CMake Projects #938

Open joesulewski opened 1 week ago

joesulewski commented 1 week ago

Hello,

I have a project that I created with Conan.io for package management which generates a CMake project. I am able to successfully use CMake on Windows to generate a Visual Studio configuration to build and edit my code on Windows. On Linux I would like to use Eclipse CDT to build, debug and edit. I was able to generate Unix Make files that will clean and build the project without issue.

I created a new CMake (new or existing code) project and pointed the directory of the code to the root directory of my project which has the CMakeLists.txt file. I can compile, execute and debug within Eclipse. However, the indexer cannot find standard and external library classes and functions such as std::string, boost, oatpp, log4cxx and others. I have tried every tutorial I can find but it seems I can't get the indexer to find anything.

I could post some of the CMake but there is probably a log file somewhere that would be more helpful.

I'm using WSL Ubuntu 24.04 and the latest Eclipse and CMake plugin.

Eclipse 24.09 (4.33.0) cmake4eclipse 5.0.0

Below is a screen capture that displays the issue, notice the includes has the right paths. What I find interesting is that I couldn't get the includes to show up until I started eclipse to get a screen capture for this note. Not sure why they showed up this time. But the problem still manifests. Notice how std::string test in main is showing an error and when I hover it says it can't be resolved.

image

Thanks, Joe

I looked at the workspace/.metadata/.log and I see a lot but that is the only thing I can find

!SESSION 2024-11-12 18:44:23.840 ----------------------------------------------- eclipse.buildId=4.33.0.20240905-0613 java.version=21.0.4 java.vendor=Eclipse Adoptium BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en Framework arguments: -product org.eclipse.epp.package.cpp.product Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.cpp.product

!ENTRY org.eclipse.equinox.p2.repository 2 0 2024-11-12 18:45:27.943 !MESSAGE Server returned lastModified <= 0 for https://raw.githubusercontent.com/15knots/cmake4eclipse/master/releng/comp-update/compositeArtifacts.xml

!ENTRY org.eclipse.equinox.p2.repository 2 0 2024-11-12 18:45:30.940 !MESSAGE Server returned lastModified <= 0 for https://raw.githubusercontent.com/15knots/cmake4eclipse/master/releng/comp-update/compositeContent.xml

!ENTRY org.eclipse.ui 4 0 2024-11-12 18:45:31.572 !MESSAGE Unhandled event loop exception !STACK 0 java.lang.IllegalArgumentException: Argument not valid at org.eclipse.swt.SWT.error(SWT.java:4903) at org.eclipse.swt.SWT.error(SWT.java:4837) at org.eclipse.swt.SWT.error(SWT.java:4808) at org.eclipse.swt.graphics.Image.init(Image.java:1189) at org.eclipse.swt.graphics.Image.(Image.java:210)

joesulewski commented 1 week ago

I was able to determine problem and rather than edit the original post I'll leave it in case any other Conan users come across the issue. Open Project Properties->Cmake4eclipseBuild->CMake Options and enter the argument to the conan generated toolchain like so:

-DCMAKE_TOOLCHAIN_FILE=build/Debug/generators/conan_toolchain.cmake