[CMake] Listing all the include directories

Robert Maynard robert.maynard at kitware.com
Tue Mar 27 10:47:08 EDT 2018


In general your options are to look at the command line or use
cmake-server mode to query the code model. The full set of include
directories is not known while configuring due to generator
expressions expanding after the configure step.

On Mon, Mar 26, 2018 at 9:45 PM, Saad Khattak <saadrustam at gmail.com> wrote:
> Hi,
>
> I have many libraries and packages that are being linked using
> target_link_libraries(...) where CMake takes care of the include
> directories. There are cases where I get compile errors because I don't know
> the exact include directories.
>
> I thought perhaps I could get the include directories of my target by doing
> the following:
>
> get_target_property(INCLUDE_DIRS MyExeThatLinksToManyLibs
> INCLUDE_DIRECTORIES)
> message(STATUS ${INCLUDE_DIRS}) # hoped that this would print all the
> include directories
>
> Unfortunately, that did not work as expected. It was missing directories
> that I know are added to the include directories of the target (because the
> compiler is able to find the headers properly).
>
> Apart from sifting through the compile commands, is there a nice way to
> debug the include directories of a target?
>
> Thank you,
> Saad
>
> --
>
> 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