<div dir="ltr"><div style><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Thanks for the very valuable info Matthew. </span></div><div style><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br>

</span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span style="font-size:12.800000190734863px;font-family:arial,sans-serif">If Project A is installed (to a standard location), then it is available<br>

</span><span style="font-size:12.800000190734863px;font-family:arial,sans-serif">system wide, yes. However you should still use find_package(A) rather<br></span><span style="font-size:12.800000190734863px;font-family:arial,sans-serif">than relying on e.g. target_link_libraries(B A) </span></blockquote>

<div><br></div><div style>I tried to use find_package(A) but CMake would display a warning: </div><div style><br></div><div style>&quot;By not providing &quot;FindA.cmake&quot; in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by &quot;A&quot;, but CMake did not find one&quot;</div>

<div style><br></div><div style>Obviously I am not installing it correctly. When do I know my libraries/package is installed correctly (apart from the fact that find_package will be able to find it)? Is there a specific folder that I can check to make sure the installation took place properly and that CMake will be able to find the libraries/packages? Am I correct in assuming that if I do the install correctly, I do not have to write a package configuration file and that it will be provided by CMake automatically?</div>

<div style><br></div><div style>Any tips that first time users like me should watch out for when installing their libraries would be great.</div><div style><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<span style="font-size:12.800000190734863px;font-family:arial,sans-serif">Generally speaking, you should either have two separate builds of A in<br></span><span style="font-size:12.800000190734863px;font-family:arial,sans-serif">32- and 64-bit mode that can be installed in parallel</span></blockquote>

<div><br></div><div style>I will follow your advice here and split up the configurations. </div><div style><br></div><div style>Thank you,</div><div style>Saad</div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br>

</span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Message: 2<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Date: Wed, 03 Apr 2013 17:12:43 -0400<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">From: Matthew Woehlke &lt;</span><a href="mailto:matthew.woehlke@kitware.com" style="font-family:arial,sans-serif;font-size:12.800000190734863px">matthew.woehlke@kitware.com</a><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt;<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Subject: Re: [CMake] Explanation of the CMake INSTALL and EXPORT<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">        Commands<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">To: </span><a href="mailto:cmake@cmake.org" style="font-family:arial,sans-serif;font-size:12.800000190734863px">cmake@cmake.org<br></a><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Message-ID: &lt;kji607$pe$</span><a href="mailto:1@ger.gmane.org" style="font-family:arial,sans-serif;font-size:12.800000190734863px">1@ger.gmane.org</a><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt;<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Content-Type: text/plain; charset=UTF-8; format=flowed</span><br style="font-family:arial,sans-serif;font-size:12.800000190734863px"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">On 2013-04-03 16:16, Saad Khattak wrote:<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt; I am having a hard time understanding some commands in CMake which by the<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt; looks of it are vital for proper project deployment. One of the commands is<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt; INSTALL and the other is EXPORT.</span><br style="font-family:arial,sans-serif;font-size:12.800000190734863px"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">There are two forms of EXPORT, and I am not certain which one you are<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">referring to. There is the command EXPORT, and there is the EXPORT named<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">argument to the INSTALL command. They are similar in that they both deal<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">with generating target export files, but the command version is used to<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">generate such for build trees, while the named argument version applies<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">to install trees.</span><br style="font-family:arial,sans-serif;font-size:12.800000190734863px"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">If you never use your software downstream from a build directory, you<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">can safely ignore the command version.</span><br style="font-family:arial,sans-serif;font-size:12.800000190734863px"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt; 1) Why do I need to install my library/executable? When I build my<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt; libraries and they are put in their library output paths, what is the point<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt; of INSTALL?</span><br style="font-family:arial,sans-serif;font-size:12.800000190734863px">

<span style="font-family:arial,sans-serif;font-size:12.800000190734863px">INSTALL is used to implement &#39;make install&#39; (or equivalent), and also<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">packaging. If you are only ever using your software from a source build,<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">you can probably ignore it. If you ever want to deploy your software,<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">however, I would strongly encourage having an install process.</span><br style="font-family:arial,sans-serif;font-size:12.800000190734863px">

