<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">The convention in MSVC-land seems to be to prefix (as well as suffix) static libraries with lib. E.g. the static CRT is libcmt.lib, the static VC runtime support library is libvcruntime.lib (whereas the import library for the dynamic equivalent
 is vcruntime.lib), and so on. It isn't necessarily the greatest scheme, but it does provide some distinction, at least.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">CMake <cmake-bounces@cmake.org> on behalf of Ray Donnelly <mingw.android@gmail.com><br>
<b>Date: </b>Saturday, May 19, 2018 at 6:10 AM<br>
<b>To: </b>Elvis Stansvik <elvis.stansvik@orexplore.com><br>
<b>Cc: </b>CMake MailingList <cmake@cmake.org><br>
<b>Subject: </b>Re: [CMake] Approach to both shared and static lib (again, sorry)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">And the situation is *far* worse on Windows where the extension for a dll import library is the same as for a static library because cmake refuses to try to move the needle on this awful 'defacto' decision with
 respect to msvc when it is exactly the sort of thing cmake should strive to take the lead on creating this new standard here, in cooperation and discussion with Microsoft (though for pure cmake based things it can be done without that). .dll.lib vs .lib being
 the obvious extensions here. <o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">FWIW mingw-w64 fixed this, and it was far from difficult. Here we use .dll.a and .a.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">I appeal to the CMake moderators to consider the damage this situation causes to the genericness and hygiene of CMakeList.txt files.<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in">On Sat, May 19, 2018, 2:00 PM Elvis Stansvik <<a href="mailto:elvis.stansvik@orexplore.com">elvis.stansvik@orexplore.com</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal" style="margin-left:.5in">I know this has been asked before, but I've never seen a really<br>
authoritative answer.<br>
<br>
Say I have a simple single-library project.<br>
<br>
The advise I've seen is to not pass SHARED or STATIC to the<br>
add_library(..), but instead let the user pass<br>
-DBUILD_SHARED_LIBS:BOOL=ON/OFF to build the library as either shared<br>
or static.<br>
<br>
That's fine, but leads to packagers having to do ugly things like e.g:<br>
<br>
    <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__salsa.debian.org_hle_dlib_blob_master_debian_rules&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=bmBNxLvBJFPYO0Kd1_VsRIXq2zQXfPQBW72q5lBMPlo&s=R7JQmKVI2oxy-AIQVcBC-DX-dqlkBFk5kTCI222ecO8&e=" target="_blank">
https://salsa.debian.org/hle/dlib/blob/master/debian/rules</a><br>
<br>
That is, do two separate configure/build/install, in order to get both<br>
a shared and static version. Note that the above was just an example.<br>
But many packagers do it like this.<br>
<br>
How can I make life easier for the packager?<br>
<br>
I could add a -DFOO_BUILD_SHARED_AND_STATIC_LIBS, and use two<br>
add_library(...), one with SHARED and one with STATIC, but the same<br>
input source files. I could give the two libraries different output<br>
filenames, as to not conflict on e.g. Windows (where I think the .lib<br>
import library containing symbols for the .dll would otherwise<br>
conflict with the static library .lib, or..?).<br>
<br>
To not have to repeat the list of sources, I could keep them in a<br>
variable. But that's not recommended in modern CMake AFAIK.<br>
<br>
I've also seen people add an object library, and then build the shared<br>
+ static lib from that.<br>
<br>
What are your thoughts on all this? How do you go about it? Do you use<br>
the recommended way, with a single add_library(..) and just let<br>
packagers put up with having to do two builds?<br>
<br>
Thanks in advance!<br>
Elvis<br>
-- <br>
<br>
Powered by <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.kitware.com&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=bmBNxLvBJFPYO0Kd1_VsRIXq2zQXfPQBW72q5lBMPlo&s=V3mYr9Flf9Qf-Pq-_OovKbzrwVWhpIOrjcCHuYvbszk&e=" target="_blank">
www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.cmake.org_Wiki_CMake-5FFAQ&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=bmBNxLvBJFPYO0Kd1_VsRIXq2zQXfPQBW72q5lBMPlo&s=sX26SQZVFYfGdhl4S0nVhXQDQ6eq_MhGXOy06ZAW9KQ&e=" 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="https://urldefense.proofpoint.com/v2/url?u=http-3A__cmake.org_cmake_help_support.html&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=bmBNxLvBJFPYO0Kd1_VsRIXq2zQXfPQBW72q5lBMPlo&s=BWvA9Izw2G-XbRvZi9ptVgljjbJtkoRi_P7RuctYyTk&e=" target="_blank">
http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__cmake.org_cmake_help_consulting.html&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=bmBNxLvBJFPYO0Kd1_VsRIXq2zQXfPQBW72q5lBMPlo&s=ouA_QmMRSZ16piM4G5xCtdJwt7Sz4fx_anknDStubYU&e=" target="_blank">
http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__cmake.org_cmake_help_training.html&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=bmBNxLvBJFPYO0Kd1_VsRIXq2zQXfPQBW72q5lBMPlo&s=qR0yZSqjFyaVr1xJpwSmtk28b-sMXtWDoM_URvLQs7A&e=" target="_blank">
http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.kitware.com_opensource_opensource.html&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=bmBNxLvBJFPYO0Kd1_VsRIXq2zQXfPQBW72q5lBMPlo&s=m2pcWM0TtqESkDz4KmjlV9a1VwfRPD2XaiR3Motzbxg&e=" target="_blank">
http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__cmake.org_mailman_listinfo_cmake&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=bmBNxLvBJFPYO0Kd1_VsRIXq2zQXfPQBW72q5lBMPlo&s=_fvbzMfoMh-elt7ju2Fetz2OTx7Z4TmCHGf7D6C4htE&e=" target="_blank">https://cmake.org/mailman/listinfo/cmake</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</body>
</html>