[CMake] Visual C++ Compile/Link Flags

Jano Svitok jan.svitok at gmail.com
Tue Feb 13 09:14:08 EST 2018


On Tue, Feb 13, 2018 at 2:38 PM, ThePhD <jm3689 at columbia.edu> wrote:

> 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".
>

You can try this; I don't know if this is the preferred way to do it.

set_property( TARGET lib_target APPEND_STRING PROPERTY LINK_FLAGS "
/OPT:NOREF" )

Jano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180213/9b0228a9/attachment.html>


More information about the CMake mailing list