<div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 26, 2019 at 4:02 AM Dustyn Blasig <<a href="mailto:dustyn@blasig.us">dustyn@blasig.us</a>> wrote:<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"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi All,<div><br></div><div>I'm really struggling to use ExternalProject_Add() in our CMake project.</div><div><br></div><div>Based on the documentation, I was expecting the simplest Git-based external project with all defaults to act just like using a Git submodule locked at a specific commit. </div><div><pre style="padding:5px;background-color:rgb(238,238,238);color:rgb(51,51,51);line-height:15.6px;border-top-width:1px;border-style:solid none;border-top-color:rgb(170,204,153);border-bottom-width:1px;border-bottom-color:rgb(170,204,153)"><span class="gmail-m_-5725835497228738977gmail-nf" style="color:rgb(0,112,32)">include(</span><span class="gmail-m_-5725835497228738977gmail-nb">ExternalProject</span><span class="gmail-m_-5725835497228738977gmail-nf" style="color:rgb(0,112,32)">)</span><span class="gmail-m_-5725835497228738977gmail-w" style="color:rgb(187,187,187)"></span>
<span class="gmail-m_-5725835497228738977gmail-nf" style="color:rgb(0,112,32)">ExternalProject_Add(</span><span class="gmail-m_-5725835497228738977gmail-nb">foobar</span><span class="gmail-m_-5725835497228738977gmail-w" style="color:rgb(187,187,187)"></span>
<span class="gmail-m_-5725835497228738977gmail-w" style="color:rgb(187,187,187)"> </span><span class="gmail-m_-5725835497228738977gmail-no" style="color:rgb(64,112,160)">GIT_REPOSITORY</span><span class="gmail-m_-5725835497228738977gmail-w" style="color:rgb(187,187,187)"> </span><span class="gmail-m_-5725835497228738977gmail-na" style="color:rgb(144,96,96)">git@github.com:FooCo/FooBar.git</span><span class="gmail-m_-5725835497228738977gmail-w" style="color:rgb(187,187,187)"></span>
<span class="gmail-m_-5725835497228738977gmail-w" style="color:rgb(187,187,187)"> </span><span class="gmail-m_-5725835497228738977gmail-no" style="color:rgb(64,112,160)">GIT_TAG</span><span class="gmail-m_-5725835497228738977gmail-w" style="color:rgb(187,187,187)"> </span><span class="gmail-m_-5725835497228738977gmail-na" style="color:rgb(144,96,96)">origin/release/1.2.3</span><span class="gmail-m_-5725835497228738977gmail-w" style="color:rgb(187,187,187)"></span>
<span class="gmail-m_-5725835497228738977gmail-nf" style="color:rgb(0,112,32)">)</span></pre></div><div>The documentation states "The default configure command runs CMake with options based on the main project.", so I was expecting any options we pass to the owning project such as CMAKE_INSTALL_PREFIX and other variables would get propagated to the ExternalProject. However, that doesn't seem to be the case. Do I need to explicitly apply every variable through the "CMAKE_ARGS" options? If so, </div></div></div></div></div></blockquote><div><br></div><div>Some basic details are passed down to the external project, but I don't recall exactly which variables. I don't think there are a lot of them and I do tend to find that I need to pass down some vars in my own projects. You may have to dig into the ExternalProject module's source to get confirmation for yourself, possibly also look into what the external_process() command's implementation does as well.</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"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Also, unless I specify a custom CONFIGURE_COMMAND, I can't figure out how to make the configure step happen during the parent projects configure step. Should that be happening? If not, is there a simple way to force it to happen without having to duplicate everything the default options do? I'm seeing mixed results with online resources, along with many older examples that just don't work anymore.<br></div></div></div></div></div></blockquote></div><div><br></div><div>The external project's configure step happens during the main project's build stage, just like every other step of ExternalProject_Add(). This will be the case whether you override the CONFIGURE_COMMAND or not. If you really need the configure step to occur during the main project's configure stage, then you have at least a couple of options:</div><div><ul><li>Consider using the FetchContent module instead and bring the external project into your main build directly. If this suits your scenario, then I'd recommend this method. I use this a lot and it seems to be growing in popularity. It requires CMake 3.11 or later.</li><li>Go for a pure superbuild approach where your main project does nothing more than call various ExternalProject functions to tie together different external projects (i.e. your main project doesn't add any targets, etc. of its own). This will mean that even though the configure steps all occur during the main project's build step, you can control the dependencies between the different external projects' steps so that they can find what they need from each other (I'm guessing here that you want the external project's configure stage to run during your main project's build stage so that something later in your main project's configure stage can make use of something the external project's configure stage does). You will still have to explicitly specify a number of variables to be passed through to each external project's configure stage though, so maybe this doesn't solve the problem you are facing.</li></ul></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><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><br></div><div>Get the hand-book for every CMake user: <a href="https://crascit.com/professional-cmake/" target="_blank">Professional CMake: A Practical Guide</a><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>