• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# if CMAKE_LIBTOOL is not set, try and find it with xcrun or find_program
2if(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 libtool
8      OUTPUT_VARIABLE CMAKE_LIBTOOL
9      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} -V
23    OUTPUT_VARIABLE LIBTOOL_V_OUTPUT
24    OUTPUT_STRIP_TRAILING_WHITESPACE)
25  if("${LIBTOOL_V_OUTPUT}" MATCHES ".*cctools-([0-9.]+).*")
26    string(REGEX REPLACE ".*cctools-([0-9.]+).*" "\\1" LIBTOOL_VERSION
27      ${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_LIBRARY
35      "\"${CMAKE_LIBTOOL}\" -static ${LIBTOOL_NO_WARNING_FLAG} -o <TARGET> <LINK_FLAGS> <OBJECTS>")
36  endforeach()
37endif()
38
39# If DYLD_LIBRARY_PATH is set we need to set it on archiver commands
40if(DYLD_LIBRARY_PATH)
41  set(dyld_envar "DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}")
42  foreach(lang ${languages})
43    foreach(cmd ${CMAKE_${lang}_CREATE_STATIC_LIBRARY})
44      list(APPEND CMAKE_${lang}_CREATE_STATIC_LIBRARY_NEW
45           "${dyld_envar} ${cmd}")
46    endforeach()
47    set(CMAKE_${lang}_CREATE_STATIC_LIBRARY
48      ${CMAKE_${lang}_CREATE_STATIC_LIBRARY_NEW})
49  endforeach()
50endif()
51