# Modify default link flag "subsystem"

**URL:** https://discourse.cmake.org/t/modify-default-link-flag-subsystem/13525
**Category:** Code
**Created:** [February 2, 2025, 8:35pm UTC](https://discourse.cmake.org/t/modify-default-link-flag-subsystem/13525 "2025-02-02T20:35:46Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Zohar](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/z/45deac/32.png) [@Zohar](https://discourse.cmake.org/u/Zohar)
#### Post date: [February 2, 2025, 8:35pm UTC](https://discourse.cmake.org/t/modify-default-link-flag-subsystem/13525/1 "2025-02-02T20:35:46Z")

</div>

For visual studio, I’d like to change the link flag

```auto
/subsystem:CONSOLE

```

to

```auto
/subsystem:WINDOWS

```

I tried variations such as

```auto
    set_target_properties( pyconfstruct PROPERTIES LINK_FLAGS /subsystem:WINDOWS )
    #get_target_property( tmp_flags pyconfstruct LINK_FLAGS )
    message(" ******* ${CMAKE_EXE_LINKER_FLAGS}")
    #list( REMOVE_ITEM tmp_flags "/subsystem:CONSOLE" )
    #set_target_properties( pyconfstruct PROPERTIES LINK_FLAGS "${tmp_flags}" )

```

However, LINK\_FLAGS doesn’t exist yet.

A related topic:

> [@Remove items from CMAKE\_EXE\_LINKER\_FLAGS\_INIT](https://discourse.cmake.org/t/remove-items-from-cmake-exe-linker-flags-init/7785):
>
> Hi, how can I remove certain link options of a specific executable which initially came from CMAKE\_EXE\_LINKER\_FLAGS\_INIT? For instance, the CMake configuration for the Android platform defines CMAKE\_EXE\_LINKER\_FLAGS\_INIT to include -Wl,--gc-sections. Is there a way to remove this particular option from the link options of an executable? I tried that by removing -Wl,--gc-sections from the LINK\_OPTIONS property of the corresponding target, but apparently, the CMAKE\_EXE\_LINKER\_FLAGS\_INIT content…

---

<div class="post-metadata">

### Author: ![Angew](https://discourse.cmake.org/user_avatar/discourse.cmake.org/angew/32/229_2.png) [@Angew](https://discourse.cmake.org/u/Angew)
#### Post date: [February 3, 2025, 2:00pm UTC](https://discourse.cmake.org/t/modify-default-link-flag-subsystem/13525/2 "2025-02-03T14:00:26Z")

</div>

To create a non-console application (i.e. one which uses `WinMain` instead of `main`), pass the argument [`WIN32` to `add_executable()`](https://cmake.org/cmake/help/latest/command/add_executable.html#normal), or set the target’s [property `WIN32_EXECUTABLE`](https://cmake.org/cmake/help/latest/prop_tgt/WIN32_EXECUTABLE.html) to true.

---

<div class="post-metadata">

### Author: ![Zohar](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/z/45deac/32.png) [@Zohar](https://discourse.cmake.org/u/Zohar)
#### Post date: [February 3, 2025, 8:13pm UTC](https://discourse.cmake.org/t/modify-default-link-flag-subsystem/13525/3 "2025-02-03T20:13:08Z")

</div>

I still want a console app. I’m only changing the subsystem flag in order to skip the pause after execution.

> **[Disable pause after execution 2 - Microsoft Q&A](https://learn.microsoft.com/en-us/answers/questions/2143038/disable-pause-after-execution-2)**
>
> What happened to the first post where I asked this question?
> Why are there still these puzzle verifications when posting?
> \--
> It's been asked for years, and I was wondering if something has finally been done about it.
> I'd like after an execution of a...

---

<div class="post-metadata">

### Author: ![retif](https://discourse.cmake.org/user_avatar/discourse.cmake.org/retif/32/1776_2.png) [@retif](https://discourse.cmake.org/u/retif)
#### Post date: [February 4, 2025, 8:02am UTC](https://discourse.cmake.org/t/modify-default-link-flag-subsystem/13525/4 "2025-02-04T08:02:12Z")

</div>

Hmm, here’s what I have in my project and that works fine (_unless I misunderstood what you wanted to achieve in yours_):

```cmake
set_target_properties(HERE-IS-MY-EXECUTABLE-TARGET-NAME
    PROPERTIES
    LINK_FLAGS "/ENTRY:mainCRTStartup /SUBSYSTEM:WINDOWS"
)

```

Looking at your code, one difference is that my flags are quoted and another difference is that they are in upper case (_your `/subsystem` is lower-cased_). Not sure if any of these differences matter, though.

Also it could be that you have a typo in your target name? But that would have caused a different kind of problem, unless you have another target with that name.

---

<div class="post-metadata">

### Author: ![Zohar](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/z/45deac/32.png) [@Zohar](https://discourse.cmake.org/u/Zohar)
#### Post date: [February 4, 2025, 10:50am UTC](https://discourse.cmake.org/t/modify-default-link-flag-subsystem/13525/5 "2025-02-04T10:50:35Z")

</div>

Yeah, the “SUBSYSTEM” flag is case-sensitive.
