Preferential include path in CMake

Nov 18, 2020 at 12:53am
Dear all,

I use CMake for build system, and define include path of libraries via link_directories.

Here, is there a way to switch the include path preferentially with respect to system's path (c.f. usr/include to an include path I defined)?


Kind regards
Nov 18, 2020 at 1:48am
When you specify your own include paths, they take precedence over the implementation's. So, if you put in one of those paths a file named iostream, when you #include <iostream> you'll be including that file, not the implementation's iostream.
Nov 18, 2020 at 9:12am
Dear helios,

Thank you for your reply.
What I told me is, do not use #include <***>, but use #include "***", when selecting our own include directories.

According to it, I will try my project, thank you so much.
Nov 18, 2020 at 12:25pm
If you use quotes instead of angle brackets the compiler will first look for the file in the path relative to the current file. If it can't find it, it will continue looking in the include paths.
In other words, if you expect the file you're looking for to be in an include path then it doesn't make any difference if you use angle brackets or quotes.
Topic archived. No new replies allowed.