<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: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:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
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><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal>David, <o:p></o:p></p><p class=MsoNormal> I think a bit more explanation of the philosophy (at least how I interpret it) is needed. I see in your emails that you are “targeting makefiles”. With CMake you need to really stop thinking this way. Rarely do you need to target any specific build system (although those times do come up…). A lot of folks I see coming from autoconf to CMake still try to treat CMake in the same way. Don’t. There are a few golden rules with CMake that if you adhere to those will allow you to use CMake much easier.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>1: NEVER have the Source directory and the Build directory be the same place.<o:p></o:p></p><p class=MsoNormal>2: PREFER out-of-source build directories (Not required but helpful)<o:p></o:p></p><p class=MsoNormal>3: Try not to target specific generators (makefiles, visual studio, xcode)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>What this looks like is the following. Say I have a project from github called Foo and I clone it onto my local filesystem. From a command line perspective you get the following:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Git clone <a href="https://github.com/somebody/Foo">https://github.com/somebody/Foo</a><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The *<b>Preferred</b>* way is this<o:p></o:p></p><p class=MsoNormal>Clone Foo<o:p></o:p></p><p class=MsoNormal>*<b>At the same directory level as Foo</b>*<o:p></o:p></p><p class=MsoNormal>Mkdir Debug && cd Debug<o:p></o:p></p><p class=MsoNormal>Cmake -DCMAKE_BUILD_TYPE=Release ../Foo<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal># We can break rule 2 a bit by making subdirectories inside of Foo<o:p></o:p></p><p class=MsoNormal> cd Foo<o:p></o:p></p><p class=MsoNormal> mkdir Debug && cd Debug<o:p></o:p></p><p class=MsoNormal> cmake -DCMAKE_BUILD_TYPE=Debug ../<o:p></o:p></p><p class=MsoNormal> make -j<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>We have just created a Debug build in the Debug Directory. Now, the same is analogous for the Release build.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Cd Foo<o:p></o:p></p><p class=MsoNormal>Mkdir Release && cd Release<o:p></o:p></p><p class=MsoNormal>Cmake -DCMAKE_BUILD_TYPE=Release ../<o:p></o:p></p><p class=MsoNormal>Make -j<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>*<b>IF</b>* you make these subdirectories in a source code top level be sure to add those directory names to the .gitignore file.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>If your cmake is written properly then the build creates NOTHING inside of the source directory.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I hope this helps summarize all of the other emails. Glad to have you in the CMake community.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal><span style='color:black'>--<o:p></o:p></span></p></div><p class=MsoNormal><span style='color:black'>Mike Jackson </span><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><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 David Aldrich <david.aldrich.ntml@gmail.com><br><b>Date: </b>Friday, June 21, 2019 at 12:10 PM<br><b>To: </b>Braden McDaniel <braden@endoframe.com><br><b>Cc: </b>CMake <cmake@cmake.org><br><b>Subject: </b>Re: [CMake] How to support separate debug and release build directories?<o:p></o:p></span></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><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-bottom:12.0pt'>> What would best practice be to provide convenient commands for our<br>> developers to easily build the target ?<br><br>For the Makefile generator, best practice is to use separate build<br>directories (i.e., places where you run cmake) for different<br>configurations (i.e., different settings recorded during the<br>configuration step).<br><br>If you want to provide developers with some known set(s) of<br>configuration settings, I suggest wrapper scripts that invoke cmake<br>with those settings.<o:p></o:p></p></blockquote><div><p class=MsoNormal>Thanks for your advice. I am not finding it easy to find 'patterns' for these sort of issues. I would have thought that configuring a project with separate debug and release directories would be quite typical. But it's hard to find the recommended way of doing such things. Anyway, I think I am on the right track now.<o:p></o:p></p></div></div></div><p class=MsoNormal>-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake <o:p></o:p></p></div></body></html>