With this project:
cmake_minimum_required(VERSION 3.29) # sets CMP0156 to NEW
project(Discourse9084 C)
add_library(A a.c)
add_library(B b.c)
target_link_libraries(B PUBLIC A)
add_library(C c.c)
target_link_libraries(C PUBLIC A)
add_executable(Y y.c)
target_link_libraries(Y PRIVATE A B C)
add_executable(Z z.c)
target_link_libraries(Z PRIVATE A B)
On Linux I get link lines:
cc ... -o Y libA.a libB.a libC.a libA.a
cc ... -o Z libA.a libB.a libA.a
and on Apple I get link lines:
cc ... -o Y libB.a libC.a libA.a
cc ... -o Z libB.a libA.a
The latter are de-duplicated as expected because CMake (after CMP0156) knows that Apple’s linker re-scans automatically.
The CMAKE_<LANG>_LINK_LIBRARIES_PROCESSING
variable is an undocumented implementation detail that CMake sets internally/automatically based on what linker is being used.