No subject
Fri May 8 15:29:31 EDT 2009
=20
"If COMMAND specifies an executable target (created by ADD_EXECUTABLE)
it will automatically be replaced by the location of the executable
created at build time"
=20
Would it be a bad idea to have add_custom_command replace the executable
target by its location, when this is passed as an argument?
=20
Ideally the following code:
=20
add_executable(foo ${HEADERS} ${SOURCES})
=20
set_target_properties(
foo
PROPERTIES
OUTPUT_NAME bar
DEBUG_POSTFIX _d
)
=20
add_custom_command(
TARGET foo
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy foo C:/put/it/here/bin
)
=20
Would create a post build event that looks like this in Visual Studio:
Debug Configuration:
"C:\Program Files\CMake 2.6\bin\cmake.exe" -E copy Debug/bar_d.exe
C:/put/it/here/bin
=20
Release Configuration:
"C:\Program Files\CMake 2.6\bin\cmake.exe" -E copy Release/bar.exe
C:/put/it/here/bin
=20
As far as I can tell, add_custom_command, only expands the target name
into the executable location, if this is the command being executed.
=20
This thread <http://www.mail-archive.com/cmake@cmake.org/msg18026.html>
discussed a similar, if not identical issue. But didn't seem to have an
elegant solution.
=20
=20
Thanks,
=20
Daniel Tavares
Programmer | Slipgate Ironworks
http://www.slipg8.com
=20
------_=_NextPart_001_01C9DFE8.649485DA
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@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;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3DEN-US link=3Dblue vlink=3Dpurple>
<div class=3DSection1>
<p class=3DMsoNormal>How can I get the location of the target being =
built?
Granted, this file name changes depending on the configuration that =
you’re
building.<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>I’m trying to add a post build event using
add_custom_command that will copy the target executable to a different
directory, but I can’t get the correct location of the executable =
created
at build time, because it changes depending on the configuration being =
built.<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>add_custom_command will replace the executable =
target (created
by ADD_EXECUTABLE) with the location of the executable created at build =
time,
but only if the target is the one being executed by the =
command.<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>From the docs:<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>“If COMMAND specifies an executable target =
(created by
ADD_EXECUTABLE) it will automatically be replaced by the location of the
executable created at build time”<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>Would it be a bad idea to have add_custom_command =
replace
the executable target by its location, when this is passed as an =
argument?<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>Ideally the following code:<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>add_executable(foo ${HEADERS} =
${SOURCES})<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>set_target_properties(<o:p></o:p></p>
<p =
class=3DMsoNormal> &=
nbsp; foo<o:p></o:p></p>
<p =
class=3DMsoNormal> &=
nbsp; PROPERTIES<o:p></o:p></p>
<p class=3DMsoNormal style=3D'text-indent:.5in'>OUTPUT_NAME =
bar<o:p></o:p></p>
<p =
class=3DMsoNormal> &=
nbsp; DEBUG_POSTFIX
_d<o:p></o:p></p>
<p class=3DMsoNormal>)<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>add_custom_command(<o:p></o:p></p>
<p class=3DMsoNormal style=3D'text-indent:.5in'>TARGET =
foo<o:p></o:p></p>
<p class=3DMsoNormal =
style=3D'text-indent:.5in'>POST_BUILD<o:p></o:p></p>
<p class=3DMsoNormal style=3D'text-indent:.5in'>COMMAND ${CMAKE_COMMAND} =
-E copy foo
C:/put/it/here/bin<o:p></o:p></p>
<p class=3DMsoNormal>)<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>Would create a post build event that looks like =
this in Visual
Studio:<o:p></o:p></p>
<p class=3DMsoNormal>Debug Configuration:<o:p></o:p></p>
<p class=3DMsoNormal>"C:\Program Files\CMake =
2.6\bin\cmake.exe" -E copy
Debug/bar_d.exe C:/put/it/here/bin<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>Release Configuration:<o:p></o:p></p>
<p class=3DMsoNormal>"C:\Program Files\CMake =
2.6\bin\cmake.exe" -E copy
Release/bar.exe C:/put/it/here/bin<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>As far as I can tell, add_custom_command, only =
expands the
target name into the executable location, if this is the command being
executed.<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>This <a
href=3D"http://www.mail-archive.com/cmake@cmake.org/msg18026.html">thread=
</a>
discussed a similar, if not identical issue. But didn’t seem to =
have an elegant
solution.<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>Thanks,<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal><span =
style=3D'font-size:10.0pt;font-family:"Arial","sans-serif"'>Daniel
Tavares</span><span style=3D'font-size:12.0pt;font-family:"Times New =
Roman","serif"'><o:p></o:p></span></p>
<p class=3DMsoNormal><span =
style=3D'font-size:10.0pt;font-family:"Arial","sans-serif"'>Programmer
| Slipgate Ironworks</span><span =
style=3D'font-size:12.0pt;font-family:"Times New =
Roman","serif"'><o:p></o:p></span></p>
<p class=3DMsoNormal><span =
style=3D'font-size:10.0pt;font-family:"Arial","sans-serif"'>http://www.sl=
ipg8.com</span><o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
</div>
</body>
</html>
------_=_NextPart_001_01C9DFE8.649485DA--
More information about the CMake
mailing list