<div dir="ltr">Ah, sorry. This particular problem <a href="https://gitlab.kitware.com/cmake/cmake/merge_requests/1264">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><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>set_property(TARGET portaudio APPEND PROPERTY</div><div>    INTERFACE_INCLUDE_DIRECTORIES <span style="font-size:12.800000190734863px">${SOURCE_DIR}/include</span></div><div><span style="font-size:12.800000190734863px">)</span></div></blockquote><div><span style="font-size:12.800000190734863px"><br></span></div><div><span style="font-size:12.800000190734863px">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><span style="font-size:12.800000190734863px"><br></span></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-size:12.800000190734863px">target_include_directories(</span><wbr style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} </span><span style="font-size:12.800000190734863px">${SOURCE_DIR}/include</span><span style="font-size:12.800000190734863px">)</span></div></blockquote><div><br style="font-size:12.800000190734863px"></div><div><span style="font-size:12.800000190734863px"><br></span></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 29, 2017 at 11:47 AM, Carlton Banks <span dir="ltr"><<a href="mailto:noflaco@gmail.com" target="_blank">noflaco@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 style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>Den 29. okt. 2017 kl. 02.29 skrev Craig Scott <<a href="mailto:craig.scott@crascit.com" target="_blank">craig.scott@crascit.com</a>>:</div><br class="m_-4802676557684340219Apple-interchange-newline"><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 29, 2017 at 11:26 AM, Carlton Banks <span dir="ltr"><<a href="mailto:noflaco@gmail.com" target="_blank">noflaco@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 style="word-wrap:break-word"><div style="margin:0px;line-height:normal;font-family:'Andale Mono';color:rgb(40,254,20);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures">CMake Error at src/include/record/CMakeLists.<wbr>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)"><span style="font-variant-ligatures:no-common-ligatures">  Cannot specify include directories for imported target "portaudio".</span></div><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div><span style="font-variant-ligatures:no-common-ligatures">is the problem that externalProject_add only is executed when make is executed and not when cmake is executed’?</span></div><div><span style="font-variant-ligatures:no-common-ligatures">what is `portaudio` here referring to?</span></div></div></blockquote><div><br></div><div>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><span class="m_-4802676557684340219Apple-tab-span" style="white-space:pre-wrap">  </span>ok.</div><span class=""><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Did you also try the INTERFACE IMPORTED alternative? </div></div></div></div></div></blockquote></span><div>Still the same.. </div><span class=""><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>It would be more useful if you showed the full CMakeLists.txt rather than just the error message.</div><div><br></div></div></div></div></div></blockquote><div><br></div></span><div>The submodule cmakelist: </div><div><br></div><div><a href="https://pastebin.com/x2WNhK56" target="_blank">https://pastebin.com/x2WNhK56</a></div><div><br></div><div>tree structure</div><div><br></div><div><a href="https://pastebin.com/xhPNCkN2" target="_blank">https://pastebin.com/xhPNCkN2</a></div><div><br></div><div>The outer cmakelist includes the inner directories. </div><div><div class="h5"><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div> </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"><div><div class="m_-4802676557684340219h5"><div><blockquote type="cite"><div>Den 29. okt. 2017 kl. 02.19 skrev Craig Scott <<a href="mailto:craig.scott@crascit.com" target="_blank">craig.scott@crascit.com</a>>:</div><br class="m_-4802676557684340219m_1483269101489427805Apple-interchange-newline"><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 29, 2017 at 10:36 AM, Carlton Banks <span dir="ltr"><<a href="mailto:noflaco@gmail.com" target="_blank">noflaco@gmail.com</a>></span> wrote:<br><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>
<br>
MESSAGE(“In record CMAKELIST”)<br>
<br>
# Include externalproject {portaudio} if lib/portaudio don't exist.<br>
MESSAGE(“Download external project”)<br>
<br>
INCLUDE(ExternalProject)<br>
ExternalProject_Add(project_po<wbr>rtaudio<br>
    GIT_REPOSITORY      <a href="https://git.assembla.com/portaudio.git" rel="noreferrer" target="_blank">https://git.assembla.com/porta<wbr>udio.git</a><br>
    PREFIX              lib/portaudio<br>
    CONFIGURE_COMMAND   <SOURCE_DIR>/configure<br>
    BUILD_IN_SOURCE     1<br>
    BUILD_COMMAND       make<br>
    INSTALL_COMMAND     sudo make install<br>
)<br>
ExternalProject_Get_Property(p<wbr>roject_portaudio BINARY_DIR)<br>
ExternalProject_Get_Property(p<wbr>roject_portaudio SOURCE_DIR)<br>
<br>
SET(portaudio_lib_dir "${BINARY_DIR}/lib/.libs")<br>
SET(portaudio_inc_dir "${SOURCE_DIR}/include")<br>
<br>
add_library(record STATIC record.cpp record.h)<br>
add_library(libaudio libportaudio.a PATHS ${portaudio_lib_dir})<br></blockquote><div><br></div><div>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><br></div></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div>add_library(portaudio STATIC IMPORTED)</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div>set_target_properties(portaudi<wbr>o PROPERTIES</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div>    IMPORTED_LOCATION ${BINARY_DIR}/lib/.libs/libpor<wbr>taudio.a</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div>)</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div>target_include_directories(por<wbr>taudio INTERFACE</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div>    ${SOURCE_DIR}/include</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div>)</div></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div>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><br></div><div>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><br></div><div><br></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>
<br>
<br>
#<br>
# this makes sure we have compiler flags that allow class::class() = default (>= C++11)<br>
target_compile_features(record PUBLIC cxx_defaulted_functions)<br>
<br>
<br>
<br>
<br>
target_include_directories(rec<wbr>ord PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${project_portaudio})<br></blockquote><div><br></div><div>You won't need this if you define the portaudio imported library as per my example above.</div><div><br></div><div> </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>
<br>
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>
<br>
<br>
what is wrong here?<br></blockquote><div><br></div><div>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"><div><br></div>-- <br><div class="m_-4802676557684340219m_1483269101489427805gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com/" target="_blank">https://crascit.com</a><br></div></div></div></div></div></div></div>
</div></div>
</div></blockquote></div><br></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_-4802676557684340219gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com/" target="_blank">https://crascit.com</a><br></div></div></div></div></div></div></div>
</div></div>
</div></blockquote></div></div></div><br></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div></div></div></div></div></div></div>
</div>