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-boun...@cmake.org> on behalf of ThePhD <jm3...@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.enderl...@ifm-chemnitz.de<mailto:volker.enderl...@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<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.kitware.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=o3kDXzdBUE3ljQXKeTWOMw&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=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=TuF6_dXoirMgs8pxfwOLK76T87AEraphOyvzaCdHZDA&s=EyOfGRsbaZJy5-cWrLYXm1PHaZFXQndTGdI1LHiETMc&e=>
CMake Consulting: 
http://cmake.org/cmake/help/consulting.html<https://urldefense.proofpoint.com/v2/url?u=http-3A__cmake.org_cmake_help_consulting.html&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&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=http-3A__cmake.org_cmake_help_training.html&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&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=5VD0RTtNlTh3ycd41b3MUw&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=https-3A__cmake.org_mailman_listinfo_cmake&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=TuF6_dXoirMgs8pxfwOLK76T87AEraphOyvzaCdHZDA&s=s1Qwtnjz3QEPaTSNIgF2f2q1AopU7YrCX0MmXaP5X0Q&e=>

-- 

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

Reply via email to