<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Aug 29, 2019 at 11:14 PM Stéphane Ancelot <<a href="mailto:sancelot@numalliance.com">sancelot@numalliance.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<p>hi,</p>
<p>i used fetch_content to download bullet library , but I cant use
it.<br>
</p>
<p>FetchContent_Declare(<br>
bullet<br>
GIT_REPOSITORY <a class="gmail-m_-753477881839068158moz-txt-link-freetext" href="https://github.com/bulletphysics/bullet3.git" target="_blank">https://github.com/bulletphysics/bullet3.git</a><br>
GIT_TAG 2.88<br>
<br>
)<br>
<br>
FetchContent_GetProperties(bullet)<br>
if(NOT bullet_POPULATED)<br>
FetchContent_Populate(bullet)<br>
add_subdirectory(${bullet_SOURCE_DIR} ${bullet_BINARY_DIR})<br>
endif()<br>
</p>
<p>linking using bullet does not permit to find any include or lib
file</p></div>
</blockquote></div>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.<div><br></div><div>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:</div><div><br></div><div><font face="monospace">if(NOT bullet_POPULATED)<br> FetchContent_Populate(bullet)<br> add_subdirectory(${bullet_SOURCE_DIR} ${bullet_BINARY_DIR}</font></div><div><font face="monospace"> target_include_directories(Bullet3Common INTERFACE</font></div><div><font face="monospace"> ${bullet_SOURCE_DIR}/src</font></div><div><font face="monospace"> ${bullet_SOURCE_DIR}/src/Bullet3Common</font></div><div><font face="monospace"> ... more as you work out what is needed</font></div><div><font face="monospace"> )<br>endif()</font><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div><div><br></div><div>Get the hand-book for every CMake user: <a href="https://crascit.com/professional-cmake/" target="_blank">Professional CMake: A Practical Guide</a><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>