<div dir="ltr"><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif;font-size:small"><div class="gmail_default">I found this solution helpful: </div><div class="gmail_default" style="font-family:arial,sans-serif;font-size:12.8px"><font face="trebuchet ms, sans-serif">  <a href="https://crascit.com/2015/07/25/cmake-gtest" target="_blank">https://crascit.com/2015/07/<wbr>25/cmake-gtest</a></font><br></div><div class="gmail_default" style="font-family:arial,sans-serif;font-size:12.8px"><font face="trebuchet ms, sans-serif">It is unfortunate that CMake doesn't have a proper way to accomplish this.</font></div></div><div class="gmail_extra">--James</div><div class="gmail_extra"><br></div><div class="gmail_extra">
<br><div class="gmail_quote">On Sun, Jan 8, 2017 at 10:07 PM, Hendrik Sattler <span dir="ltr"><<a href="mailto:post@hendrik-sattler.de" target="_blank">post@hendrik-sattler.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">One possibility is the often mentioned superbuild, another is not using find_library() but setting the variables with the library file paths manually (that's static info anyway).<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
Am 8. Januar 2017 22:49:52 MEZ schrieb Saad Khattak <<a href="mailto:saadrustam@gmail.com">saadrustam@gmail.com</a>>:<br>
>Hello,<br>
><br>
>I have an external project glfw that I added to my project like this:<br>
><br>
>==========<br>
>include(ExternalProject)<br>
>ExternalProject_Add(glfw<br>
>  GIT_REPOSITORY "<a href="https://github.com/glfw/glfw.git" rel="noreferrer" target="_blank">https://github.com/glfw/glfw.<wbr>git</a>"<br>
>  GIT_TAG "master"<br>
><br>
>  SOURCE_DIR "${CMAKE_SOURCE_DIR}/dep/glfw"<br>
>  CMAKE_ARGS -DGLFW_BUILD_DOCS=OFF -DGLFW_BUILD_TESTS=OFF<br>
>-DGLFW_BUILD_EXAMPLES=OFF<br>
>-DCMAKE_INSTALL_PREFIX=${<wbr>CMAKE_SOURCE_DIR}/install/<wbr>glfw/<br>
>-DCMAKE_DEBUG_POSTFIX=_d<br>
><br>
>  TEST_COMMAND ""<br>
>  )<br>
>set(GLFW_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/install/<wbr>glfw/include/")<br>
>set(GLFW_LIBRARY_DIR "${CMAKE_SOURCE_DIR}/install/<wbr>glfw/lib/")<br>
>==========<br>
><br>
>Then I include it in my project like so:<br>
><br>
>==========<br>
>find_library(GLFW_LIB_D  glfw3_d ${GLFW_LIBRARY_DIR})<br>
>find_library(GLFW_LIB    glfw3   ${GLFW_LIBRARY_DIR})<br>
><br>
>include_directories(${GLFW_<wbr>INCLUDE_DIR})<br>
><br>
>add_executable(vk_test<br>
>  src/vulkan_test.cpp<br>
>  )<br>
>target_link_libraries(vk_test debug ${GLFW_LIB_D} optimized<br>
>${GLFW_LIB})<br>
>add_dependencies(vk_test glfw)<br>
>==========<br>
><br>
>As you can see, I depend on the libraries compiled by the external<br>
>project<br>
>glfw. Unfortunately, when I first configure the project, CMake<br>
>complains<br>
>that it cannot find the libraries specified by ${GLFW_LIB_D} and<br>
>${GLFW_LIB} variables.<br>
><br>
>Of course, this is because CMake did not begin cloning, configuring and<br>
>building the glfw project. That only happens AFTER my project has been<br>
>configured and starts building. This becomes a chicken and the egg<br>
>problem.<br>
><br>
>Currently, my solution is to add dummy .lib files so that I can at<br>
>least<br>
>configure and generate my project. My question is, am I approaching<br>
>this<br>
>problem in the wrong way? If yes, what is the correct way to add a<br>
>dependency to an external project and have it clone/configure/build<br>
>BEFORE<br>
>the "find_library" call?<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.<br>
</font></span><div class="HOEnZb"><div class="h5">--<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>
</div></div></blockquote></div><br></div></div>