<div dir="ltr">I managed to find a solution myself:<div><br><div>``````````````````````````````````````````````````````````````<br></div><div><div>cmake_minimum_required(VERSION 3.11)</div><div><br></div><div>project(testProj)</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>  )</div><div><br></div><div>FetchContent_GetProperties(Catch2) #mispelled name in original post</div><div>if(NOT Catch2_POPULATED)</div><div>  FetchContent_Populate(Catch2)</div><div>  message(STATUS "Catch source dir: ${catch2_SOURCE_DIR}")</div><div>  message(STATUS "Catch binary dir: ${catch2_BINARY_DIR}")</div><div>  add_subdirectory(${catch2_SOURCE_DIR} ${catch2_BINARY_DIR}) #can be case insensitive</div><div>endif()</div><div><br></div><div>add_executable(testExe</div><div>  main.cpp</div><div>  )</div><div><br></div><div>message(STATUS "Catch include dir: ${catch2_SOURCE_DIR}/include")</div><div><br></div><div>target_link_libraries(testExe Catch) #name of library to link is case sensitive!</div><div>``````````````````````````````````````````````````````````````<br></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Mar 11, 2018 at 8:02 PM Saad Khattak <<a href="mailto:saadrustam@gmail.com">saadrustam@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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" target="_blank">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><div dir="ltr"><div><br></div><div>- Saad</div></div></blockquote></div></div></div></div>