Merge #9130 'build: Fix for macOS 10.14/mojave'

fix #9050

Q: (from From #7891)
  > It turns out there's a difference between executing
  > /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
  > and /usr/bin/clang. CMake was picking up the former and with that it left off
  > a key include path. Why?

A: /usr/bin/clang is a shim that uses libxcselect/libxcrun under the hood.
   $ otool -L /usr/bin/clang
   /usr/bin/clang:
    /usr/lib/libxcselect.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)

From https://macops.ca/developer-binaries-on-os-x-xcode-select-and-xcrun/ :
  > this shim binary loads functions in libxcselect.dylib that can locate the
  > path to the real binary, depending on how the system has been configured. One
  > part of this process is to check whether this path contains
  > usr/lib/libxcrun.dylib, and the xcrun tool, in which case it will invoke
  > xcrun to run the binary.
  > ...
  > (If all of this isn’t yet enough indirection for you, /usr/bin/xcrun itself
  > is a shim, and so libxcselect.dylib contains code to detect whether the
  > executed xcrun is a shim. Look for the __xcrun_shim segment in the __DATA
  > section output by the command: pagestuff /usr/bin/xcrun -a.)
This commit is contained in:
Justin M. Keyes 2018-10-18 01:28:17 +02:00 committed by GitHub
commit edcf640f59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -98,6 +98,10 @@ else()
set(DEPS_C_COMPILER "${CMAKE_C_COMPILER}")
endif()
if(CMAKE_OSX_SYSROOT)
set(DEPS_C_COMPILER "${DEPS_C_COMPILER} -isysroot${CMAKE_OSX_SYSROOT}")
endif()
# Cross compiling: use these for dependencies built for the
# HOST system, when not crosscompiling these should be the
# same as DEPS_*. Except when targeting Unix in which case

View File

@ -50,8 +50,17 @@ set(INSTALLCMD_UNIX ${MAKE_PRG} CFLAGS=-fPIC
install)
if(UNIX)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# Set MACOSX_DEPLOYMENT_TARGET (else luajit defaults to 10.4). #9050
# https://github.com/LuaJIT/LuaJIT/blob/b025b01c5b9d23f6218c7d72b7aafa3f1ab1e08a/src/Makefile#L301-L303
set(DEPLOYMENT_TARGET "MACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")
else()
set(DEPLOYMENT_TARGET "")
endif()
BuildLuaJit(INSTALL_COMMAND ${INSTALLCMD_UNIX}
CC=${DEPS_C_COMPILER} PREFIX=${DEPS_INSTALL_DIR})
CC=${DEPS_C_COMPILER} PREFIX=${DEPS_INSTALL_DIR}
${DEPLOYMENT_TARGET})
elseif(MINGW AND CMAKE_CROSSCOMPILING)