On Thu, Aug 29, 2019 at 11:14 PM Stéphane Ancelot <[email protected]>
wrote:

> hi,
>
> i used fetch_content to download bullet library , but I cant use it.
>
> FetchContent_Declare(
>   bullet
>   GIT_REPOSITORY https://github.com/bulletphysics/bullet3.git
>   GIT_TAG        2.88
>
> )
>
> FetchContent_GetProperties(bullet)
> if(NOT bullet_POPULATED)
>   FetchContent_Populate(bullet)
>   add_subdirectory(${bullet_SOURCE_DIR} ${bullet_BINARY_DIR})
> endif()
>
> linking using bullet does not permit to find any include or lib file
>
Your FetchContent usage looks fine. I had a quick scan through the bullet
project and it uses very old CMake patterns. In particular, it doesn't use
any of the target-centered commands like target_include_directories(), etc.
This means it doesn't define PUBLIC or INTERFACE properties on targets,
which is why when you try to link to the bullet targets and include its
headers, they aren't being found. Nothing is telling consumers of those
libraries where to look.

Ideally, the bullet project would update to more modern CMake practices,
but that's not always a priority for projects that others manage. If you
need to get this working for your build, you will have to manually add the
missing header search paths and inter-library dependencies in your own
project. You can still call target_include_directories() on the bullet
targets from outside of the bullet source tree. You would do this
immediately after the add_subdirectory() call, something like the following
structure:

if(NOT bullet_POPULATED)
  FetchContent_Populate(bullet)
  add_subdirectory(${bullet_SOURCE_DIR} ${bullet_BINARY_DIR}
  target_include_directories(Bullet3Common INTERFACE
    ${bullet_SOURCE_DIR}/src
    ${bullet_SOURCE_DIR}/src/Bullet3Common
    ... more as you work out what is needed
  )
endif()

-- 
Craig Scott
Melbourne, Australia
https://crascit.com

Get the hand-book for every CMake user: Professional CMake: A Practical
Guide <https://crascit.com/professional-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

Reply via email to