Skip to content

Commit

Permalink
Fix linux rpath (#941)
Browse files Browse the repository at this point in the history
Add $ORIGIN to RUNPATH for Linux apps and fix settings so
`CMAKE_BUILD_WITH_INSTALL_RPATH` is set for Linux.
  • Loading branch information
MarkCallow authored Sep 8, 2024
1 parent 382a261 commit 06d66b6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
20 changes: 12 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -476,17 +476,21 @@ if(KTX_FEATURE_GL_UPLOAD)
)
endif()

if(WIN32)
if(APPLE_MAC_OS OR LINUX OR WIN32)
# By wrapping in generator expression we force multi configuration
# generators (like Visual Studio) to take the exact path and not
# change it.
# generators (like Visual Studio, Xcode or Ninja multi-config) to
# take the exact path and not change it.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${KTX_BUILD_DIR}/$<CONFIG>>)
elseif(APPLE_MAC_OS OR LINUX)
# Set a common RUNTIME_OUTPUT_DIR and LIBRARY_OUTPUT_DIR for all targets,
# so that INSTALL RPATH is functional in build directory as well.
# BUILD_WITH_INSTALL_RPATH is necessary for working code signing.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${KTX_BUILD_DIR}/$<CONFIG>>)
if(APPLE_MAC_OS OR LINUX)
# Use a common RUNTIME_OUTPUT_DIR and LIBRARY_OUTPUT_DIR for all
# targets so that INSTALL RPATH is functional in build directory
# as well. BUILD_WITH_INSTALL_RPATH is necessary for working code
# signing. Signing happens at build time so the binary must not
# be altered during install. Although Linux code is not yet being
# signed, make it symmetrical with macOS.
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY $<1:${KTX_BUILD_DIR}/$<CONFIG>>)
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
endif()
endif()

set(KTX_BASISU_INCLUDE_DIRS
Expand Down
3 changes: 0 additions & 3 deletions cmake/codesign.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ macro (set_code_sign target)
XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "${XCODE_DEVELOPMENT_TEAM}"
XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "--timestamp"
XCODE_ATTRIBUTE_CODE_SIGN_INJECT_BASE_ENTITLEMENTS $<IF:$<CONFIG:Debug>,YES,NO>
# Necessary for working code signing. Signing happens at build time
# so the binary cannot be altered during install.
BUILD_WITH_INSTALL_RPATH ON
)
if(IOS)
set(set_pps FALSE)
Expand Down
2 changes: 1 addition & 1 deletion tests/loadtests/glloadtests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ function( create_gl_target target version sources common_resources test_images
# /usr/local/bin.

set_target_properties( ${target} PROPERTIES
INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}"
INSTALL_RPATH "\$ORIGIN:${CMAKE_INSTALL_FULL_LIBDIR}"
)

######### IMPORTANT ######
Expand Down

0 comments on commit 06d66b6

Please sign in to comment.