<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:#606420;
        text-decoration:underline;}
p
        {mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman";}
pre
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:595.3pt 841.9pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
</head>
<body lang=FR link=blue vlink="#606420">
<div class=Section1>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>Hi,</span></font><span lang=EN-GB><o:p></o:p></span></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-GB
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>I'm facing an issue while trying to port my current
build system to cmake, and it seems there is no way to solve it currently.
At least, nobody in the mailing list found one. The only suggestion was to
totally recode the dependency mechanism with macros instead of relying on the
Cmake standard mechanism (as done in Boost), which doesn't really look like an
optimal use of cmake.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>Let me explain the problem again, and propose the
cmake api to solve it:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>----- PROBLEM:</span></font><span lang=EN-GB><o:p></o:p></span></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'> <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>It's a typical application of the C++ link time
variation idiom:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>In our project, we build a bunch of <strong><b><font
face=Arial><span style='font-family:Arial'>static</span></font></b></strong>
libs (about 360) and several executables on them.</span></font><span
lang=EN-GB><o:p></o:p></span></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-GB
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>* one library, in the middle of the lib dependency
chain, has in fact 2 different implementations. That is to say, there are 2
different libs with the exact same interface, but they don't use the same
back-end, have different source code, and don't have the same dependencies.</span></font><span
lang=EN-GB><o:p></o:p></span></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>* only one of them has to be used in every
executable, the implementation to use is determined by the executable.</span></font><span
lang=EN-GB><o:p></o:p></span></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-GB
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>Dependency graph example: "->" means
"depends on"</span></font><font face=Arial><span lang=EN-GB
style='font-family:Arial'><o:p></o:p></span></font></p>
<p class=MsoNormal><font size=3 face=Arial><span lang=EN-GB style='font-size:
12.0pt;font-family:Arial'> <o:p></o:p></span></font></p>
<p class=MsoNormal><strong><b><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'>exe1-A</span></font></b></strong><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:
"Courier New"'> -> lib1 -> lib3 -> <strong><b><font
face="Courier New"><span style='font-family:"Courier New"'>lib4-A</span></font></b></strong>
-> lib5 -> lib7</span></font><font face=Arial><span lang=EN-GB
style='font-family:Arial'><o:p></o:p></span></font></p>
<p class=MsoNormal><strong><b><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'>exe1-B</span></font></b></strong><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:
"Courier New"'> -> lib1 -> lib3 -> <strong><b><font
face="Courier New"><span style='font-family:"Courier New"'>lib4-B</span></font></b></strong>
-> lib6 -> lib8</span></font><font face=Arial><span lang=EN-GB
style='font-family:Arial'><o:p></o:p></span></font></p>
<p class=MsoNormal><strong><b><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'>exe2-A</span></font></b></strong><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:
"Courier New"'> -> lib2 -> lib3 -> <strong><b><font
face="Courier New"><span style='font-family:"Courier New"'>lib4-A</span></font></b></strong>
-> lib5 -> lib7</span></font><font face="Courier New"><span lang=EN-GB
style='font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal><strong><b><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'>exe2-B</span></font></b></strong><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:
"Courier New"'> -> lib2 -> lib3 -> <strong><b><font
face="Courier New"><span style='font-family:"Courier New"'>lib4-B</span></font></b></strong>
-> lib6 -> lib8</span></font><font face="Courier New"><span lang=EN-GB
style='font-family:"Courier New"'><o:p></o:p></span></font></p>
<p class=MsoNormal><font size=3 face=Arial><span lang=EN-GB style='font-size:
12.0pt;font-family:Arial'> <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=3 face=Arial><span lang=EN-GB style='font-size:
12.0pt;font-family:Arial'> <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>I'd like to keep using the standard cmake mechanism
of dependency description in which every lib only defines on which other
libs it depends, and let cmake compute the final link line.</span></font><span
lang=EN-GB><o:p></o:p></span></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-GB
style='font-size:12.0pt'> <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>----- SOLUTION : Feature request:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>Adding a SELECTOR keyword (working a bit like
debug|optimized) to target_link_libraries to specify that the given dependency
is only required when this selector has a given value.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>The selector will be defined when building the
executable.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<pre><font size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt'>target_link_libraries(<target> [item1 [item2 [...]]]<br>
<b><span style='font-weight:bold'>[[SELECTOR <selectorName> <selectorValue>]</span></b>[debug|optimized|general] <item>] ...)<o:p></o:p></span></font></pre>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>* lib3 CMakeLists.txt:<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-indent:35.4pt'><font size=2 face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'>add_library(lib3 some
source)<o:p></o:p></span></font></p>
<p class=MsoNormal style='text-indent:35.4pt'><font size=2 face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'>target_link_libraries(lib3,<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:35.4pt;text-indent:35.4pt'><b><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:
"Courier New";font-weight:bold'>SELECTOR</span></font></b><font size=2
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'>
A_OR_B A lib4-A<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:35.4pt;text-indent:35.4pt'><b><font
size=2 face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:
"Courier New";font-weight:bold'>SELECTOR</span></font></b><font size=2
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'>
A_OR_B B lib4-B<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'> )<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>* exe1-A CmakeLists.txt<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'> add_executable(exe1-A some
sources)<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'> <b><span
style='font-weight:bold'>set (A_OR_B A)<o:p></o:p></span></b></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'> target_link_libraries(exe1-A
lib1) # will link with lib4-A<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>* exe1-B CmakeLists.txt<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'> add_executable(exe1-A some
sources)<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'> <b><span
style='font-weight:bold'>set (A_OR_B B)<o:p></o:p></span></b></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'> target_link_libraries(exe1-A
lib1) # will link with lib4-B<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>Would you see this feature in a future official
release?<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>Would you include a patch if we code it with your
help, as we don't know much about cmake sources.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'>Thanks,</span></font><span lang=EN-GB><o:p></o:p></span></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'><o:p> </o:p></span></font></p>
</div>
<br clear=all> This email was sent to you by Thomson Reuters, the global news and information company.<br>
Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Thomson Reuters.
</body>
</html>