mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 05:52:33 +00:00
ifcviewer: support linking system-packaged wgpu-native and zstd
Add a WGPU_NATIVE_USE_SYSTEM option that resolves wgpu-native via pkg-config instead of FetchContent-ing upstream's prebuilt binary release, for distros (e.g. Fedora) that ship it as a system package. Also fall back to pkg-config for zstd when the CONFIG package isn't available, and skip the wgpu-native runtime install step when the system package already owns it.
This commit is contained in:
@@ -32,13 +32,21 @@ endif()
|
|||||||
# everywhere a 4x4 transform shows up. Header-only, works under Emscripten.
|
# everywhere a 4x4 transform shows up. Header-only, works under Emscripten.
|
||||||
find_package(Eigen3 REQUIRED)
|
find_package(Eigen3 REQUIRED)
|
||||||
|
|
||||||
# wgpu-native — fetched as a pre-built binary release from upstream.
|
# wgpu-native — fetched as a pre-built binary release from upstream, or
|
||||||
# Under Emscripten this whole block is skipped; the web build links
|
# taken from a system package via pkg-config when WGPU_NATIVE_USE_SYSTEM
|
||||||
# against Dawn's webgpu.h via the emdawnwebgpu port instead. The
|
# is set. Under Emscripten this whole block is skipped; the web build
|
||||||
|
# links against Dawn's webgpu.h via the emdawnwebgpu port instead. The
|
||||||
# `wgpu_native` link target is created as an INTERFACE in that branch
|
# `wgpu_native` link target is created as an INTERFACE in that branch
|
||||||
# (see the end of this block) so consumers' target_link_libraries lines
|
# (see the end of this block) so consumers' target_link_libraries lines
|
||||||
# work uniformly.
|
# work uniformly.
|
||||||
if(NOT EMSCRIPTEN)
|
option(WGPU_NATIVE_USE_SYSTEM "Link against a system-packaged wgpu-native instead of FetchContent-ing upstream's prebuilt binary release" OFF)
|
||||||
|
if(NOT EMSCRIPTEN AND WGPU_NATIVE_USE_SYSTEM)
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
|
pkg_check_modules(WGPU_NATIVE REQUIRED IMPORTED_TARGET wgpu-native)
|
||||||
|
|
||||||
|
add_library(wgpu_native ALIAS PkgConfig::WGPU_NATIVE)
|
||||||
|
|
||||||
|
elseif(NOT EMSCRIPTEN)
|
||||||
# Pin the version with WGPU_NATIVE_VERSION; bump to pull a newer release.
|
# Pin the version with WGPU_NATIVE_VERSION; bump to pull a newer release.
|
||||||
set(WGPU_NATIVE_VERSION "v29.0.0.0" CACHE STRING "wgpu-native release tag")
|
set(WGPU_NATIVE_VERSION "v29.0.0.0" CACHE STRING "wgpu-native release tag")
|
||||||
|
|
||||||
@@ -244,8 +252,15 @@ if(EMSCRIPTEN)
|
|||||||
target_sources(IfcViewerCore PRIVATE ${ZSTD_DEC_SRC})
|
target_sources(IfcViewerCore PRIVATE ${ZSTD_DEC_SRC})
|
||||||
target_include_directories(IfcViewerCore PRIVATE ${ZSTD_DEC_DIR})
|
target_include_directories(IfcViewerCore PRIVATE ${ZSTD_DEC_DIR})
|
||||||
else()
|
else()
|
||||||
find_package(zstd CONFIG REQUIRED)
|
find_package(zstd CONFIG QUIET)
|
||||||
target_link_libraries(IfcViewerCore PUBLIC zstd::libzstd_static)
|
if(TARGET zstd::libzstd_static)
|
||||||
|
target_link_libraries(IfcViewerCore PUBLIC zstd::libzstd_static)
|
||||||
|
else()
|
||||||
|
# No zstd CONFIG package on this system — fall back to pkg-config.
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
|
pkg_check_modules(ZSTD REQUIRED IMPORTED_TARGET libzstd)
|
||||||
|
target_link_libraries(IfcViewerCore PUBLIC PkgConfig::ZSTD)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
install(TARGETS IfcViewerCore EXPORT ${IFCOPENSHELL_EXPORT_TARGETS})
|
install(TARGETS IfcViewerCore EXPORT ${IFCOPENSHELL_EXPORT_TARGETS})
|
||||||
|
|
||||||
@@ -336,7 +351,12 @@ install(FILES ${IFCVIEWER_H_FILES}
|
|||||||
# INSTALL_RPATH is set to @executable_path/../Frameworks — together
|
# INSTALL_RPATH is set to @executable_path/../Frameworks — together
|
||||||
# they resolve at launch without depending on macdeployqt to follow
|
# they resolve at launch without depending on macdeployqt to follow
|
||||||
# non-Qt @rpath references.
|
# non-Qt @rpath references.
|
||||||
if(WIN32)
|
#
|
||||||
|
# None of this applies with WGPU_NATIVE_USE_SYSTEM: the shared library
|
||||||
|
# already lives on the system linker path, owned by its own package.
|
||||||
|
if(WGPU_NATIVE_USE_SYSTEM)
|
||||||
|
# nothing to install; system package owns libwgpu_native
|
||||||
|
elseif(WIN32)
|
||||||
install(FILES "${wgpu_native_SOURCE_DIR}/lib/${_wgpu_runtime}" DESTINATION bin)
|
install(FILES "${wgpu_native_SOURCE_DIR}/lib/${_wgpu_runtime}" DESTINATION bin)
|
||||||
elseif(APPLE AND BUILD_BONSAIVIEWER)
|
elseif(APPLE AND BUILD_BONSAIVIEWER)
|
||||||
install(FILES "${wgpu_native_SOURCE_DIR}/lib/${_wgpu_lib}"
|
install(FILES "${wgpu_native_SOURCE_DIR}/lib/${_wgpu_lib}"
|
||||||
|
|||||||
Reference in New Issue
Block a user