<div dir="ltr">The way to solve this is to use a superbuild project layout - you use ExternalProject_Add to build your dependencies AND your own project, using the DEPENDS option to control build order. Thus by the time it gets around to configuring your project, the dependencies have already been built and installed fully.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 8, 2017 at 3:49 PM, Saad Khattak <span dir="ltr"><<a href="mailto:saadrustam@gmail.com" target="_blank">saadrustam@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>I have an external project glfw that I added to my project like this:</div><div><br></div><div>==========</div><div><div>include(ExternalProject)</div><div>ExternalProject_Add(glfw</div><div>  GIT_REPOSITORY "<a href="https://github.com/glfw/glfw.git" target="_blank">https://github.com/glfw/glfw.<wbr>git</a>"</div><div>  GIT_TAG "master"</div><div><br></div><div>  SOURCE_DIR "${CMAKE_SOURCE_DIR}/dep/glfw"</div><div>  CMAKE_ARGS -DGLFW_BUILD_DOCS=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=${<wbr>CMAKE_SOURCE_DIR}/install/<wbr>glfw/ -DCMAKE_DEBUG_POSTFIX=_d</div><div><br></div><div>  TEST_COMMAND ""</div><div>  )</div></div><div><div>set(GLFW_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/install/<wbr>glfw/include/")</div><div>set(GLFW_LIBRARY_DIR "${CMAKE_SOURCE_DIR}/install/<wbr>glfw/lib/")</div></div><div>========== </div><div> <br></div><div>Then I include it in my project like so:</div><div><br></div><div>==========  <br></div><div><div>find_library(GLFW_LIB_D  glfw3_d ${GLFW_LIBRARY_DIR})</div><div>find_library(GLFW_LIB    glfw3   ${GLFW_LIBRARY_DIR})</div></div><div><br></div><div><div>include_directories(${GLFW_<wbr>INCLUDE_DIR})</div></div><div><br></div><div><div>add_executable(vk_test</div><div>  src/vulkan_test.cpp</div><div>  )</div><div>target_link_libraries(vk_test debug ${GLFW_LIB_D} optimized ${GLFW_LIB})</div><div>add_dependencies(vk_test glfw)<br></div><div>========== </div><div><br></div><div>As you can see, I depend on the libraries compiled by the external project glfw. Unfortunately, when I first configure the project, CMake complains that it cannot find the libraries specified by ${GLFW_LIB_D} and ${GLFW_LIB} variables. </div><div><br></div><div>Of course, this is because CMake did not begin cloning, configuring and building the glfw project. That only happens AFTER my project has been configured and starts building. This becomes a chicken and the egg problem.<br></div></div><div><br></div><div>Currently, my solution is to add dummy .lib files so that I can at least configure and generate my project. My question is, am I approaching this problem in the wrong way? If yes, what is the correct way to add a dependency to an external project and have it clone/configure/build BEFORE the "find_library" call?</div><div><br></div></div>
<br>--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/<wbr>CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/cmake</a><br></blockquote></div><br></div>