INSTALL_RPATH_USE_LINK_PATH not working when CMAKE_EXE_LINKER_FLAGS (LDFLAGS) is set

I’m wondering if this is a bug.

I’m using INSTALL_RPATH_USE_LINK_PATH TRUE for a target in my project, and generally it seems to work and set the target’s RUNPATH as expected on install, except it stops working and doesn’t set any RUNPATH if an -L option is included in CMAKE_EXE_LINKER_FLAGS.

I don’t see interactions between USE_LINK_PATH and LINKER_FLAGS variables mentioned in the reference documentation or in https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling, so I’m wondering if this behavior is expected or may be a bug.

I can vaguely see how the behavior might be useful, but not specifically, and it seems like a surprising thing that should be document. For now setting CMAKE_INSTALL_RPATH manually seems to function as a workaround.

I can try to come up with minimal test case if this sounds like a bug. Some more details are in