[CMake] getting compiler's include paths

jl forums jlmxyz.forums at gmail.com
Thu Jun 27 08:59:13 EDT 2019


thanks for the anwer....
quite not... I'm using cmake 3.14.2 (so, far away from 3.6....) and have a
look, in main.cpp, there is #include <filesystem>:

$ find /usr/include/ -name filesystem
/usr/include/c++/5/experimental/filesystem
/usr/include/c++/7/experimental/filesystem
/usr/include/c++/8/filesystem
/usr/include/c++/8/experimental/filesystem
$ sudo touch /usr/include/c++/5/experimental/filesystem
/usr/include/c++/7/experimental/filesystem /usr/include/c++/8/filesystem
/usr/include/c++/8/experimental/filesystem
$ make
[100%] Built target FileSync
$ touch ../main.cxx
$ make
Scanning dependencies of target FileSync
[ 50%] Building CXX object CMakeFiles/FileSync.dir/main.cxx.o
[100%] Linking CXX executable FileSync
[100%] Built target FileSync


=> cmake don't create "full include dependency" which IS a mistake....
updating system g++ can just assume the target is uptodate and in fact just
create a broken build...

in cmake cxx.includecache

#IncludeRegexLine: ^[ ]*[#%][ ]*(include|import)[ ]*[<"]([^">]+)([">])
#IncludeRegexScan: ^.*$
#IncludeRegexComplain: ^$
#IncludeRegexTransform:
/home/orange/crypt/Devel/projets/FileSync/main.cxx
cstdio
-
io.h
-
fcntl.h
-
locale
-
clocale
-
fstream
-
iostream
-
filesystem
-

