<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 19, 2018 at 3:44 AM, 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: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">Absolutely. Please find the example project here: <a href="https://github.com/samaursa/cmake_fetch_content_and_generator_expressions" target="_blank">https://github.com/<wbr>samaursa/cmake_fetch_content_<wbr>and_generator_expressions</a> <div><br></div><div>The repository README also includes the output from running `./setup.sh`. </div></div></blockquote><div><br></div><div><br></div><div>Okay that's much clearer, thanks. The example is doing what I'd expect and the generator expressions are also expected to be visible at the point your example is printing them. If you made your <font face="monospace, monospace">main</font> target link against <font face="monospace, monospace">LibA</font>, you'd see that CMake automatically expands out the generator expressions when it constructs the link command line for <font face="monospace, monospace">main</font>, so the example as it stands doesn't actually have any error.</div><div><br></div><div>Generator expressions are not expanded when CMake is processing the files (called the <i>configure</i> stage), they are expanded only when writing out the Makefiles during the <i>generation</i> stage. When running cmake from the command line, one doesn't tend to think of these two phases as being distinct, but you can see it at the end of the cmake log with these two messages:</div><div><br></div><div><div>-- Configuring done</div><div>-- Generating done</div></div><div><br></div><div>It is clearer when using the CMake GUI application because you get two different buttons, one for Configure and another for Generate, so you have to trigger both phases manually. So if you look at the contents of various properties and variables with CMake commands like <font face="monospace, monospace">message(...)</font>, you are doing that during the configure stage and therefore will see unexpanded generator expressions.</div><div><br></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 class="gmail-HOEnZb"><div class="gmail-h5"><br><div class="gmail_quote"><div dir="ltr">On Sat, Mar 17, 2018 at 6:47 PM Craig Scott <<a href="mailto:craig.scott@crascit.com" target="_blank">craig.scott@crascit.com</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">Can you provide a small project example that can be used to demonstrate your problem? The specifics of how you are doing things may be important.<br><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"></div></div><div class="gmail_extra"><div class="gmail_quote">On Sun, Mar 18, 2018 at 8:12 AM, Saad Khattak <span dir="ltr"><<a href="mailto:saadrustam@gmail.com" target="_blank">saadrustam@gmail.com</a>></span> wrote:<br></div></div><div class="gmail_extra"><div class="gmail_quote"><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">Hi,<div><br></div><div>ExternalProject_Add builds, generates and installs and thus any generator expressions used will be expanded by the time another library uses it. </div><div><br></div><div>For example, if I add a library LibA using ExternalProject_Add, I can then query the target property INTERFACE_INCLUDE_DIRECTORIES and get the include directory for the library:</div><div><br></div><div>get_target_property(LibA_<wbr>INCLUDE_DIRECTORIES LibA</div><div>  INTERFACE_INCLUDE_DIRECTORIES</div><div>  )</div><div><br></div><div>This allows me to then use the variable LibA_INCLUDE_DIRECTORIES in my CMake include(...) statements. However, with FetchContent, this is no longer possible.</div><div><br></div><div>The reason I would like to query a variable is because at project generation time, I invoke FetchContent only if LibA is not found by find_package(LibA). </div><div><br></div><div>Thus, the include directory for LibA may be in the current build directory (through FetchContent) OR it may be found in the folder where LibA is cloned by the user and generated/built OR an INSTALL of LibA.</div><div><br></div><div>Perhaps I should not be using `get_target_property` to get the a library's include directory? Either way, would like some guidance in solving this issue.</div><div><br></div><div>Thank you,</div><div>Saad</div><div><br></div></div>
<br></blockquote></div></div><div class="gmail_extra"><div class="gmail_quote"><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>
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="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/<wbr>listinfo/cmake</a><br>
<br></blockquote></div></div><div class="gmail_extra"><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_-753098783373090812m_-1725422429802086517gmail_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></blockquote></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="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>