target_link_libraries not populating INCLUDE_DIRECTORIES?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

target_link_libraries not populating INCLUDE_DIRECTORIES?

Ciccio Pasticcio
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
Reply | Threaded
Open this post in threaded view
|

Re: target_link_libraries not populating INCLUDE_DIRECTORIES?

Mateusz Loskot
On Fri, 21 Dec 2018, 09:30 Ciccio Pasticcio <[hidden email] wrote:
> TARGET_INCLUDE_DIRECTORIES(PRIVATE private/ PUBLIC inc/)
> ... 
The manpage of TARGET_LINK_LIBRARIES says:
PRIVATE and PUBLIC items will populate the INCLUDE_DIRECTORIES property of <target>.

Yea, but are missing the actual <target> from your call. 

Mateusz Loskot, [hidden email]
(Sent from mobile) 

--

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
--
Mateusz Loskot
http://mateusz.loskot.net
Reply | Threaded
Open this post in threaded view
|

Re: target_link_libraries not populating INCLUDE_DIRECTORIES?

Marc CHEVRIER
In reply to this post by Ciccio Pasticcio
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 <[hidden email]>, 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

--

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