brintos

brintos / llvm-project-archived public Read only

0
0
Text · 706 B · c27e501 Raw
20 lines · plain
1# Get the linker version on Darwin2function(get_darwin_linker_version variable)3  set(LINK_VERSION)4  set(LD_V_OUTPUT)5  execute_process(6    COMMAND sh -c "${CMAKE_LINKER} -v 2>&1 | head -1"7    RESULT_VARIABLE HAD_ERROR8    OUTPUT_VARIABLE LD_V_OUTPUT9    )10  if (HAD_ERROR)11    message(FATAL_ERROR "${CMAKE_LINKER} failed with status ${HAD_ERROR}")12  endif()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})17  endif()18  set(${variable} ${LINK_VERSION} PARENT_SCOPE)19endfunction()20