<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">Den 29. okt. 2017 kl. 02.06 skrev J Decker <<a href="mailto:d3ck0r@gmail.com" class="">d3ck0r@gmail.com</a>>:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I recently added externaproject_add() to download a library, but since it doesn't do the download until build, I had to put a conditional around the second part of the cmake that used the libraries it produced so it would do a cmake configure/generate, cmake build, cmake configure/generate and a final build and all was good... <div class=""><br class=""></div></div></div></blockquote>Yes… that sound exactly like the problem I am currently facing..<br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><a href="https://github.com/d3x0r/sack.vfs/blob/master/CMakeLists.gui.txt#L61" class="">https://github.com/d3x0r/sack.vfs/blob/master/CMakeLists.gui.txt#L61</a><br class=""></div></div></div></blockquote><div>I am not sure I understand how your if statement fixes this?.. when does it download?</div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">but I coudln't reference any directories that didn't exist yet in include_directories, or link_directories...until the project had been at least partially built.</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sat, Oct 28, 2017 at 6:00 PM, Craig Scott <span dir="ltr" class=""><<a href="mailto:craig.scott@crascit.com" target="_blank" class="">craig.scott@crascit.com</a>></span> wrote:<br class=""></div></div></div></blockquote><div>it still doesn’t work… </div><div><br class=""></div><div>I am bit unsure of what is being done here..  I need to include the libraryportaudio.a to include portaudio into the project. </div><div><br class=""></div><div>which causes an error as the download only occurs during build (make) and not during cmake. </div><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Ah, sorry. This particular problem <a href="https://gitlab.kitware.com/cmake/cmake/merge_requests/1264" target="_blank" class="">has been fixed</a> on CMake master, but it won't be in the 3.10 release (in release candidate stage), so that isn't going to help you right now. Possibly you might be able to modify the relevant target property directly rather than using target_include_directories() - again this is untested, but worth a try:<div class=""><br class=""></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><div class="">set_property(TARGET portaudio APPEND PROPERTY</div><div class="">    INTERFACE_INCLUDE_DIRECTORIES <span style="font-size:12.800000190734863px" class=""><wbr class="">${SOURCE_DIR}/include</span></div><div class=""><span style="font-size:12.800000190734863px" class="">)</span></div></blockquote><div class=""><span style="font-size:12.800000190734863px" class=""><br class=""></span></div><div class=""><span style="font-size:12.800000190734863px" class="">If that doesn't work, then I guess modifying your original method to use the correct path may be an alternative workaround:</span></div><div class=""><span style="font-size:12.800000190734863px" class=""><br class=""></span></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><div class=""><span style="font-size:12.800000190734863px" class="">target_include_directories(</span><span style="font-size:12.800000190734863px" class="">rec<wbr class="">ord PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} </span><span style="font-size:12.800000190734863px" class="">${<wbr class="">SOURCE_DIR}/include</span><span style="font-size:12.800000190734863px" class="">)</span></div></blockquote><div class=""><br style="font-size:12.800000190734863px" class=""></div><div class=""><span style="font-size:12.800000190734863px" class=""><br class=""></span></div><div class=""><br class=""></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sun, Oct 29, 2017 at 11:47 AM, Carlton Banks <span dir="ltr" class=""><<a href="mailto:noflaco@gmail.com" target="_blank" class="">noflaco@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">Den 29. okt. 2017 kl. 02.29 skrev Craig Scott <<a href="mailto:craig.scott@crascit.com" target="_blank" class="">craig.scott@crascit.com</a>>:</div><br class="m_-2705398934767925011m_-4802676557684340219Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sun, Oct 29, 2017 at 11:26 AM, Carlton Banks <span dir="ltr" class=""><<a href="mailto:noflaco@gmail.com" target="_blank" class="">noflaco@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div style="margin:0px;line-height:normal;font-family:'Andale Mono';color:rgb(40,254,20);background-color:rgba(0,0,0,0.901961)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">CMake Error at src/include/record/CMakeLists.<wbr class="">txt:28 (target_include_directories):</span></div><div style="margin:0px;line-height:normal;font-family:'Andale Mono';color:rgb(40,254,20);background-color:rgba(0,0,0,0.901961)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">  Cannot specify include directories for imported target "portaudio".</span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class="">is the problem that externalProject_add only is executed when make is executed and not when cmake is executed’?</span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class="">what is `portaudio` here referring to?</span></div></div></blockquote><div class=""><br class=""></div><div class="">The name "portaudio" is the target defined by the add_library() call in my example (the imported target that represents what the ExternalProject_Add() is going to create at build time). </div></div></div></div></div></blockquote></span><div class=""><span class="m_-2705398934767925011m_-4802676557684340219Apple-tab-span" style="white-space:pre-wrap">       </span>ok.</div><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">Did you also try the INTERFACE IMPORTED alternative? </div></div></div></div></div></blockquote></span><div class="">Still the same.. </div><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">It would be more useful if you showed the full CMakeLists.txt rather than just the error message.</div><div class=""><br class=""></div></div></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">The submodule cmakelist: </div><div class=""><br class=""></div><div class=""><a href="https://pastebin.com/x2WNhK56" target="_blank" class="">https://pastebin.com/x2WNhK56</a></div><div class=""><br class=""></div><div class="">tree structure</div><div class=""><br class=""></div><div class=""><a href="https://pastebin.com/xhPNCkN2" target="_blank" class="">https://pastebin.com/xhPNCkN2</a></div><div class=""><br class=""></div><div class="">The outer cmakelist includes the inner directories. </div><div class=""><div class="m_-2705398934767925011h5"><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><div class="m_-2705398934767925011m_-4802676557684340219h5"><div class=""><blockquote type="cite" class=""><div class="">Den 29. okt. 2017 kl. 02.19 skrev Craig Scott <<a href="mailto:craig.scott@crascit.com" target="_blank" class="">craig.scott@crascit.com</a>>:</div><br class="m_-2705398934767925011m_-4802676557684340219m_1483269101489427805Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sun, Oct 29, 2017 at 10:36 AM, Carlton Banks <span dir="ltr" class=""><<a href="mailto:noflaco@gmail.com" target="_blank" class="">noflaco@gmail.com</a>></span> wrote:<br class=""><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">I seem to have some problems executing one of my submodules cmakelist.<br class="">
<br class="">
MESSAGE(“In record CMAKELIST”)<br class="">
<br class="">
# Include externalproject {portaudio} if lib/portaudio don't exist.<br class="">
MESSAGE(“Download external project”)<br class="">
<br class="">
INCLUDE(ExternalProject)<br class="">
ExternalProject_Add(project_po<wbr class="">rtaudio<br class="">
    GIT_REPOSITORY      <a href="https://git.assembla.com/portaudio.git" rel="noreferrer" target="_blank" class="">https://git.assembla.com/porta<wbr class="">udio.git</a><br class="">
    PREFIX              lib/portaudio<br class="">
    CONFIGURE_COMMAND   <SOURCE_DIR>/configure<br class="">
    BUILD_IN_SOURCE     1<br class="">
    BUILD_COMMAND       make<br class="">
    INSTALL_COMMAND     sudo make install<br class="">
)<br class="">
ExternalProject_Get_Property(p<wbr class="">roject_portaudio BINARY_DIR)<br class="">
ExternalProject_Get_Property(p<wbr class="">roject_portaudio SOURCE_DIR)<br class="">
<br class="">
SET(portaudio_lib_dir "${BINARY_DIR}/lib/.libs")<br class="">
SET(portaudio_inc_dir "${SOURCE_DIR}/include")<br class="">
<br class="">
add_library(record STATIC record.cpp record.h)<br class="">
add_library(libaudio libportaudio.a PATHS ${portaudio_lib_dir})<br class=""></blockquote><div class=""><br class=""></div><div class="">What is this second add_library() command intended to do? I'm guessing you probably instead want to be doing something like this (untested, but hopefully in the ballpark):</div><div class=""><br class=""></div></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">add_library(portaudio STATIC IMPORTED)</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div class="">set_target_properties(portaudi<wbr class="">o PROPERTIES</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div class="">    IMPORTED_LOCATION ${BINARY_DIR}/lib/.libs/libpor<wbr class="">taudio.a</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div class="">)</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div class="">target_include_directories(por<wbr class="">taudio INTERFACE</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div class="">    ${SOURCE_DIR}/include</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div class="">)</div></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">add_dependencies(portaudio project_portaudio)     # Not sure if this is allowed for imported targets though</div></div></div></blockquote><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">I don't recall off the top of my head whether STATIC IMPORTED or INTERFACE IMPORTED would be the right way to call add_library() in the above, so try the latter if the former doesn't work for you. </div><div class=""><br class=""></div><div class=""><br class=""></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">
<br class="">
<br class="">
<br class="">
#<br class="">
# this makes sure we have compiler flags that allow class::class() = default (>= C++11)<br class="">
target_compile_features(record PUBLIC cxx_defaulted_functions)<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
target_include_directories(rec<wbr class="">ord PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${project_portaudio})<br class=""></blockquote><div class=""><br class=""></div><div class="">You won't need this if you define the portaudio imported library as per my example above.</div><div class=""><br class=""></div><div class=""> </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">
<br class="">
<br class="">
It cannot find libportaudio.a as externalproject_add() is not being executed, the command it executes add_library, which fails as the project has not been downloaded…<br class="">
<br class="">
<br class="">
what is wrong here?<br class=""></blockquote><div class=""><br class=""></div><div class="">The reason for this specific problem is that there's no dependency relationship between the project_portaudio target defined by the ExternalProject_Add() call and the record target. Such a relationship is only created through a suitable call to target_link_libraries() or add_dependencies(), or through arguments like DEPENDS for commands that offer such features (e.g. add_custom_target() and add_custom_command()).</div></div><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="m_-2705398934767925011m_-4802676557684340219m_1483269101489427805gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class="">Craig Scott<br class=""><div class="">Melbourne, Australia</div><div class=""><a href="https://crascit.com/" target="_blank" class="">https://crascit.com</a><br class=""></div></div></div></div></div></div></div>
</div></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="m_-2705398934767925011m_-4802676557684340219gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class="">Craig Scott<br class=""><div class="">Melbourne, Australia</div><div class=""><a href="https://crascit.com/" target="_blank" class="">https://crascit.com</a><br class=""></div></div></div></div></div></div></div>
</div></div>
</div></blockquote></div></div></div><br class=""></div></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="m_-2705398934767925011gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class="">Craig Scott<br class=""><div class="">Melbourne, Australia</div><div class=""><a href="https://crascit.com/" target="_blank" class="">https://crascit.com</a><br class=""></div></div></div></div></div></div></div>
</div>
</div></div><br class="">--<br class="">
<br class="">
Powered by <a href="http://www.kitware.com/" rel="noreferrer" target="_blank" class="">www.kitware.com</a><br class="">
<br class="">
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank" class="">http://www.cmake.org/Wiki/<wbr class="">CMake_FAQ</a><br class="">
<br class="">
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br class="">
<br class="">
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank" class="">http://cmake.org/cmake/help/<wbr class="">support.html</a><br class="">
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank" class="">http://cmake.org/cmake/help/<wbr class="">consulting.html</a><br class="">
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank" class="">http://cmake.org/cmake/help/<wbr class="">training.html</a><br class="">
<br class="">
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank" class="">http://www.kitware.com/<wbr class="">opensource/opensource.html</a><br class="">
<br class="">
Follow this link to subscribe/unsubscribe:<br class="">
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank" class="">http://public.kitware.com/<wbr class="">mailman/listinfo/cmake</a><br class=""></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>