Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correctly set Visual Studio linker flag /SUBSYSTEM in CMAKE

I am trying to set up an old project using cmake and I would like to keep all flags the same as before. The old project generator has the linker flag /SUBSYSTEM with minimum subystem version number 5.01 set like this:

/SUBSYSTEM:WINDOWS,"5.01"

I tried the same in cmake by adding this:

set_target_properties(mytarget PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS,\"5.01\"")

However the result is wrong. Cmake seems to remove the (escaped) double quotes and places the linker flag to "Addition Options" in the Visual Studio project: /SUBSYSTEM:WINDOWS,5.01

This way the subsystem flag is not recognized and set to CONSOLE.

I tried several combinations how to add the min version ,"5.01" to the subsystem flag but without success.

Is there any other way to add the minimum subsystem version number to the /SUBSYSTEM flag?

like image 829
bender Avatar asked Nov 23 '15 14:11

bender


1 Answers

You can simply use the [WIN32] flag in the add_executable function :

add_executable(${PROJECT_NAME} WIN32 main.cpp)
like image 167
cmourglia Avatar answered Nov 04 '22 13:11

cmourglia