build(deps): support universal builds on macOS

CMake can handle building universal binaries on macOS using the
`CMAKE_OSX_ARCHITECTURES` variable. Let's pass this variable to the
relevant dep builds. We use the `LIST_SEPARATOR` argument to prevent the
shell from interpreting the `;` that CMake uses as a list separator.

For dependencies that don't build using CMake, we only need to make sure
that the compiler is invoked with the correct `-arch` flags. The
compiler does the rest.

The only exception to this is the LuaJIT build, which we handle
separately as a special case.
This commit is contained in:
Carlo Cabrera
2022-06-24 23:43:11 +08:00
committed by Christian Clason
parent 0d230d3f01
commit dca69c90d4
4 changed files with 22 additions and 3 deletions

View File

@@ -27,7 +27,8 @@ function(BuildMsgpack)
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
CONFIGURE_COMMAND "${_msgpack_CONFIGURE_COMMAND}"
BUILD_COMMAND "${_msgpack_BUILD_COMMAND}"
INSTALL_COMMAND "${_msgpack_INSTALL_COMMAND}")
INSTALL_COMMAND "${_msgpack_INSTALL_COMMAND}"
LIST_SEPARATOR |)
endfunction()
set(MSGPACK_CONFIGURE_COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/msgpack
@@ -37,6 +38,7 @@ set(MSGPACK_CONFIGURE_COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/msgpack
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_ALT_SEP}
"-DCMAKE_C_FLAGS:STRING=${CMAKE_C_COMPILER_ARG1} -fPIC"
-DCMAKE_GENERATOR=${CMAKE_GENERATOR})