Ignored linker flag with Visual Studio
I am trying to propagate the /SAFESEH:NO linker flag from a lib to an application target. Therefore, I add the following command to the CMAkeLists.txt of the lib target:
target_link_libraries(lib PUBLIC -SAFESEH:NO)
Of course, the application target links agains lib:
target_link_libraries(app PRIVATE lib)
In the vcxproj generated for visual studio 32 bits (I tried 2013 and 2015) for the application project, the linker command line contains both -SAFESEH:NO and /SAFESEH which results in SAFESEH:NO to be ignored. I believe the problem comes from the fact that the -SAFESEH:NO specified in the target_link_libraries command is added to the vcxproj in the AdditionalDependencies tag and not the ImageHasSafeExceptionHandlers tag as it should be. Since the default value of the ImageHasSafeExceptionHandlers tag is yes, visual adds /SAFESEH to the command line, therefore overriding the previous -SAFESEH:NO flag.
I enclosed a zip file that contains a minimal source tree that reproduces my problem.