CMAKE_RANLIB vs CMAKE_CXX_COMPILER_RANLIB

Hi! I’m not certain how these variables are to be used. In my case building with clang 7 and -flto I need to run the cxx compiler specific ranlib but CMAKE_RANLIB is the one actually run.

Am I supposed to to something like the snippet below, or is there some other way CMAKE_CXX_COMPILER_RANLIB is supposed to be used?

project( Blarg C CXX )
if ( CMAKE_CXX_COMPILER_RANLIB )
  set( CMAKE_RANLIB ${CMAKE_CXX_COMPILER_RANLIB} )
endif()

Or maybe the question is this: is there a way to tell cmake to use the compiler binutils instead of the system binutils?

In my case, clang+±7 on ubunutu 18.04 they are in /usr/lib/llvm-7/bin and the CMAKE_CXX_COMPILER_RANLIB is set to /usr/lib/llvm-7/bin/llvm-ranlib. I just don’t know how to inform cmake to actually use that and the other binutils there.