Reputation: 2776
I have a C++ project built of several shared libraries. Each library source code is placed under its subtree of directories. The main CMakeList file contains a list of add_subdirectory(<dirname>)
directives. CMakeList files in every subdirectory contain definitions like the following:
set (SOURCE_FILES
util/src/Connector.cpp
pub/util/Connector.h
)
add_library(channels SHARED $( SOURCE_FILES))
SET_TARGET_PROPERTIES(channels PROPERTIES LINKER_LANGUAGE CXX)
where channels
is the subdirectory name.
Although the search path for include files is set correctly and compilation works, KDevelop does not see the Connector.h
header file and, therefore, its parsing and code/class browser do not work.
I know that .kdev_include_paths
file in every directory might solve the problem. Unfortunately, this approach may not be used due to some additional constraints in our development environment.
Is there any other way to solve this issue?
I use Intel C/C++ compiler on RHEL 7.1 with KDevelop 5.0.4 running from AppImage.
Upvotes: 2
Views: 5252
Reputation: 11
On KDevelop 5 this solved my issue:
Upvotes: 1
Reputation: 1
It appears I experienced the same problem. Symptoms: -- Kdevelop 5.1.2 could not find some #includes; they were underlined in source files. -- There was no problem building the project Cause: -- Both symbolic links and the original *.h files were in the paths specified in include_directories( ) in CMakeLists.txt. Symbolic link removal fixed the problem.
Kdevelop is probably right to be confused about multiple *.h files with the same name. Maybe some future Kdevelop release will be able to recognize that it is dealing with only one target.
Upvotes: 0
Reputation: 29
I found and solved a problem which presented similarly - header files not seen and code/class browser failing. The cause turned out to be an error in my code. For the benefit of others who may write a similar bug and arrive at this page, here is what I did wrong:
I had a header only class in a file 'myClass.hpp' and an empty implementation 'myClass.cpp'. My CmakeLists.txt cited the implementation, but my implementation did not contain #include "myClass.hpp". The effect in Kdevelop-5.1.0 was that the header file was not parsed as part of the program - hence its includes were not read, and much of the code failed semantic analysis.
Upvotes: 1