Link options are not transitive over private dependency on static library
Hi,
I have recently encountered what I believe might be a bug, where INTERFACE_LINK_OPTIONS are not carried over static libraries. Following is the simplest CMakeLists.txt that demonstrates the problem (all files in zip: cmake-LinkOptionsNotTransitive.zip):
cmake_minimum_required(VERSION 3.16)
project(LinkOptionsNotTransitive)
add_library(A SHARED A.cpp)
add_library(B STATIC B.cpp)
add_executable(C C.cpp)
target_link_options(A INTERFACE "/DELAYLOAD:A.dll")
target_link_libraries(B PRIVATE A)
target_link_libraries(C PRIVATE B)
I tested this with both Visual Studio 2017 and Ninja generators and both cmake 3.15.4 and 3.16.0-rc4, with the same result.
When inspecting generated solution, C is linking both A.lib and B.lib (as it should), but /DELAYLOAD flag is not applied to it. If B has PUBLIC dependency on A, then /DELAYLOAD flag is also correctly carried over. I get the impression that target_link_options behaves as eg. target_include_directories, which are not carried over PRIVATE dependencies. Given that these are linker options, I would expect them to follow same rules as target_link_libraries, which will carry over until nearest linker invocation.