Skip to content

Commit 103b83e

Browse files
committed
apply universal rpath policy, that does not contain absolute paths
1 parent c4758b3 commit 103b83e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,27 @@ set(CMAKE_CUDA_STANDARD 20)
1111
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
1212
# ------------------
1313

14+
# --- Universal RPATH policy ---
15+
# Don't skip RPATH when installing, but don't hardcode build dirs either
16+
set(CMAKE_SKIP_BUILD_RPATH FALSE)
17+
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
18+
# When building, allow local RPATH so binaries work in build tree
19+
set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE)
20+
# Prefer relative RPATHs (avoids absolute /build/ paths)
21+
set(CMAKE_BUILD_RPATH "$ORIGIN/../lib")
22+
# When installing, make binaries relocatable
23+
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
24+
# Don’t automatically include system dirs in RPATH (avoid pollution)
25+
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
26+
# CMake policies (for modern behavior)
27+
if(POLICY CMP0068)
28+
cmake_policy(SET CMP0068 NEW) # RPATH settings apply to install
29+
endif()
30+
if(POLICY CMP0072)
31+
cmake_policy(SET CMP0072 NEW) # Prefer config mode find_package for OpenGL
32+
endif()
33+
# ------------------
34+
1435
# ---- Options ----
1536
option(RAYX_WERROR "add -Werror option. Warning will be treated as errors." OFF) # inactive per default
1637
if (RAYX_WERROR)

0 commit comments

Comments
 (0)