[CMake] getting compiler's include paths

Robert Maynard robert.maynard at kitware.com
Mon Jun 24 08:13:48 EDT 2019


It look that starting with CMake 3.6 modification of system headers
will cause CMake to recompile projects. What version of CMake and your
compiler are you using?

On Mon, Jun 17, 2019 at 9:40 AM jl forums <jlmxyz.forums at gmail.com> wrote:
>
> 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
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list