1 # Get the linker version on Darwin
2 function(get_darwin_linker_version variable)
6 COMMAND sh -c "${CMAKE_LINKER} -v 2>&1 | head -1"
7 RESULT_VARIABLE HAD_ERROR
8 OUTPUT_VARIABLE LD_V_OUTPUT
11 message(FATAL_ERROR "${CMAKE_LINKER} failed with status ${HAD_ERROR}")
13 if ("${LD_V_OUTPUT}" MATCHES ".*ld64-([0-9.]+).*")
14 string(REGEX REPLACE ".*ld64-([0-9.]+).*" "\\1" LINK_VERSION ${LD_V_OUTPUT})
15 elseif ("${LD_V_OUTPUT}" MATCHES "[^0-9]*([0-9.]+).*")
16 string(REGEX REPLACE "[^0-9]*([0-9.]+).*" "\\1" LINK_VERSION ${LD_V_OUTPUT})
18 set(${variable} ${LINK_VERSION} PARENT_SCOPE)