[CMake] getting compiler's include paths

jl forums jlmxyz.forums at gmail.com
Mon Jun 17 09:39:59 EDT 2019


Hi,
I want to create a full tag file and for this require to know the compiler
full include path...  there is a way to had custom includes path but didn't
found any variables for the include path....
for example :
$ gcc-8 -v -x c -E /dev/null
Using built-in specs.
[....]
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/8/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/8/include-fixed
 /usr/x86_64-linux-gnu/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
[...]

$ gcc -v -x c -E /dev/null
Using built-in specs.
[...]
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/7/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
 /usr/x86_64-linux-gnu/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
[...]

I tried to


get_target_property(moggle_interface_includes FileSync
INTERFACE_INCLUDE_DIRECTORIES)
message("Moggle interface includes: ${moggle_interface_includes}")

get_target_property(motor_includes FileSync INCLUDE_DIRECTORIES)
message("MOTOR includes ${motor_includes}")

but I get

Moggle interface includes: moggle_interface_includes-NOTFOUND
MOTOR includes motor_includes-NOTFOUND


there is also some issue because cmake strip dependencies from system's
include, which means that updating a system software won't cause rebuild
and consider that the build is uptodate, causing unexpected results
seems that there is ways to workaround this :
https://stackoverflow.com/questions/7461000/handling-header-files-dependencies-with-cmake
but this is ugly... would be better to let the user choose with an option

thanks and regards
JLM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190617/28270bcb/attachment.html>


More information about the CMake mailing list