1

I am looking for a way for CMake to query which version of the linker is currently being used. I have to fail a build if the linker version is too high or low. So far I could not find an easy way to do so except to execute the command ld --version and parse the output manually which is ugly and won't work cross-platform.

Thanks!

  • 1
    CMake has no platform-independent notion about the linker executable. Usually, for link an executable or shared library it just calls the compiler with appropriate options. There is `CMAKE_CXX_LINK_EXECUTABLE` which denotes command line used for link executable instead of compiler invocation (https://stackoverflow.com/a/25274328/3440745), but nothing above that. It seems you need to resort to executing a command like `ld --version` and parsing its output. In CMake commands could be executed with [execute_process](https://cmake.org/cmake/help/v3.18/command/execute_process.html). – Tsyvarev Jan 14 '21 at 08:15

0 Answers0