[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    Re: [CMake] Visual C++ Compile/Link Flags
From:       Shoaib Meenai <smeenai () fb ! com>
Date:       2018-02-14 3:02:09
Message-ID: 6009A406-B245-4BD2-9946-604A14002F79 () fb ! com
[Download RAW message or body]

[Attachment #2 (text/plain)]

Visual Studio's linker (and compiler, for that matter) also accept flags that start \
with dashes instead of slashes (e.g. you can do -opt:noref instead of /opt:noref).

From: CMake <cmake-bounces@cmake.org> on behalf of ThePhD <jm3689@columbia.edu>
Date: Tuesday, February 13, 2018 at 1:10 PM
To: "cmake@cmake.org" <cmake@cmake.org>
Subject: Re: [CMake] Visual C++ Compile/Link Flags

Thank you, Jano Svitok and Volker Enderlein.
     I settled for using "set_target_properties( ... )", and to specify multiple \
LINK_FLAGS I encapsulated both arguments I wanted to pass in a single set of quotes \
(with a space between them). I suppose the APPEND_STRING approach could also work \
well, if I wanted to add multiple.

I appreciate the help!

On Tue, Feb 13, 2018 at 9:11 AM, Volker Enderlein \
<volker.enderlein@ifm-chemnitz.de<mailto:volker.enderlein@ifm-chemnitz.de>> wrote:

set_target_properties(target PROPERTIES LINK_FLAGS "/OPT:NOREF") should work.


Am 13/02/2018 um 14:38 schrieb ThePhD:
I have a project where I attempt to add linker flags to a Visual Studio project using

     target_link_libraries(lib_target PRIVATE /OPT:NOREF)

But it seems like the `/` syntax automatically has CMake assuming that the flag is a \
file, and it complains it cannot find the file. Is there any way to have CMake \
recognize a passed-in linker flag using this syntax? As a side note, is there perhaps \
a better way of passing in Linker flags that I am not aware of? Documentation stated \
that using "target_link_libraries" is preferred, and I did not find \
                "target_link_options".
--

--

Powered by www.kitware.com<www.kit" rel="nofollow">https://urldefense.proofpoint.com/v2/url?u=http-3A__www.kit> \
ware.com&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=TuF6_dXoirMgs8pxfwOLK76T87AEraphOyvzaCdHZDA&s=H8XZFlDlKPXDJs6Txl7iKXVMfqMldGD1SOfjhCgMNyc&e=>


Please keep messages on-topic and check the CMake FAQ at: \
http://www.cmake.org/Wiki/CMake_FAQ<https://urldefense.proofpoint.com/v2/url?u=http-3A \
__www.cmake.org_Wiki_CMake-5FFAQ&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKe \
TWOMw&m=TuF6_dXoirMgs8pxfwOLK76T87AEraphOyvzaCdHZDA&s=V3vhi-FAUPQb9zCOzs1Swgy5y6eYcLq5cbmbZYqiwTM&e=>


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<https://urldefense.proofpoint. \
com/v2/url?u=http-3A__cmake.org_cmake_help_support.html&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3 \
MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=TuF6_dXoirMgs8pxfwOLK76T87AEraphOyvzaCdHZDA&s=EyOfGRsbaZJy5-cWrLYXm1PHaZFXQndTGdI1LHiETMc&e=>
 CMake Consulting: http://cmake.org/cmake/help/consulting.html<https://urldefense.proo \
fpoint.com/v2/url?u=http-3A__cmake.org_cmake_help_consulting.html&d=DwMFaQ&c=5VD0RTtNl \
Th3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=TuF6_dXoirMgs8pxfwOLK76T87AEraphOyvzaCdHZDA&s=gRunwWAHwI2E_hwYQuKRN9zyZc24IcA19T6gjJsv9ck&e=>
 CMake Training Courses: \
http://cmake.org/cmake/help/training.html<https://urldefense.proofpoint.com/v2/url?u=h \
ttp-3A__cmake.org_cmake_help_training.html&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzd \
BUE3ljQXKeTWOMw&m=TuF6_dXoirMgs8pxfwOLK76T87AEraphOyvzaCdHZDA&s=BnZouoLQlKBiCjmNJXqVDrGqG0J54OFJJc6ldsN1rBY&e=>


Visit other Kitware open-source projects at \
http://www.kitware.com/opensource/opensource.html<https://urldefense.proofpoint.com/v2 \
/url?u=http-3A__www.kitware.com_opensource_opensource.html&d=DwMFaQ&c=5VD0RTtNlTh3ycd4 \
1b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=TuF6_dXoirMgs8pxfwOLK76T87AEraphOyvzaCdHZDA&s=SM1OvUqw0STN8RIdtrtd6NPzl-ct4kDSVpCqvL_aXAM&e=>


Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake<https://urldefense.proofpoint.com/v2/url?u=ht \
tps-3A__cmake.org_mailman_listinfo_cmake&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBU \
E3ljQXKeTWOMw&m=TuF6_dXoirMgs8pxfwOLK76T87AEraphOyvzaCdHZDA&s=s1Qwtnjz3QEPaTSNIgF2f2q1AopU7YrCX0MmXaP5X0Q&e=>



[Attachment #3 (text/html)]

<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="Title" content="">
<meta name="Keywords" content="">
<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;}
span.EmailStyle17
	{mso-style-type:personal-reply;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
span.msoIns
	{mso-style-type:export-only;
	mso-style-name:"";
	text-decoration:underline;
	color:teal;}
.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 bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Visual Studio's linker (and compiler, for that matter) also \
accept flags that start with dashes instead of slashes (e.g. you can do -opt:noref \
instead of /opt:noref).<o:p></o:p></p> <p class="MsoNormal"><o:p>&nbsp;</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 &lt;cmake-bounces@cmake.org&gt; on behalf \
of ThePhD &lt;jm3689@columbia.edu&gt;<br> <b>Date: </b>Tuesday, February 13, 2018 at \
1:10 PM<br> <b>To: </b>&quot;cmake@cmake.org&quot; &lt;cmake@cmake.org&gt;<br>
<b>Subject: </b>Re: [CMake] Visual C&#43;&#43; Compile/Link \
Flags<o:p></o:p></span></p> </div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p>&nbsp;</o:p></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal" \
style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:.5in">
 Thank you, Jano Svitok and Volker Enderlein.<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-left:.5in">&nbsp;&nbsp;&nbsp;&nbsp; I settled for \
using &quot;set_target_properties( ... )&quot;, and to specify multiple LINK_FLAGS I \
encapsulated both arguments I wanted to pass in a single set of quotes (with a space \
between them). I suppose the APPEND_STRING  approach could also work well, if I \
wanted to add multiple.<br> <br>
I appreciate the help!<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p>&nbsp;</o:p></p>
<div>
<p class="MsoNormal" style="margin-left:.5in">On Tue, Feb 13, 2018 at 9:11 AM, Volker \
Enderlein &lt;<a href="mailto:volker.enderlein@ifm-chemnitz.de" \
target="_blank">volker.enderlein@ifm-chemnitz.de</a>&gt; wrote:<o:p></o:p></p> \
<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"><br> set_target_properties(target PROPERTIES LINK_FLAGS \
&quot;/OPT:NOREF&quot;) should work. <o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><br>
<br>
Am 13/02/2018 um 14:38 schrieb ThePhD:<o:p></o:p></p>
<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="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:.5in">
 I have a project where I attempt to add linker flags to a Visual Studio project \
using<br> <br>
&nbsp;&nbsp;&nbsp;&nbsp; target_link_libraries(lib_target PRIVATE /OPT:NOREF)<br>
<br>
But it seems like the `/` syntax automatically has CMake assuming that the flag is a \
file, and it complains it cannot find the file. Is there any way to have CMake \
recognize a passed-in linker flag using this syntax? As a side note, is there perhaps \
a better  way of passing in Linker flags that I am not aware of? Documentation stated \
that using &quot;target_link_libraries&quot; is preferred, and I did not find \
&quot;target_link_options&quot;.<o:p></o:p></p> </blockquote>
</div>
</div>
<p class="MsoNormal" style="margin-left:.5in">-- <br>
<br>
-- <br>
<br>
Powered by <a href="www.kitware.co" rel="nofollow">https://urldefense.proofpoint.com/v2/url?u=http-3A__www.kitware.co> \
m&amp;d=DwMFaQ&amp;c=5VD0RTtNlTh3ycd41b3MUw&amp;r=o3kDXzdBUE3ljQXKeTWOMw&amp;m=TuF6_dX \
oirMgs8pxfwOLK76T87AEraphOyvzaCdHZDA&amp;s=H8XZFlDlKPXDJs6Txl7iKXVMfqMldGD1SOfjhCgMNyc&amp;e=" \
target="_blank"> www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a \
href="www.cmake.org_Wiki_CMake-5FF" rel="nofollow">https://urldefense.proofpoint.com/v2/url?u=http-3A__www.cmake.org_Wiki_CMake-5FF> \
AQ&amp;d=DwMFaQ&amp;c=5VD0RTtNlTh3ycd41b3MUw&amp;r=o3kDXzdBUE3ljQXKeTWOMw&amp;m=TuF6_d \
XoirMgs8pxfwOLK76T87AEraphOyvzaCdHZDA&amp;s=V3vhi-FAUPQb9zCOzs1Swgy5y6eYcLq5cbmbZYqiwTM&amp;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&amp;d=DwMFaQ&amp;c=5VD0RTtNlTh3ycd41b3MUw&amp;r=o3kDXzdBUE3ljQ \
XKeTWOMw&amp;m=TuF6_dXoirMgs8pxfwOLK76T87AEraphOyvzaCdHZDA&amp;s=EyOfGRsbaZJy5-cWrLYXm1PHaZFXQndTGdI1LHiETMc&amp;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_consult \
ing.html&amp;d=DwMFaQ&amp;c=5VD0RTtNlTh3ycd41b3MUw&amp;r=o3kDXzdBUE3ljQXKeTWOMw&amp;m= \
TuF6_dXoirMgs8pxfwOLK76T87AEraphOyvzaCdHZDA&amp;s=gRunwWAHwI2E_hwYQuKRN9zyZc24IcA19T6gjJsv9ck&amp;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_trainin \
g.html&amp;d=DwMFaQ&amp;c=5VD0RTtNlTh3ycd41b3MUw&amp;r=o3kDXzdBUE3ljQXKeTWOMw&amp;m=Tu \
F6_dXoirMgs8pxfwOLK76T87AEraphOyvzaCdHZDA&amp;s=BnZouoLQlKBiCjmNJXqVDrGqG0J54OFJJc6ldsN1rBY&amp;e=" \
target="_blank"> http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a \
href="www.kitware.com_opensource_o" rel="nofollow">https://urldefense.proofpoint.com/v2/url?u=http-3A__www.kitware.com_opensource_o> \
pensource.html&amp;d=DwMFaQ&amp;c=5VD0RTtNlTh3ycd41b3MUw&amp;r=o3kDXzdBUE3ljQXKeTWOMw& \
amp;m=TuF6_dXoirMgs8pxfwOLK76T87AEraphOyvzaCdHZDA&amp;s=SM1OvUqw0STN8RIdtrtd6NPzl-ct4kDSVpCqvL_aXAM&amp;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_listin \
fo_cmake&amp;d=DwMFaQ&amp;c=5VD0RTtNlTh3ycd41b3MUw&amp;r=o3kDXzdBUE3ljQXKeTWOMw&amp;m= \
TuF6_dXoirMgs8pxfwOLK76T87AEraphOyvzaCdHZDA&amp;s=s1Qwtnjz3QEPaTSNIgF2f2q1AopU7YrCX0MmXaP5X0Q&amp;e=" \
target="_blank">https://cmake.org/mailman/listinfo/cmake</a><o:p></o:p></p> \
</blockquote> </div>
<p class="MsoNormal" style="margin-left:.5in"><o:p>&nbsp;</o:p></p>
</div>
</div>
</body>
</html>



-- 

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

--===============1303746513==--



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic