# Windows librarian options issue

**URL:** https://discourse.cmake.org/t/windows-librarian-options-issue/3597
**Category:** Code
**Tags:** os:windows
**Created:** [June 20, 2021, 8:06am UTC](https://discourse.cmake.org/t/windows-librarian-options-issue/3597 "2021-06-20T08:06:45Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![serge](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/5f8ce5/32.png) [@serge](https://discourse.cmake.org/u/serge)
#### Post date: [June 20, 2021, 8:06am UTC](https://discourse.cmake.org/t/windows-librarian-options-issue/3597/1 "2021-06-20T08:06:45Z")

</div>

I am building a static library in windows:

add\_library(somelib STATIC asource.cpp)

I would like to use the /NODEFAULTLIB option with the librarian command of windows so I call:

add\_link\_options(/NODEFAULTLIB)

or

target\_link\_options(somelib PUBLIC /NODEFAULTLIB)

In both case cmake ignores and does not add the above option to the lib.exe command.  
Do I have to add a custom command to do that?

Any idea?  
Thanks,  
Serge

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [June 21, 2021, 9:33am UTC](https://discourse.cmake.org/t/windows-librarian-options-issue/3597/2 "2021-06-21T09:33:48Z")

</div>

Static libraries have their own specific link options. Use the target property [STATIC\_LINK\_OPTIONS](https://cmake.org/cmake/help/latest/prop_tgt/STATIC_LIBRARY_OPTIONS.html) for that purpose.

---

<div class="post-metadata">

### Author: ![serge](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/5f8ce5/32.png) [@serge](https://discourse.cmake.org/u/serge)
#### Post date: [June 21, 2021, 12:50pm UTC](https://discourse.cmake.org/t/windows-librarian-options-issue/3597/3 "2021-06-21T12:50:56Z")

</div>

Nice, thank you Mark.
