<div dir="ltr">Hi,<div><br></div><div>I would like to know how to use the FetchContent properly so that I can link against downloaded (CMake enabled) projects. I have looked at the CMake docs, which although are quite thorough, almost always fail to list a complete example which is incredibly crucial to get up and running quickly.</div><div><br></div><div>With ExternalProject_Add, we use add_dependencies(...) but that doesn't seem to be the case for FetchContent. Since I can immediately call add_subdirectory(...), I assumed that I can simply link to the library. But that doesn't seem to do anything.</div><div><br></div><div>Here's my CMakeLists.txt<br></div><div>``````````````````````````````````````````````````````````````</div><div><div>cmake_minimum_required(VERSION 3.5)</div><div>project(testProj)<br></div><div><br></div><div>include(FetchContent)</div><div><br></div><div>FetchContent_Declare(</div><div>  Catch2</div><div>  GIT_REPOSITORY "<a href="https://github.com/catchorg/Catch2">https://github.com/catchorg/Catch2</a>"</div><div>  TEST_COMMAND ""</div><div>  )</div><div><br></div><div>FetchContent_GetProperties(catch)</div><div>if(NOT Catch2_POPULATED)</div><div>  FetchContent_Populate(Catch2)</div><div>  add_subdirectory(${Catch2_SOURCE_DIR} ${Catch2_BINARY_DIR})</div><div>endif()</div><div><br></div><div>add_executable(testExe main.cpp)</div><div><br></div><div>target_link_libraries(testExe Catch2)</div></div><div>``````````````````````````````````````````````````````````````<br></div><div><br></div><div>CMake populates Catch2 with Catch2-NOTFOUND.</div><div><br></div><div>So, my question is, how do I link against projects added through FetchContent?</div><div><br></div><div>- Saad</div></div>