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!
Edward
请先登录再写评论。
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:
CMakeLists.txt
for library B.EXCLUDE_FROM_ALL
keyword so it won't be built.CMakeLists.txt
where you add project A and a fake project B viaadd_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)
project(dummy)
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})
set_property(TARGET dummy PROPERTY EXCLUDE_FROM_ALL TRUE)
In my main Cmake I added
# Add dummy Cmake for imgui (to enable navigation through its functions)
add_subdirectory(vendor/dummyCmake/)
Hello!
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)