`This file does not belong to any project target` - even though it compiles

I have a ROS project that I had set up totally fine in Clion. Something in my settings got reset and now I'm getting `This file does not belong to any project target, code insight features might not work properly`. 

The project dir looks roughly like this: 

genicam_driver
├── CMakeLists.txt
├── launch
│   └── genicam.launch
├── package.xml
└── src
    ├── aux.cpp
    ├── aux.h
    ├── driver.cpp

 

I've added the env variables to Cmake Settings:

LD_LIBRARY_PATH=/opt/ros/melodic/lib:/usr/local/lib
CMAKE_PREFIX_PATH=/opt/ros/melodic:/usr/bin
ROS_ETC_DIR=/opt/ros/melodic/etc/ros
ROS_PACKAGE_PATH=/opt/ros/melodic/share
ROS_ROOT=/opt/ros/melodic/share/ros

The CMakeLists.txt has all the usual Catkin boilerplate, e.g.: 

find_package(catkin REQUIRED COMPONENTS
cv_bridge
image_transport
roscpp
sensor_msgs
)

And I have the executable as a target: 

add_executable( driver_node
src/driver.cpp
src/aux.h
src/aux.cpp
)


And it compiles! I see the target in Run -> Edit Configurations ( "driver_node" ) and it compiles with no complaints. But I still get the yellow banner. Furthermore I can click on `src/driver.cpp` in CmakeLists, hit Ctrl-B, and jump right to that file. So clearly it has some awareness that file is part of the project. 

I've tried various combinations of rm-ing .idea, cmake caches, File->Invalidate Caches, to no avail. 

Actually, instead of talking in the abstract, here is an example right out of the box. If you go into `prosilica_nodelet.cpp`, jump to 

#include <nodelet/nodelet.h>

and jump to that file, you get the Yellow Banner of Doom, and accordingly, macros like NODELET_WARN from that include file get the red squiggle. Even though `/opt/ros/melodic/include` is in `target_include_directories`. 

0
7 comments

Hi! Do you use the latest stable release (2018.3.4)? If not, please update CLion.

Then please close the project, remove the .idea subfolder from the project's folder, close CLion and open the project as described in our ROS setup tutorial (with launching CLion in the sourced environment). Is the CMake project loaded successfully in this case (i.e. there are no errors in the CMake tool window)? Ae the macros like NODELET_WARN resolved correctly?

-1

I was really convinced that IJ brings us great Dev Products. But in the last few month I have the feeling that none of the Dev Products works without problems - today CLion with this annoying bug. 2020.1.EAP fails, 2019.3.4 works

1

Hi Mike! Do you get `This file does not belong to any project target`? On what build system is your project based?

0

I get this on only 1 .cpp file in a project with multiple library targets. There are other .cpp files in the same lib and they are added to the CMakeLists.txt the same way... but still no luck on getting intellisense on the file.

I'm using a local docker container to build and I've rerun CMake, rebuilt the project, and invalidated caches in the IDE and restarted.

0

Hi Sam!

Do you use the remote mode? Have you tried calling Tools | Resync with Remote Hosts?

0

Yes, I have to use full remote to use a local docker container. I followed the steps here to update our existing docker images.

As a sanity check I ran it one last time and I can confirm that the warning "This file does not belong to any project target, code insight features might not work properly" still appears.

0

Sam, please do the following:

  1. Update CLion to latest version (2020.1.1).
  2. Make sure that remote toolchain is connected to remote host (check connection status in File | Settings | Build, Execution, Deployment | Toolchains).
  3. Open any source file, call Help | Find Action and find "Show Remote Hosts Info".
  4. Share the output with us.

Also please call Tools | Resync With Remote Hosts and send us the idea.log file (Help | Show Log in ...) after that. Note that logs might contain private user's information (like file paths and names). 

Please send the requested files to clion-support at jetbrains.com. Thanks.

0

Please sign in to leave a comment.