$ /usr/bin/gcc-8 -M ../main.cxx
main.o: ../main.cxx /usr/x86_64-linux-gnu/include/stdc-predef.h \
 /usr/include/c++/8/cstdio \
 /usr/include/x86_64-linux-gnu/c++/8/bits/c++config.h \
 /usr/include/x86_64-linux-gnu/c++/8/bits/os_defines.h \
 /usr/x86_64-linux-gnu/include/features.h \
 /usr/x86_64-linux-gnu/include/sys/cdefs.h \
 /usr/x86_64-linux-gnu/include/bits/wordsize.h \
 /usr/x86_64-linux-gnu/include/bits/long-double.h \
 /usr/x86_64-linux-gnu/include/gnu/stubs.h \
 /usr/x86_64-linux-gnu/include/gnu/stubs-64.h \
 /usr/include/x86_64-linux-gnu/c++/8/bits/cpu_defines.h \
 /usr/x86_64-linux-gnu/include/stdio.h \
 /usr/x86_64-linux-gnu/include/bits/libc-header-start.h \
 /usr/lib/gcc/x86_64-linux-gnu/8/include/stddef.h \
 /usr/x86_64-linux-gnu/include/bits/types.h \
 /usr/x86_64-linux-gnu/include/bits/typesizes.h \
 /usr/x86_64-linux-gnu/include/bits/types/__FILE.h \
 /usr/x86_64-linux-gnu/include/bits/types/FILE.h \
 /usr/x86_64-linux-gnu/include/bits/libio.h \
 /usr/x86_64-linux-gnu/include/bits/_G_config.h \
 /usr/x86_64-linux-gnu/include/bits/types/__mbstate_t.h \
 /usr/lib/gcc/x86_64-linux-gnu/8/include/stdarg.h \
 /usr/x86_64-linux-gnu/include/bits/stdio_lim.h \
 /usr/x86_64-linux-gnu/include/bits/sys_errlist.h \
 /usr/include/c++/8/locale /usr/include/c++/8/bits/localefwd.h \
 /usr/include/x86_64-linux-gnu/c++/8/bits/c++locale.h \
 /usr/include/c++/8/clocale /usr/x86_64-linux-gnu/include/locale.h \
 /usr/x86_64-linux-gnu/include/bits/locale.h \
 /usr/x86_64-linux-gnu/include/bits/types/locale_t.h \
 /usr/x86_64-linux-gnu/include/bits/types/__locale_t.h \
 /usr/include/c++/8/iosfwd /usr/include/c++/8/bits/stringfwd.h \
 /usr/include/c++/8/bits/memoryfwd.h /usr/include/c++/8/bits/postypes.h \
 /usr/include/c++/8/cwchar /usr/x86_64-linux-gnu/include/wchar.h \
 /usr/x86_64-linux-gnu/include/bits/floatn.h \
 /usr/x86_64-linux-gnu/include/bits/floatn-common.h \
 /usr/x86_64-linux-gnu/include/bits/wchar.h \
 /usr/x86_64-linux-gnu/include/bits/types/wint_t.h \
 /usr/x86_64-linux-gnu/include/bits/types/mbstate_t.h \
 /usr/include/c++/8/cctype /usr/x86_64-linux-gnu/include/ctype.h \
 /usr/x86_64-linux-gnu/include/endian.h \
 /usr/x86_64-linux-gnu/include/bits/endian.h \
 /usr/x86_64-linux-gnu/include/bits/byteswap.h \
 /usr/x86_64-linux-gnu/include/bits/byteswap-16.h \
 /usr/x86_64-linux-gnu/include/bits/uintn-identity.h \
 /usr/include/c++/8/bits/locale_classes.h /usr/include/c++/8/string \
 /usr/include/c++/8/bits/char_traits.h \
 /usr/include/c++/8/bits/stl_algobase.h \
 /usr/include/c++/8/bits/functexcept.h \
 /usr/include/c++/8/bits/exception_defines.h \
 /usr/include/c++/8/bits/cpp_type_traits.h \
 /usr/include/c++/8/ext/type_traits.h \
 /usr/include/c++/8/ext/numeric_traits.h \
 /usr/include/c++/8/bits/stl_pair.h /usr/include/c++/8/bits/move.h \
 /usr/include/c++/8/bits/concept_check.h /usr/include/c++/8/type_traits \
 /usr/include/c++/8/bits/stl_iterator_base_types.h \
 /usr/include/c++/8/bits/stl_iterator_base_funcs.h \
 /usr/include/c++/8/debug/assertions.h \
 /usr/include/c++/8/bits/stl_iterator.h \
 /usr/include/c++/8/bits/ptr_traits.h /usr/include/c++/8/debug/debug.h \
 /usr/include/c++/8/bits/predefined_ops.h /usr/include/c++/8/cstdint \
 /usr/lib/gcc/x86_64-linux-gnu/8/include/stdint.h \
 /usr/x86_64-linux-gnu/include/stdint.h \
 /usr/x86_64-linux-gnu/include/bits/stdint-intn.h \
 /usr/x86_64-linux-gnu/include/bits/stdint-uintn.h \
 /usr/include/c++/8/bits/allocator.h \
 /usr/include/x86_64-linux-gnu/c++/8/bits/c++allocator.h \
 /usr/include/c++/8/ext/new_allocator.h /usr/include/c++/8/new \
 /usr/include/c++/8/exception /usr/include/c++/8/bits/exception.h \
 /usr/include/c++/8/bits/exception_ptr.h \
 /usr/include/c++/8/bits/cxxabi_init_exception.h \
 /usr/include/c++/8/typeinfo /usr/include/c++/8/bits/hash_bytes.h \
 /usr/include/c++/8/bits/nested_exception.h \
 /usr/include/c++/8/bits/ostream_insert.h \
 /usr/include/c++/8/bits/cxxabi_forced.h \
 /usr/include/c++/8/bits/stl_function.h \
 /usr/include/c++/8/backward/binders.h \
 /usr/include/c++/8/bits/range_access.h \
 /usr/include/c++/8/initializer_list \
 /usr/include/c++/8/bits/basic_string.h \
 /usr/include/c++/8/ext/atomicity.h \
 /usr/include/x86_64-linux-gnu/c++/8/bits/gthr.h \
 /usr/include/x86_64-linux-gnu/c++/8/bits/gthr-default.h \
 /usr/x86_64-linux-gnu/include/pthread.h \
 /usr/x86_64-linux-gnu/include/sched.h \
 /usr/x86_64-linux-gnu/include/bits/types/time_t.h \
 /usr/x86_64-linux-gnu/include/bits/types/struct_timespec.h \
 /usr/x86_64-linux-gnu/include/bits/sched.h \
 /usr/x86_64-linux-gnu/include/bits/cpu-set.h \
 /usr/x86_64-linux-gnu/include/time.h \
 /usr/x86_64-linux-gnu/include/bits/time.h \
 /usr/x86_64-linux-gnu/include/bits/timex.h \
 /usr/x86_64-linux-gnu/include/bits/types/struct_timeval.h \
 /usr/x86_64-linux-gnu/include/bits/types/clock_t.h \
 /usr/x86_64-linux-gnu/include/bits/types/struct_tm.h \
 /usr/x86_64-linux-gnu/include/bits/types/clockid_t.h \
 /usr/x86_64-linux-gnu/include/bits/types/timer_t.h \
 /usr/x86_64-linux-gnu/include/bits/types/struct_itimerspec.h \
 /usr/x86_64-linux-gnu/include/bits/pthreadtypes.h \
 /usr/x86_64-linux-gnu/include/bits/thread-shared-types.h \
 /usr/x86_64-linux-gnu/include/bits/pthreadtypes-arch.h \
 /usr/x86_64-linux-gnu/include/bits/setjmp.h \
 /usr/include/x86_64-linux-gnu/c++/8/bits/atomic_word.h \
 /usr/include/c++/8/ext/alloc_traits.h \
 /usr/include/c++/8/bits/alloc_traits.h \
 /usr/include/c++/8/ext/string_conversions.h /usr/include/c++/8/cstdlib \
 /usr/x86_64-linux-gnu/include/stdlib.h \
 /usr/x86_64-linux-gnu/include/bits/waitflags.h \
 /usr/x86_64-linux-gnu/include/bits/waitstatus.h \
 /usr/x86_64-linux-gnu/include/sys/types.h \
 /usr/x86_64-linux-gnu/include/sys/select.h \
 /usr/x86_64-linux-gnu/include/bits/select.h \
 /usr/x86_64-linux-gnu/include/bits/types/sigset_t.h \
 /usr/x86_64-linux-gnu/include/bits/types/__sigset_t.h \
 /usr/x86_64-linux-gnu/include/sys/sysmacros.h \
 /usr/x86_64-linux-gnu/include/bits/sysmacros.h \
 /usr/x86_64-linux-gnu/include/alloca.h \
 /usr/x86_64-linux-gnu/include/bits/stdlib-float.h \
 /usr/include/c++/8/bits/std_abs.h /usr/include/c++/8/cerrno \
 /usr/x86_64-linux-gnu/include/errno.h \
 /usr/x86_64-linux-gnu/include/bits/errno.h \
 /usr/x86_64-linux-gnu/include/linux/errno.h \
 /usr/x86_64-linux-gnu/include/asm/errno.h \
 /usr/x86_64-linux-gnu/include/asm-generic/errno.h \
 /usr/x86_64-linux-gnu/include/asm-generic/errno-base.h \
 /usr/include/c++/8/bits/functional_hash.h \
 /usr/include/c++/8/bits/basic_string.tcc \
 /usr/include/c++/8/bits/locale_classes.tcc \
 /usr/include/c++/8/bits/locale_facets.h /usr/include/c++/8/cwctype \
 /usr/x86_64-linux-gnu/include/wctype.h \
 /usr/x86_64-linux-gnu/include/bits/wctype-wchar.h \
 /usr/include/x86_64-linux-gnu/c++/8/bits/ctype_base.h \
 /usr/include/c++/8/bits/ios_base.h /usr/include/c++/8/system_error \
 /usr/include/x86_64-linux-gnu/c++/8/bits/error_constants.h \
 /usr/include/c++/8/stdexcept /usr/include/c++/8/streambuf \
 /usr/include/c++/8/bits/streambuf.tcc \
 /usr/include/c++/8/bits/streambuf_iterator.h \
 /usr/include/x86_64-linux-gnu/c++/8/bits/ctype_inline.h \
 /usr/include/c++/8/bits/locale_facets.tcc \
 /usr/include/c++/8/bits/locale_facets_nonio.h /usr/include/c++/8/ctime \
 /usr/include/x86_64-linux-gnu/c++/8/bits/time_members.h \
 /usr/include/x86_64-linux-gnu/c++/8/bits/messages_members.h \
 /usr/x86_64-linux-gnu/include/libintl.h \
 /usr/include/c++/8/bits/codecvt.h \
 /usr/include/c++/8/bits/locale_facets_nonio.tcc \
 /usr/include/c++/8/bits/locale_conv.h \
 /usr/include/c++/8/bits/unique_ptr.h /usr/include/c++/8/utility \
 /usr/include/c++/8/bits/stl_relops.h /usr/include/c++/8/tuple \
 /usr/include/c++/8/array /usr/include/c++/8/bits/uses_allocator.h \
 /usr/include/c++/8/bits/invoke.h /usr/include/c++/8/fstream \
 /usr/include/c++/8/istream /usr/include/c++/8/ios \
 /usr/include/c++/8/bits/basic_ios.h \
 /usr/include/c++/8/bits/basic_ios.tcc /usr/include/c++/8/ostream \
 /usr/include/c++/8/bits/ostream.tcc /usr/include/c++/8/bits/istream.tcc \
 /usr/include/x86_64-linux-gnu/c++/8/bits/basic_file.h \
 /usr/include/x86_64-linux-gnu/c++/8/bits/c++io.h \
 /usr/include/c++/8/bits/fstream.tcc /usr/include/c++/8/iostream \
 /usr/include/c++/8/filesystem


amazing, no? cmake find only 9 dependencies against 100+ real ones (and I
don't even speak of errors that can be caused in parsing if some -D option
is changed....

thanks and regards
JLM


Le lun. 24 juin 2019 à 14:14, Robert Maynard <robert.maynard at kitware.com> a
écrit :

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190627/0ff3a01c/attachment-0001.html>


More information about the CMake mailing list