Zohar
February 2, 2025, 8:35pm
1
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:
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…
Angew
(Petr Kmoch)
February 3, 2025, 2:00pm
2
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
Zohar
February 3, 2025, 8:13pm
3
I still want a console app. I’m only changing the subsystem flag in order to skip the pause after execution.
retif
February 4, 2025, 8:02am
4
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.
Zohar
February 4, 2025, 10:50am
5
Yeah, the “SUBSYSTEM” flag is case-sensitive.