Skip to content

Commit a138191

Browse files
apteryksMaxim Cournoyer
authored andcommitted
build: Allow using a system-provided SPIRV-Cross library.
Fixes: #17079 * Makefile.common [HAVE_BUILTINSPIRV_CROSS]: Include bundled SPIRV-Cross sources only when using the builtin option, else... [!HAVE_BUILTINSPIRV_CROSS]: Extend CXXFLAGS and LIBS. * qb/config.libs.sh (BUILTINSPIRV_CROSS): Register new check_enabled configure option, and add libraries/header checks. * qb/config.params.sh (HAVE_BUILTINSPIRV_CROSS): Register new parameter.
1 parent 5e5f047 commit a138191

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

Makefile.common

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,6 +1895,7 @@ endif
18951895

18961896
ifeq ($(HAVE_SPIRV_CROSS), 1)
18971897
DEFINES += -DHAVE_SPIRV_CROSS
1898+
ifeq ($(HAVE_BUILTINSPIRV_CROSS), 1)
18981899
INCLUDE_DIRS += -I$(DEPS_DIR)/SPIRV-Cross
18991900
OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_cross.o
19001901
OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_cfg.o
@@ -1903,6 +1904,13 @@ ifeq ($(HAVE_SPIRV_CROSS), 1)
19031904
OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_msl.o
19041905
OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_parser.o
19051906
OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_cross_parsed_ir.o
1907+
else
1908+
CXXFLAGS += $(SPIRV_CROSS_CFLAGS)
1909+
LIBS += -lspirv-cross-core \
1910+
-lspirv-cross-glsl \
1911+
-lspirv-cross-reflect \
1912+
-lspirv-cross-msl
1913+
endif
19061914
endif
19071915

19081916
ifeq ($(WANT_WGL), 1)

qb/config.libs.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ check_enabled CXX GLSLANG glslang 'The C++ compiler is' false
662662
check_enabled CXX SPIRV_CROSS SPIRV-Cross 'The C++ compiler is' false
663663

664664
check_enabled GLSLANG BUILTINGLSLANG 'builtin glslang' 'glslang is' true
665+
check_enabled SPIRV_CROSS BUILTINSPIRV_CROSS 'builtin spirv-cross' 'spirv-cross is' true
665666

666667
if [ "$HAVE_GLSLANG" != no ]; then
667668
check_header cxx GLSLANG \
@@ -694,6 +695,27 @@ if [ "$HAVE_GLSLANG" != no ]; then
694695
fi
695696
fi
696697

698+
if [ "$HAVE_SPIRV_CROSS" != no ]; then
699+
check_lib cxx SPIRV_CROSS -lspirv-cross-core '' '' 'spirv_cross.hpp' 'spirv_cross'
700+
check_lib cxx SPIRV_CROSS_GLSL -lspirv-cross-glsl
701+
check_lib cxx SPIRV_CROSS_MSL -lspirv-cross-msl
702+
check_lib cxx SPIRV_CROSS_REFLECT -lspirv-cross-reflect
703+
if [ "$HAVE_SPIRV_CROSS" = no ] ||
704+
[ "$HAVE_SPIRV_CROSS_GLSL" = no ] ||
705+
[ "$HAVE_SPIRV_CROSS_MSL" = no ] ||
706+
[ "$HAVE_SPIRV_CROSS_REFLECT" = no ]; then
707+
if [ "$HAVE_BUILTINSPIRV_CROSS" != yes ]; then
708+
die : "Notice: System spirv-cross libraries not found, \
709+
disabling spirv-cross support"
710+
HAVE_SPIRV_CROSS=no
711+
else
712+
HAVE_SPIRV_CROSS=yes
713+
fi
714+
else
715+
HAVE_SPIRV_CROSS=yes
716+
fi
717+
fi
718+
697719
if [ "$HAVE_CRTSWITCHRES" != no ]; then
698720
if [ "$HAVE_CXX11" = 'no' ]; then
699721
HAVE_CRTSWITCHRES=no

qb/config.params.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ C89_GLSLANG=no
194194
HAVE_BUILTINGLSLANG=auto # Bake in glslang support
195195
C89_BUILTINGLSLANG=no
196196
HAVE_SPIRV_CROSS=auto # SPIRV-Cross support (requires C++11)
197+
HAVE_BUILTINSPIRV_CROSS=auto # Use bundled SPIRV-Cross source
197198
C89_SPIRV_CROSS=no
198199
HAVE_METAL=no # Metal support (macOS-only)
199200
C89_METAL=no

0 commit comments

Comments
 (0)