VS generator doesn't support multiple /SECTION linker options
CMake VS generator converts /SECTION
linker options into SpecifySectionAttributes
property. This property seemingly supports only single section definition, so CMake looses all except the last /SECTION
option.
Example of the flags:
add_executable(test_sections main.cpp)
target_link_options(test_sections PUBLIC /SECTION:.text,!P /SECTION:.data,!P /SECTION:.rdata,!P)
In this case, only .rdata
flag is applied. Issue can be reproduced with CMake 3.16.1 and VS 2015/2017.
If VS cannot support multiple options in SpecifySectionAttributes
property, then these linker flags should just go into AdditionalOptions
and be passed to linker as is.
I've created an issue on Visual Studio issue tracker as well: https://developercommunity.visualstudio.com/content/problem/909017/specify-section-attributes-linker-option-doesnt-su.html