<span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Installing makes a software package generally available to users of the<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">system, by installing its components into a well-known prefix (e.g.<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">/usr, /usr/local, /opt/MySoft). It is often much more convenient to use<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">an installed software package rather than stuff in a build directory, as<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">installed binaries tend to be in e.g. PATH, whereas build directories<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">may not be readable by all users.</span><br style="font-family:arial,sans-serif;font-size:12.800000190734863px">

<span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Please don&#39;t teach your build to write its build objects directly into<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">e.g. /usr/local/bin :-).</span><br style="font-family:arial,sans-serif;font-size:12.800000190734863px">

<span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt; 2) Once I do install targets and/or programs, are they available to other<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt; projects that are not in the same CMakeLists build?</span><br style="font-family:arial,sans-serif;font-size:12.800000190734863px">

<span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Yes. They are available just from build directories also, but you will<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">need to manually tell CMake where to find build directories. (Per above,<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">installed packages can be found automatically if they are installed to<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">standard (well known) locations... keeping in mind that you can choose<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">to install to any location you like, e.g. in your home directory.)</span><br style="font-family:arial,sans-serif;font-size:12.800000190734863px">

<span style="font-family:arial,sans-serif;font-size:12.800000190734863px">(If you are using exported targets - and you should - then you will need<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">to use the EXPORT command to create a build-directory exported targets<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">file. Getting this right is a little more complicated than install<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">exports, but saves needing to install the package every time your<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">downstream needs an updated version.)</span><br style="font-family:arial,sans-serif;font-size:12.800000190734863px"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt; 3) Suppose I have 2 completely separate projects (i.e. they have completely<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt; separate CMakeLists that are not &#39;talking&#39; to each other) - Project A<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt; builds some libraries which Project B now needs to use. Does Project A<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt; &#39;install&#39; the libraries and are now those libraries are available system<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt; wide?</span><br style="font-family:arial,sans-serif;font-size:12.800000190734863px">

<span style="font-family:arial,sans-serif;font-size:12.800000190734863px">If Project A is installed (to a standard location), then it is available<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">system wide, yes. However you should still use find_package(A) rather<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">than relying on e.g. target_link_libraries(B A) so that your build will<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">work for users that do not have A in a standard location.</span><br style="font-family:arial,sans-serif;font-size:12.800000190734863px">

<span style="font-family:arial,sans-serif;font-size:12.800000190734863px">If A is built by CMake, your install should generate exports so that<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">users of A do not need a find module. (Also, then you *can* - and should<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">- do target_link_libraries(B A), because &#39;A&#39; will be an imported target,<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">i.e. will &#39;look like&#39; it was build as part of B.)</span><br style="font-family:arial,sans-serif;font-size:12.800000190734863px">

<span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt; 4) Project A can build 32 bit and 64 bit libraries. How does INSTALL (or<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt; EXPORT? Like I said earlier, I am very confused here...) know which library<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt; it is &#39;installing&#39;? And then how does Project B 32 bit know to link with<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">&gt; Project A 32 bit libraries and same with 64-bit?</span><br style="font-family:arial,sans-serif;font-size:12.800000190734863px">

<span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Hmm... I&#39;m not all that familiar with multi-arch bits, but I *think* how<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">this is supposed to work is that when B does find_package(A), it will<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">look in either lib or lib64 depending on whether or not it is being<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">built in 64-bit mode. So as long as your find_package picks the right<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">AConfig.cmake, all will be well (it should by default if A is installed<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">to a standard location, and/or if necessary you can force where to find<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">its config).</span><br style="font-family:arial,sans-serif;font-size:12.800000190734863px"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Generally speaking, you should either have two separate builds of A in<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">32- and 64-bit mode that can be installed in parallel, or else A should<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">produce 32- and 64-bit libraries with different names. (I would<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">recommend the former, since that is how most software works and is less<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">likely to give you headaches getting it to work. Also because getting<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">CMake to build both 32- and 64-bit binaries in the same build is going<br></span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">to be harder than just having separate 32- and 64-bit builds.)</span><br style="font-family:arial,sans-serif;font-size:12.800000190734863px">

<span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Hope that helps.</span><br style="font-family:arial,sans-serif;font-size:12.800000190734863px"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">--<br>

</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Matthew</span></blockquote></div>