brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 130810c Raw
59 lines · plain
1# if CMAKE_LIBTOOL is not set, try and find it with xcrun or find_program2if(NOT CMAKE_LIBTOOL)3  if(NOT CMAKE_XCRUN)4    find_program(CMAKE_XCRUN NAMES xcrun)5  endif()6  if(CMAKE_XCRUN)7    execute_process(COMMAND ${CMAKE_XCRUN} -find libtool8      OUTPUT_VARIABLE CMAKE_LIBTOOL9      OUTPUT_STRIP_TRAILING_WHITESPACE)10  endif()11 12  if(NOT CMAKE_LIBTOOL OR NOT EXISTS CMAKE_LIBTOOL)13    find_program(CMAKE_LIBTOOL NAMES libtool)14  endif()15endif()16 17get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)18if(CMAKE_LIBTOOL)19  set(CMAKE_LIBTOOL ${CMAKE_LIBTOOL} CACHE PATH "libtool executable")20  message(STATUS "Found libtool - ${CMAKE_LIBTOOL}")21 22  execute_process(COMMAND ${CMAKE_LIBTOOL} -V23    OUTPUT_VARIABLE LIBTOOL_V_OUTPUT24    OUTPUT_STRIP_TRAILING_WHITESPACE)25  if("${LIBTOOL_V_OUTPUT}" MATCHES ".*cctools-([0-9.]+).*")26    string(REGEX REPLACE ".*cctools-([0-9.]+).*" "\\1" LIBTOOL_VERSION27      ${LIBTOOL_V_OUTPUT})28    if(NOT LIBTOOL_VERSION VERSION_LESS "862")29      set(LIBTOOL_NO_WARNING_FLAG "-no_warning_for_no_symbols")30    endif()31  endif()32 33  foreach(lang ${languages})34    set(CMAKE_${lang}_CREATE_STATIC_LIBRARY35      "\"${CMAKE_LIBTOOL}\" -static ${LIBTOOL_NO_WARNING_FLAG} -o <TARGET> <LINK_FLAGS> <OBJECTS>")36  endforeach()37 38  # By default, CMake invokes ranlib on a static library after installing it.39  # libtool will have produced the table of contents for us already, and ranlib40  # does not understanding universal binaries, so skip this step. It's important41  # to set it to empty instead of unsetting it to shadow the cache variable, and42  # we don't want to unset the cache variable to not affect anything outside43  # this scope.44  set(CMAKE_RANLIB "")45endif()46 47# If DYLD_LIBRARY_PATH is set we need to set it on archiver commands48if(DYLD_LIBRARY_PATH)49  set(dyld_envar "DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}")50  foreach(lang ${languages})51    foreach(cmd ${CMAKE_${lang}_CREATE_STATIC_LIBRARY})52      list(APPEND CMAKE_${lang}_CREATE_STATIC_LIBRARY_NEW53           "${dyld_envar} ${cmd}")54    endforeach()55    set(CMAKE_${lang}_CREATE_STATIC_LIBRARY56      ${CMAKE_${lang}_CREATE_STATIC_LIBRARY_NEW})57  endforeach()58endif()59