Modify default link flag "subsystem"

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

/subsystem:CONSOLE

to

/subsystem:WINDOWS

I tried variations such as

    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:

To create a non-console application (i.e. one which uses WinMain instead of main), pass the argument WIN32 to add_executable(), or set the target’s property WIN32_EXECUTABLE to true.

1 Like

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

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

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.

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