[CMake] target_link_libraries not populating INCLUDE_DIRECTORIES?

Marc CHEVRIER marc.chevrier at gmail.com
Fri Dec 21 04:06:18 EST 2018


Command target_link_libraries do not populate directly the properties of the target due to many constraints regarding the values given to the command (generator expressions, other targets, etc…).

The full contents is taken into account at generation time not at the configuration time. This is why you cannot get full information using command get_target_property which is evaluated at configuration time.
Le 21 déc. 2018 à 09:30 +0100, Ciccio Pasticcio <dodungocorporation at gmail.com>, a écrit :
> Hi all,
>
> considering the following CMakeLists.txt:
>
> PROJECT(lib_foo)
> ADD_LIBRARY(lib_foo SHARED <src>)
> TARGET_INCLUDE_DIRECTORIES(PRIVATE private/ PUBLIC inc/)
> FIND_PACKAGE(Boost 1.55 REQUIRED COMPONENTS chrono system)
> TARGET_LINK_LIBRARIES(lib_foo PRIVATE Boost::chrono Boost::system)
> GET_TARGET_PROPERTIES(tinc lib_foo INCLUDE_DIRECTORIES)
> MESSAGE(STATUS "Include dirs: ${tinc}")
>
> I would expect a message with my private/ and inc/ paths, plus the one that comes with the Boost libraries, instead I only get the directories specified in TARGET_INCLUDE_DIRECTORIES. The manpage of TARGET_LINK_LIBRARIES says:
> PRIVATE and PUBLIC items will populate the INCLUDE_DIRECTORIES property of <target>.
>
> If I print Boost_INCLUDE_DIR I found the inclusion path.
>
> Am I missing something?
>
> Thanks,
> Gabriele
> --
>
> 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/20181221/8ec120f3/attachment.html>


More information about the CMake mailing list