Allow for using LLVM from Homebrew and include its libc++
This commit is contained in:
parent
66a58f7478
commit
f21ae77a01
|
@ -123,8 +123,10 @@ if (ENABLE_LTO)
|
||||||
if (NOT LLD STREQUAL "LLD-NOTFOUND")
|
if (NOT LLD STREQUAL "LLD-NOTFOUND")
|
||||||
add_link_options(-fuse-ld=lld)
|
add_link_options(-fuse-ld=lld)
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_AR "llvm-ar")
|
if (NOT APPLE)
|
||||||
set(CMAKE_RANLIB "llvm-ranlib")
|
set(CMAKE_AR "llvm-ar")
|
||||||
|
set(CMAKE_RANLIB "llvm-ranlib")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Toolchain file for building with Homebrew's LLVM on macOS
|
||||||
|
# This is useful on 10.14 where std::filesystem is not supported.
|
||||||
|
|
||||||
|
set(CMAKE_C_COMPILER /usr/local/opt/llvm/bin/clang)
|
||||||
|
set(CMAKE_CXX_COMPILER /usr/local/opt/llvm/bin/clang++)
|
||||||
|
|
||||||
|
add_link_options(-L/usr/local/opt/llvm/lib)
|
||||||
|
|
||||||
|
# LLVM in Homebrew is built with latest Xcode which has a newer linker than
|
||||||
|
# what is bundled in the default install of Xcode Command Line Tools, so we
|
||||||
|
# override it to prevent it passing flags not supported by the system's ld.
|
||||||
|
add_link_options(-mlinker-version=450)
|
|
@ -56,6 +56,10 @@ def expand_load_path(lib, path)
|
||||||
file = $fallback_rpaths
|
file = $fallback_rpaths
|
||||||
.map { |it| File.join(it, file_name) }
|
.map { |it| File.join(it, file_name) }
|
||||||
.find { |it| File.exist? it }
|
.find { |it| File.exist? it }
|
||||||
|
if file == nil
|
||||||
|
path = File.join(File.dirname(lib), file_name)
|
||||||
|
file = path if File.exist? path
|
||||||
|
end
|
||||||
return file, :rpath if file
|
return file, :rpath if file
|
||||||
when "executable_path"
|
when "executable_path"
|
||||||
file = File.join(File.dirname(executable), file_name)
|
file = File.join(File.dirname(executable), file_name)
|
||||||
|
@ -85,7 +89,6 @@ def install_name_tool(exec, action, path1, path2 = nil)
|
||||||
args = ["-#{action.to_s}", path1]
|
args = ["-#{action.to_s}", path1]
|
||||||
args << path2 if path2 != nil
|
args << path2 if path2 != nil
|
||||||
|
|
||||||
FileUtils.chmod("u+w", exec)
|
|
||||||
out, status = Open3.capture2e("install_name_tool", *args, exec)
|
out, status = Open3.capture2e("install_name_tool", *args, exec)
|
||||||
if status != 0
|
if status != 0
|
||||||
puts out
|
puts out
|
||||||
|
@ -129,6 +132,7 @@ def fixup_libs(prog, orig_path)
|
||||||
next if File.exist? File.join(frameworks_dir, fwname)
|
next if File.exist? File.join(frameworks_dir, fwname)
|
||||||
expath, _ = expand_load_path(orig_path, framework)
|
expath, _ = expand_load_path(orig_path, framework)
|
||||||
FileUtils.cp_r(expath, frameworks_dir, preserve: true)
|
FileUtils.cp_r(expath, frameworks_dir, preserve: true)
|
||||||
|
FileUtils.chmod_R("u+w", File.join(frameworks_dir, fwname))
|
||||||
fixup_libs File.join(frameworks_dir, fwname, fwlib), libpath
|
fixup_libs File.join(frameworks_dir, fwname, fwlib), libpath
|
||||||
else
|
else
|
||||||
libname = File.basename(libpath)
|
libname = File.basename(libpath)
|
||||||
|
@ -141,6 +145,7 @@ def fixup_libs(prog, orig_path)
|
||||||
next if File.exist? dest
|
next if File.exist? dest
|
||||||
expath, _ = expand_load_path(orig_path, libpath)
|
expath, _ = expand_load_path(orig_path, libpath)
|
||||||
FileUtils.copy expath, frameworks_dir
|
FileUtils.copy expath, frameworks_dir
|
||||||
|
FileUtils.chmod("u+w", dest)
|
||||||
fixup_libs dest, libpath
|
fixup_libs dest, libpath
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue