Support running PowerVR samples using SwiftShader on Linux
By setting the RPATH to $ORIGIN, Linux executables can behave like on
Windows and search for shared libraries in the exectuables directory
before looking elsewhere. We copy SwiftShader's Vulkan library into this
directory, naming it vulkan.so.1 to match the loader name the
executables look for.
This also relies on SwiftShader exporting all Vulkan API entry functions
like the loader library does: b/148240133
Bug: b/141361933
Change-Id: I617303cc11faead7aac9e689142a4400731a58a5
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/41970
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8d6b86e..4b97f37 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2431,11 +2431,15 @@
if(SWIFTSHADER_BUILD_PVR)
if(UNIX AND NOT APPLE)
set(PVR_WINDOW_SYSTEM XCB)
+
+ # Set the RPATH of the next defined build targets to $ORIGIN,
+ # allowing them to load shared libraries from the execution directory.
+ set(CMAKE_BUILD_RPATH "$ORIGIN")
endif()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/PowerVR_Examples)
- if(WIN32)
+ if(NOT APPLE)
# Copy the 'loader' library to the bin/ directory
# where the PowerVR executables are placed.
add_custom_command(