Skip to content

Commit

Permalink
build: Make sure pkg-config is configured correctly for macOS cross c…
Browse files Browse the repository at this point in the history
…ompile.
  • Loading branch information
squidbus committed Oct 17, 2024
1 parent b4ced58 commit 7abf3e9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,15 @@ else()
message(FATAL_ERROR "Unsupported CPU architecture: ${BASE_ARCHITECTURE}")
endif()

if (APPLE AND ARCHITECTURE STREQUAL "x86_64")
if (APPLE AND ARCHITECTURE STREQUAL "x86_64" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
# Exclude ARM homebrew path to avoid conflicts when cross compiling.
list(APPEND CMAKE_IGNORE_PREFIX_PATH "/opt/homebrew")

# Need to reconfigure pkg-config to use the right architecture library paths.
# It's not ideal to override these but otherwise the build breaks just by having pkg-config installed.
set(ENV{PKG_CONFIG_DIR} "")
set(ENV{PKG_CONFIG_LIBDIR} "${CMAKE_SYSROOT}/usr/lib/pkgconfig:${CMAKE_SYSROOT}/usr/share/pkgconfig:${CMAKE_SYSROOT}/usr/local/lib/pkgconfig:${CMAKE_SYSROOT}/usr/local/share/pkgconfig")
set(ENV{PKG_CONFIG_SYSROOT_DIR} ${CMAKE_SYSROOT})
endif()

# This function should be passed a list of all files in a target. It will automatically generate file groups
Expand Down

0 comments on commit 7abf3e9

Please sign in to comment.