<div dir="ltr">For now, clearly it is not supported. Introducing a generator expression breaks the parsing of arguments of command target_link_libraries.<div><br><div>@Björn I suggest to you to log an issue (see <a href="https://gitlab.kitware.com/cmake/cmake/issues">https://gitlab.kitware.com/cmake/cmake/issues</a>) about that (don't forget to put a short example demonstrating the problem) to enable discussion about this and to identify a solution.</div></div></div><br><div class="gmail_quote"><div dir="ltr">Le jeu. 4 oct. 2018 à 19:09, Björn Blissing <<a href="mailto:bjorn.blissing@vti.se">bjorn.blissing@vti.se</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="SV" link="blue" vlink="purple">
<div class="m_-4178343558436954087WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hi Marc,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">If that is the case that mixing of “</span><span lang="EN-US">optimized</span><span lang="EN-US">” and “debug” keywords with generator expressions
is impossible, I think this should be mentioned in the official documentation. It took us the better part of an afternoon to track down why we suddenly had a dependency to a library called “</span><span lang="EN-US">optimized.lib”.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Other people seem to struggle with similar issues as well:<br>
<a href="https://www.google.com/search?q=optimized.lib+cmake" target="_blank">https://www.google.com/search?q=optimized.lib+cmake</a><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Björn<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From:</b> Marc CHEVRIER <<a href="mailto:marc.chevrier@gmail.com" target="_blank">marc.chevrier@gmail.com</a>> <br>
<b>Sent:</b> Thursday, October 4, 2018 6:59 PM<br>
<b>To:</b> Björn Blissing <<a href="mailto:bjorn.blissing@vti.se" target="_blank">bjorn.blissing@vti.se</a>><br>
<b>Cc:</b> Andrew Fuller <<a href="mailto:afuller@teradici.com" target="_blank">afuller@teradici.com</a>>; Eric Noulard <<a href="mailto:eric.noulard@gmail.com" target="_blank">eric.noulard@gmail.com</a>>; CMake Mailinglist <<a href="mailto:cmake@cmake.org" target="_blank">cmake@cmake.org</a>></p></div></div></div></div></div><div lang="SV" link="blue" vlink="purple"><div class="m_-4178343558436954087WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><br>
<b>Subject:</b> Re: [CMake] Trouble with conditional generator expression inside target_link_libraries<u></u><u></u></p></div></div></div></div></div><div lang="SV" link="blue" vlink="purple"><div class="m_-4178343558436954087WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">I am afraid that you cannot mix "optimized" or "debug" keywords with "generator expressions" because keywords handling is done during evaluation of command "target_link_libraries" and "generator expressions" are evaluated during generation.<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">And target_link_libraries expect following pattern: [<keyword>] <library> [<library> ...], so specifying a generator expression wrapping this breaks the parsing of the arguments: keyword is no longer at the beginning of the sequence so
it is no longer recognized as is...<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">So, The most efficient way to work-around this problem is to transform your list of libraries in valid generator expressions:<u></u><u></u></p>
</div>
<div>
<ul type="disc">
<li class="MsoNormal">
<span style="font-size:10.0pt">INITIAL: optimized foo debug food_d</span><u></u><u></u></li><li class="MsoNormal">
<span style="font-size:10.0pt">RESULT: $<$<CONFIG:RELEASE>:foo> $<$<CONFIG:DEBUG>:foo_d></span><u></u><u></u></li></ul>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt">For that purpose, an helper function can do the trick...</span><u></u><u></u></p>
</div>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div></div></div></div></div><div lang="SV" link="blue" vlink="purple"><div class="m_-4178343558436954087WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div>
<div>
<p class="MsoNormal">Le jeu. 4 oct. 2018 à 18:34, Björn Blissing <<a href="mailto:bjorn.blissing@vti.se" target="_blank">bjorn.blissing@vti.se</a>> a écrit :<u></u><u></u></p>
</div>
</div></div></div></div><div lang="SV" link="blue" vlink="purple"><div class="m_-4178343558436954087WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm"><div><div>
<p class="MsoNormal">Hi Andrew,<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">That works, but as previously said. The third party find module I am using do not differentiate between debug and release libraries. To make matters even worse
the keywords “optimized” and “debug” is already in the variable list, trying to split them will be painful.</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">The workaround I am using right now is to have an IF-statement for the list option:<br>
<br>
if(${USE_FOOLIB})</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> target_link_libraries(my_exe</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> PUBLIC</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> ${FOO_LIBRARIES}</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> )</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">endif()</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">target_link_libraries(my_exe</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> PUBLIC</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> $<$<BOOL:${USE_BARLIB}>:bar></span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">)</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">But that breaks the pattern with using generator expressions, as I do for the rest of my options.</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">I don’t know if this should be considered a bug, but it seems really strange that generator expressions should break down for only this special case, i.e. the
combination using lists with the conditional operator BOOL and using it inside target_link_libraries.
</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
</div></div></blockquote></div></div></div></div><div lang="SV" link="blue" vlink="purple"><div class="m_-4178343558436954087WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm"><div><div><p class="MsoNormal"><span lang="EN-US">I don’t know if other CMake functions will react similarly bad to the list/bool operator combo.</span><u></u><u></u></p></div></div></blockquote></div></div></div></div><div lang="SV" link="blue" vlink="purple"><div class="m_-4178343558436954087WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm"><div><div>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">Regards,</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">Björn</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From:</b> Andrew Fuller <<a href="mailto:afuller@teradici.com" target="_blank">afuller@teradici.com</a>>
<br>
<b>Sent:</b> Thursday, October 4, 2018 6:16 PM<u></u><u></u></p>
</div>
</div>
</div>
</div></div></blockquote></div></div></div></div><div lang="SV" link="blue" vlink="purple"><div class="m_-4178343558436954087WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><br>
<b>To:</b> Björn Blissing <<a href="mailto:bjorn.blissing@vti.se" target="_blank">bjorn.blissing@vti.se</a>>; Eric Noulard <<a href="mailto:eric.noulard@gmail.com" target="_blank">eric.noulard@gmail.com</a>><br>
<b>Cc:</b> CMake Mailinglist <<a href="mailto:cmake@cmake.org" target="_blank">cmake@cmake.org</a>><br>
<b>Subject:</b> Re: [CMake] Trouble with conditional generator expression inside target_link_libraries<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
<div>
<div>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<p class="MsoNormal"> <u></u><u></u></p>
<div id="m_-4178343558436954087m_-463496031544905875divtagdefaultwrapper">
<p><span style="font-size:12.0pt;color:black">What about this:</span><u></u><u></u></p>
<p><span style="font-size:12.0pt;color:black"> </span><u></u><u></u></p>
<p><span style="font-size:12.0pt;color:black"><br>
list(APPEND FOO_LIBRARIES_OPT foo) <br>
list(APPEND FOO_LIBRARIES_DBG foo_d) <br>
<br>
target_link_libraries(my_exe <br>
PUBLIC <br>
debug "$<$<BOOL:${USE_FOOLIB}>:${FOO_LIBRARIES_DBG}>" <br>
optimized "$<$<BOOL:${USE_FOOLIB}>:${FOO_LIBRARIES_OPT}>" <br>
"$<$<BOOL:${USE_BARLIB}>:bar>" <br>
)<br>
<br>
A little more verbose.</span><u></u><u></u></p>
</div>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="3" width="98%" align="center">
</div>
<div id="m_-4178343558436954087m_-463496031544905875divRplyFwdMsg">
<p class="MsoNormal"><b><span style="color:black">From:</span></b><span style="color:black"> Björn Blissing <<a href="mailto:bjorn.blissing@vti.se" target="_blank">bjorn.blissing@vti.se</a>><br>
<b>Sent:</b> October 4, 2018 9:00:28 AM<br>
<b>To:</b> Andrew Fuller; Eric Noulard<br>
<b>Cc:</b> CMake Mailinglist<br>
<b>Subject:</b> RE: [CMake] Trouble with conditional generator expression inside target_link_libraries</span>
<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="m_-4178343558436954087m-463496031544905875xmsonormal"><span lang="EN-US">Hi Andrew,</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xmsonormal" style="margin-bottom:12.0pt"><span lang="EN-US">When I put the genex inside double quotes I get:</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">optimized.lib;foo.lib;debug.lib;foo_d.lib;bar.lib; --- for both debug and release builds<br>
<br>
Regards,</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">Björn</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="m_-4178343558436954087m-463496031544905875xmsonormal"><b>From:</b> Andrew Fuller <<a href="mailto:afuller@teradici.com" target="_blank">afuller@teradici.com</a>>
<br>
<b>Sent:</b> Thursday, October 4, 2018 5:54 PM<br>
<b>To:</b> Björn Blissing <<a href="mailto:bjorn.blissing@vti.se" target="_blank">bjorn.blissing@vti.se</a>>; Eric Noulard <<a href="mailto:eric.noulard@gmail.com" target="_blank">eric.noulard@gmail.com</a>><br>
<b>Cc:</b> CMake Mailinglist <<a href="mailto:cmake@cmake.org" target="_blank">cmake@cmake.org</a>><br>
<b>Subject:</b> Re: [CMake] Trouble with conditional generator expression inside target_link_libraries<u></u><u></u></p>
</div>
</div>
<p class="m_-4178343558436954087m-463496031544905875xmsonormal"> <u></u><u></u></p>
<div id="m_-4178343558436954087m_-463496031544905875x_divtagdefaultwrapper">
<p><span style="font-size:12.0pt;color:black">What happens if you put the genex inside double quotes?</span><u></u><u></u></p>
<p><span style="font-size:12.0pt;color:black"> </span><u></u><u></u></p>
<div>
<p class="m_-4178343558436954087m-463496031544905875xmsonormal"><span style="font-size:12.0pt;color:black">target_link_libraries(my_exe</span><u></u><u></u></p>
</div>
<div>
<p class="m_-4178343558436954087m-463496031544905875xmsonormal"><span style="font-size:12.0pt;color:black"> PUBLIC</span><u></u><u></u></p>
</div>
<div>
<p class="m_-4178343558436954087m-463496031544905875xmsonormal"><span style="font-size:12.0pt;color:black"> "$<$<BOOL:${USE_FOOLIB}>:${FOO_LIBRARIES}>"</span><u></u><u></u></p>
</div>
<div>
<p class="m_-4178343558436954087m-463496031544905875xmsonormal"><span style="font-size:12.0pt;color:black"> "$<$<BOOL:${USE_BARLIB}>:bar>"</span><u></u><u></u></p>
</div>
<div>
<p class="m_-4178343558436954087m-463496031544905875xmsonormal"><span style="font-size:12.0pt;color:black">)</span><u></u><u></u></p>
</div>
<p class="m_-4178343558436954087m-463496031544905875xmsonormal"><span style="font-size:12.0pt;color:black"> </span><u></u><u></u></p>
</div>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="3" width="98%" align="center">
</div>
<div id="m_-4178343558436954087m_-463496031544905875x_divRplyFwdMsg">
<p class="m_-4178343558436954087m-463496031544905875xmsonormal"><b><span style="color:black">From:</span></b><span style="color:black"> CMake <<a href="mailto:cmake-bounces@cmake.org" target="_blank">cmake-bounces@cmake.org</a>> on behalf of Björn Blissing <<a href="mailto:bjorn.blissing@vti.se" target="_blank">bjorn.blissing@vti.se</a>><br>
<b>Sent:</b> October 4, 2018 8:49:19 AM<br>
<b>To:</b> Eric Noulard<br>
<b>Cc:</b> CMake Mailinglist<br>
<b>Subject:</b> Re: [CMake] Trouble with conditional generator expression inside target_link_libraries</span>
<u></u><u></u></p>
<div>
<p class="m_-4178343558436954087m-463496031544905875xmsonormal"> <u></u><u></u></p>
</div>
</div>
<div>
<div>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal">Hi Eric,<u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"> <u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">I tried to do a self contained minimal example:
</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">cmake_minimum_required(VERSION 3.12)</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">project(expension_error LANGUAGES CXX)</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">add_executable(my_exe main.cpp)</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">option(USE_FOOLIB "Use foo.lib" ON)</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">option(USE_BARLIB "Use bar.lib" ON)</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">list(APPEND FOO_LIBRARIES optimized foo)</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">list(APPEND FOO_LIBRARIES debug foo_d)</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">target_link_libraries(my_exe</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> PUBLIC</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> $<$<BOOL:${USE_FOOLIB}>:${FOO_LIBRARIES}></span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> $<$<BOOL:${USE_BARLIB}>:bar></span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">)</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">But when I run this script using CMake 3.12.2, it expands to something even worse:</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">$<1:optimized;foo.lib;foo_d>.lib;bar.lib --- for debug builds</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">$<1:optimized;foo.lib;>.lib;bar.lib-- for release builds</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">So something goes really wrong when I try to use a list inside a conditional generator expression inside target_link_libraries().</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">Regards,</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">Björn</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Eric Noulard <<a href="mailto:eric.noulard@gmail.com" target="_blank">eric.noulard@gmail.com</a>>
<br>
<b>Sent:</b> Thursday, October 4, 2018 5:10 PM<br>
<b>To:</b> Björn Blissing <<a href="mailto:bjorn.blissing@vti.se" target="_blank">bjorn.blissing@vti.se</a>><br>
<b>Cc:</b> CMake Mailinglist <<a href="mailto:cmake@cmake.org" target="_blank">cmake@cmake.org</a>><br>
<b>Subject:</b> Re: [CMake] Trouble with conditional generator expression inside target_link_libraries</span><u></u><u></u></p>
</div>
</div>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<div>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal" style="margin-bottom:12.0pt"><span lang="EN-US"> </span><u></u><u></u></p>
<div>
<div>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal">Le jeu. 4 oct. 2018 à 16:53, Björn Blissing <<a href="mailto:bjorn.blissing@vti.se" target="_blank">bjorn.blissing@vti.se</a>> a écrit :<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<div>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">Hello Eric,</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">The minimal example was just to display the expansion error. In real life the code uses a Boolean variable (and the rest of the CMake code is much larger as well).</span> <u></u><u></u></p>
</div>
</div>
</blockquote>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<div>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">It was just to show the expansion error you get if you try to use a conditional generator expression inside a target_link_libraries function.</span><u></u><u></u></p>
</div>
</div>
</blockquote>
<div>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"> <u></u><u></u></p>
</div>
<div>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal">Sometimes the devil is hiding in the details.<u></u><u></u></p>
</div>
<div>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal">Do ou manage to reproduce the genex expansion error on a toy example?<u></u><u></u></p>
</div>
<div>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<div>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">I do agree that using it would be simpler if I could use:</span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> $<$<CONFIG:Debug>:${MYLIBS_DEBUG}></span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> $<$<CONFIG:Release>:${MYLIBS_OPTIMIZED}></span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"><span lang="EN-US">But since I use a third party find module the MYLIB_LIBRARIES variable is not separated into these categories. I was hoping to avoid rewriting this external find module.</span><u></u><u></u></p>
</div>
</div>
</blockquote>
<div>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"> <u></u><u></u></p>
</div>
<div>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal">You can perfectly write a CMake helper function which takes MYLIB_LIBRARIES as input and spit out MYLIBS_DEBUG, MYLIBS_OPTIMIZED as an output.<u></u><u></u></p>
</div>
<div>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal">This way you don't have to rewrite 3rd party code and keep your code clean.<u></u><u></u></p>
</div>
</div>
<div>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal"> <u></u><u></u></p>
</div>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal">-- <u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<p class="m_-4178343558436954087m-463496031544905875xxmsonormal">Eric<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote></div></div></div></div><div lang="SV" link="blue" vlink="purple"><div class="m_-4178343558436954087WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm"><p class="MsoNormal">-- <br>
<br></p></blockquote></div></div></div></div><div lang="SV" link="blue" vlink="purple"><div class="m_-4178343558436954087WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm"><p class="MsoNormal">
Powered by <a href="http://www.kitware.com" 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" target="_blank">
http://www.cmake.org/Wiki/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" target="_blank">
http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">
http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">
http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">
http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake" target="_blank">https://cmake.org/mailman/listinfo/cmake</a><u></u><u></u></p></blockquote></div></div></div></div></blockquote></div>