-
Notifications
You must be signed in to change notification settings - Fork 0
/
001_add_rpath_subdirs.patch
40 lines (38 loc) · 1.98 KB
/
001_add_rpath_subdirs.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 09b1aad..8366489 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,6 +31,35 @@ file(GLOB_RECURSE HDRS include/*.h)
find_package (Urho3D REQUIRED)
include_directories (${URHO3D_INCLUDE_DIRS})
+# Setup RPATH settings
+if (URHO3D_LIB_TYPE STREQUAL SHARED AND NOT WIN32 AND NOT ANDROID AND NOT IOS AND NOT TVOS AND NOT WEB)
+ # Add RPATH entries when building
+ set (CMAKE_SKIP_BUILD_RPATH FALSE)
+ # And set the RPATH entries so that the executable works both in the build tree and install destination
+ set (CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+ if (APPLE)
+ set (CMAKE_MACOSX_RPATH TRUE)
+ set (ORIGIN @loader_path)
+ else ()
+ set (ORIGIN $ORIGIN)
+ endif ()
+ # Library location relative to the executable in the build tree
+ set (CMAKE_INSTALL_RPATH ${ORIGIN}/../lib)
+ # Library location relative to the executable in the tool directory in the build tree
+ list (APPEND CMAKE_INSTALL_RPATH ${ORIGIN}/../../lib) # The tools are installed one directory further down from normal executable
+ # Library location relative to the executable in the install destination
+ list (APPEND CMAKE_INSTALL_RPATH ${ORIGIN}/../lib${LIB_SUFFIX}/${PATH_SUFFIX}) # The library location is based on SDK install destination
+ # Library location relative to the executable in the tool directory in the install destination
+ list (APPEND CMAKE_INSTALL_RPATH ${ORIGIN}/../../lib${LIB_SUFFIX}/${PATH_SUFFIX})
+ # The last entry to the install destination of the library, if the destination location is not in the system default search path, e.g. /usr/local/lib
+ list (FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} isSystemDir)
+ if (isSystemDir STREQUAL -1)
+ list (APPEND CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${DEST_LIBRARY_DIR})
+ endif ()
+endif ()
+
+
+
# Define target name
set (TARGET_NAME ProjectTemplate)