# CMake or VS issue: In Debug mode libcmt is linked together with libcmtd?

**URL:** <https://discourse.cmake.org/t/cmake-or-vs-issue-in-debug-mode-libcmt-is-linked-together-with-libcmtd/1911>\
**Category:** Code\
**Tags:** os:windows, comp:msvc\
**Created:** [September 25, 2020, 1:19pm UTC](https://discourse.cmake.org/t/cmake-or-vs-issue-in-debug-mode-libcmt-is-linked-together-with-libcmtd/1911 "2020-09-25T13:19:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ProTur1](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/34f0e0/32.png) [@ProTur1](https://discourse.cmake.org/u/ProTur1)\
**Post date:** [September 25, 2020, 1:19pm UTC](https://discourse.cmake.org/t/cmake-or-vs-issue-in-debug-mode-libcmt-is-linked-together-with-libcmtd/1911/1 "2020-09-25T13:19:21Z")

</div>

CMake or VS issue? In Debug mode _libcmt_ is linked together with _libcmtd_?  
Although I set for a release build _/MT_ and for a debug build _/MTd_, in the debug mode the `libcmt` is still being linked, together with the _libcmtd_.  
What could have gone wrong?I ended up by setting` /NODEFAULTLIB:libcmt` as a linker option for a debug mode.

Btw what is better to use  
_target\_link\_options(myTargetName PUBLIC $\<$CONFIG:Debug:/NODEFAULTLIB:libcmt\>)_  
or  
_set\_property(TARGET myTargetName APPEND PROPERTY LINK\_FLAGS\_DEBUG /NODEFAULTLIB:libcmt)_

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [November 22, 2020, 7:45pm UTC](https://discourse.cmake.org/t/cmake-or-vs-issue-in-debug-mode-libcmt-is-linked-together-with-libcmtd/1911/2 "2020-11-22T19:45:02Z")

</div>

`target_link_options` is definitely the better one here.

I think it might be better to make an `IMPORTED` target:

```cmake
add_library(cmt UNKNOWN IMPORTED)
set_target_properties(cmt PROPERTIES
  IMPORTED_LOCATION …
  IMPORTED_LOCATION_DEBUG …)

```
