How can I specify additional include files? Follow Bogdan Calmac Created September 19, 2014 02:25 I want to use the check C unit testing framework which is installed in /usr/local/include. How can I tell CLion/CMake to look in that directory for headers?
According to the CMake documentation (http://www.cmake.org/cmake/help/v3.0/command/include_directories.html#command:include_directories) I can specify additional include directories with:
CMake is able to build successfully using the library headers, but CLion highlights the include in red:
I guess the CLion's integration with CMake does not handle the include_directories directive. Is there a supported way to add additional libraries? Should I file a bug about include_directories?
CLion20180.1.1 - Issue still occurs:(
I've also tried the following CMake directive, but the result is the same: CMake works fine but CLion highlights it in red and doesn't see the functions of the imported header:
I have it too. Has anyone found a solution yet?
Still not working if th include is defined in an included directory by :
in CMakeLists.txt in SimpleTests
Don't work, CLion don't recognize as a include dir in the path.
Only workd if you put include_directories in the root CMakeLists.txt.
Can I add an external includes directories only to the CLion's project without modification the CMakeLists.txt?
In my case, I can't build the project on the developer's machine, but I have most of the headers. Now I use vim/sublime with autocomplete plugins, but they aren't very well for navigation by source code.
Hm. I'm not sure how it works. AppCode treat xcode project in the same way as Xcode. Maybe worth reporting the bug to https://youtrack.jetbrains.com/issues/OC, attaching the xcode project you generate from CMake.
Because that's where homebrew installs libraries. Eventually I was able to solve my problem with build file below:
# add extra include directories
# add extra lib directories
# specify the executable (no libraries here)
# specify the dependency on an extra library
Bordan, could you please try passing SYSTEM flag to 'include_directories' command?
Does it help?
If not, what C/CXX compilers are chosen in CMake | Cache toolwindow?
Yeah, i have this problem too...
I have a lot, and by lot, i mean LOT of include files in custom (fixed) locations around the system like $/HOME/local $Home/boost/include etc etc
CLions seems to omit this files in there is no possibility (at last i didn't found any) to point CLion to this directories. I cant confirm it because project that i am working on is huge, but also it seems to ignore even files in his own project directory, (that means a lot of inspections and other stuff like "ctrl+LMB->goto_definition/declaration" is generally not working as it should).
I assume that CLion keeps parsed information from files in some internal db for later use? In that case it may be some parsing rules or limit stuff? Or maybe it wont parse directory because there are symlinks in there?
JetBrains, please explain this magic! :3
Excellent work btw, i was waiting for stuff like this for looong time!
Mateusz, does your project builds correctly if you try to build it with CMake manually? If it does not, then you need to correctly specify include paths in your CMakeLists.txt using "include_directories" command. For certain libraries, like boost, there are designated ways of specifying the library location, e.g. set(BOOST_ROOT "/path/to/boost").
I have no problems while building, As i said project is epicly huge and it is using few different building systems ( cmake, make bjam and others ). Running build is one thing, and CLion works perfectly in that case.
I have problems while editing projects, because CLion do not parse (internally) files not included in scope ( one scope on whole project ) and i cant use code completition, goto definition/declaration show uses and other fun functions.
I cant really point CLion to directory containing include files ( in project file i have somethong like #include <sals/memmap> or #include <ataxp> ) that are resolved by system or buildtool but are unknown by CLion.
Sorry, I just noticed that you mentioned that your include paths contain symlinks in your first post. I cannot be sure, but most likely that is what causing the problem. This issue was fixed recently and will be included into the next EAP build.
I still have the exact same problem that CLion cannot find fuse.h even though CMake works fine .
I've got the same error.
Clion is not able to find header file by name on the windows-10 machine. But can find the header file by the relative path and name.
Cmake works fine. Compilation works on Mac OS X and Windows. Mac OS X version of Clion works well even with only name of file and understand where to look at header files. Windows version not.
Martin, can you compile your prj correctly?
Can you successfully run CMake command outside CLion on this prj?
Yes. I can both build the project within CLion and build externally with the CMake command .
I made a new observation just now though:
I started a basic blinky example that I have made, but I forgot to point CLion to my toolchain file (-DCMAKE_TOOLCHAIN_FILE=toolchain.cmake). This puzzled me for a while because suddenly all the #include files stayed green and CLion seemed to be able to read them just fine. But of course the project wouldn't build without the toolchain file. Then when I included the toolchain file the #includes turned red and I got the same errors reported above again.
Martin, thanks for the investigation. Looks like this is related to the same problem as https://youtrack.jetbrains.com/issue/CPP-3962.
Thanks a lot Anastasia. I will follow the progress there.
Removing the dot from end of the url, the link above is broken. check this: https://youtrack.jetbrains.com/issue/CPP-3962
Ivan, does it compile?
Mitien, could you please submit a sample to our tracker? We'll check
simple example uploaded https://youtrack.jetbrains.com/issue/CPP-12788
Clion 2018.2 Issue still occurs. When are you going to fix it?
include_directories does not work at all.
I can fix it if add directory path directly to add_executable(mytarget Include/Hardware ...)
In this case all includes in the files looks green but CLION can't regongnize types from these includes...
We currently try to reproduce on our side, when we manage to do so we'll investigate the issue. We'll check your attachement to the issue soon
Do you have these headers located under the project root or in some separate location?
They are in a separate location.
For CMake projects, CLion need an ability to run CMake correctly on the project in order to open it. If you have your header files somewhere, then probably CMake can't finish correctly for your project. Then you have to update CMakeLists.txt with the corresponding include directories.
As an alternative, you can generate compilation database out of CMake on the machine where you can run it correctly and then open the project in CLion on another machine via a compilation database.
Ok, thank you. Unfortunatly, it doesn't suite me. To have the same path on both machines is a bit hard.