Skip to content

Commit 627ba03

Browse files
committed
external_deps: make pkg-config working when cross-compiling
Without setting PKG_CONFIG_PATH to the cross database, pkg-config will only report libraries installed for the native target, not for the cross target. SDL3 relies on pkg-config to enable Wayland support, so we need that to enable Wayland support when cross-compiling SDL3 when the related libraries are only installed for the cross target.
1 parent 6298ff7 commit 627ba03

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

external_deps/build.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ CXX='false'
7272
LD='ld'
7373
AR='ar'
7474
RANLIB='ranlib'
75+
PKG_CONFIG='pkg-config'
76+
CROSS_PKG_CONFIG_PATH=''
7577
LIBS_SHARED='OFF'
7678
LIBS_STATIC='ON'
7779
CMAKE_TOOLCHAIN=''
@@ -1304,8 +1306,7 @@ common_setup() {
13041306
BUILD_DIR="${WORK_DIR}/${BUILD_BASEDIR}"
13051307
PREFIX="${BUILD_DIR}/prefix"
13061308
PATH="${PREFIX}/bin:${PATH}"
1307-
PKG_CONFIG="pkg-config"
1308-
PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
1309+
PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:${CROSS_PKG_CONFIG_PATH}"
13091310
CPPFLAGS+=" -I${PREFIX}/include"
13101311
LDFLAGS+=" -L${PREFIX}/lib"
13111312

@@ -1387,6 +1388,7 @@ common_setup_linux() {
13871388
CC="${HOST/-unknown-/-}-gcc"
13881389
CXX="${HOST/-unknown-/-}-g++"
13891390
STRIP="${HOST/-unknown-/-}-strip"
1391+
CROSS_PKG_CONFIG_PATH="/usr/lib/${HOST/-unknown-/-}/pkgconfig"
13901392
CFLAGS+=' -fPIC'
13911393
CXXFLAGS+=' -fPIC'
13921394
}

0 commit comments

Comments
 (0)