1 # if CMAKE_LIBTOOL is not set, try and find it with xcrun or find_program
4 find_program(CMAKE_XCRUN NAMES xcrun)
7 execute_process(COMMAND ${CMAKE_XCRUN} -find libtool
8 OUTPUT_VARIABLE CMAKE_LIBTOOL
9 OUTPUT_STRIP_TRAILING_WHITESPACE)
12 if(NOT CMAKE_LIBTOOL OR NOT EXISTS CMAKE_LIBTOOL)
13 find_program(CMAKE_LIBTOOL NAMES libtool)
17 get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
19 set(CMAKE_LIBTOOL ${CMAKE_LIBTOOL} CACHE PATH "libtool executable")
20 message(STATUS "Found libtool - ${CMAKE_LIBTOOL}")
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
28 if(NOT LIBTOOL_VERSION VERSION_LESS "862")
29 set(LIBTOOL_NO_WARNING_FLAG "-no_warning_for_no_symbols")
33 foreach(lang ${languages})
34 set(CMAKE_${lang}_CREATE_STATIC_LIBRARY
35 "\"${CMAKE_LIBTOOL}\" -static ${LIBTOOL_NO_WARNING_FLAG} -o <TARGET> <LINK_FLAGS> <OBJECTS>")
39 # If DYLD_LIBRARY_PATH is set we need to set it on archiver commands
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}")
47 set(CMAKE_${lang}_CREATE_STATIC_LIBRARY
48 ${CMAKE_${lang}_CREATE_STATIC_LIBRARY_NEW})