Where is it documented what linker flags are used when building a target?
The documentation for CMAKE_EXE_LINKER_FLAGS just says that "These flags will be used by the linker when creating an executable."; the documentation for CMAKE_MODULE_LINKER_FLAGS and CMAKE_SHARED_LINKER_FLAGS say the same thing for their respective target types.
The documentation for CMAKE_EXE_LINKER_FLAGS_ just says that they are "Flags to be used when linking an executable." and that they are "Same as CMAKE_C_FLAGS_* but used by the linker when creating executables."; the documentation for CMAKE_MODULE_LINKER_FLAGS_ and CMAKE_SHARED_LINKER_FLAGS_ say the same thing for their respective target types. The CMAKE__FLAGS and CMAKE__FLAGS_ documentation just speak of them as "Flags for all build types" and "Flags for language when building for the configuration", respectively.
The documentation for the LINK_FLAGS property says it contains "Additional flags to use when linking this target." and that "The LINK_FLAGS property can be used to add extra flags to the link step of a target."; similar per-configuration things are said about LINK_FLAGS_.
The documentation of the properties seems to indicate that those flags are added to whatever flags would be used for all targets of that type; that's a pretty clear description.
However, the documentation for the CMAKE_xxx_LINKER_FLAGS and CMAKE_xxx_LINKER_FLAGS_ doesn't clearly indicate whether the linker flags for a target start out as a combination of the CMAKE_xxx_LINKER_FLAGS for the target type and the CMAKE_xxx_LINKER_FLAGS_ for the target type and build type, so that the flags for a given target are the combination of the CMAKE_xxx_LINKER_FLAGS for the target type, the CMAKE_xxx_LINKER_FLAGS_ for the target type and build type, and the LINK_FLAGS for the target in question.
It also doesn't indicate how one should add linker flags for all targets of a given type, or all targets of a given type in a particular build type; should one just directly set CMAKE_xxx_LINKER_FLAGS and CMAKE_xxx_LINKER_FLAGS_, or should one assume that CMake has added flags and add your flags to the existing value? The documentation for CMAKE_xxx_LINKER_FLAGS_INIT and CMAKE_xxx_LINKER_FLAGS__INIT seems to suggest that the values of those files become the initial values of CMAKE_xxx_LINKER_FLAGS and CMAKE_xxx_LINKER_FLAGS_, respectively, and that they should be set only in a "toolchain file".
The particular issue that brought this up is that the Wireshark CMake files were setting linker flags using only the LINK_FLAGS property; the properties included /INCREMENTAL:NO and /RELEASE. This worked; there were no linker complaints about /INCREMENTAL or /INCREMENTAL:YES colliding with /RELEASE.
I changed it to set CMAKE_EXE_LINKER_FLAGS to the values that were being used for LINK_FLAGS, and not setting LINK_FLAGS; it now wasn't passing /INCREMENTAL:NO, but was passing /RELEASE, and was also passing /INCREMENTAL:YES or /INCREMENTAL. CMake was being run as
cmake -DCMAKE_TRY_COMPILE_CONFIGURATION=Release -G Visual Studio 15 2017 Win64 ..
from a build
subdirectory.