Enable navigation to implementation for external libraries?


Hi, for one of my external libraries, I have the full source code available on my machine. CLion allows me to jump to the *header* files of that external library (e.g., with Ctrl-B), but I cannot jump to the *definition* of anything. Do you have any idea how I could enable that?

Kind regards!



Unfortunately, there is no straightforward way to do it now. Here is a related feature request: https://youtrack.jetbrains.com/issue/CPP-18380/Cannot-attach-other-directory-to-current-project

Currently, the only way is to include library B into project A.

In case of CMake, you can do it in the following way:

  1. Create a fake CMakeLists.txt for library B.
  2. Add a dummy target with the list of all library B sources to it. You can mark the dummy target with EXCLUDE_FROM_ALL keyword so it won't be built.
  3. Create a top-level CMakeLists.txt where you add project A and a fake project B via add_subdirectory

That was helpful. Thank you!

If anybody wants a practical example. here you go:
I wanted to navigate through imgui functions, so

I created a folder dummyCmake where lays the following code

cmake_minimum_required(VERSION 3.20)
set(SOURCE ../imgui/examples/example_glfw_opengl3/main.cpp)
include_directories(../imgui/backends/imgui_impl_opengl3.h ../imgui/backends/imgui_impl_glfw.h)
add_library(dummy OBJECT ${SOURCE})


In my main Cmake I added

# Add dummy Cmake for imgui (to enable navigation through its functions)




Could you please describe the issue in more detail? Do I understand correctly that a function from the external library is used in a project source file and you want to navigate from that usage to its definition?


Imagine I am working in project A. Project A uses library B (also available in source code form on my machine). While browsing the source code of project A, I come across function F from library B. I can jump to the declaration of F in the header files of B, because CLion is intelligent enough to scan the includes of project A. But sometimes, I want to see the implementation of F. How can I explain to CLion to look inside the source code tree of library B, too? (And not only the header files of B)