@@ -24,14 +24,6 @@ endif()
2424# Generate folders for IDE targets (e.g., VisualStudio solutions)
2525set_property (GLOBAL PROPERTY USE_FOLDERS ON )
2626
27- # Set runtime path, i.e. where shared libs are searched relative to the exe
28- if (APPLE )
29- list (APPEND CMAKE_INSTALL_RPATH "@executable_path/../LSL/lib" )
30- list (APPEND CMAKE_INSTALL_RPATH "@executable_path/../lib" )
31- list (APPEND CMAKE_INSTALL_RPATH "@executable_path/" )
32- elseif (UNIX )
33- list (APPEND CMAKE_INSTALL_RPATH "\$ ORIGIN/../LSL/lib:\$ ORIGIN/../lib/:\$ ORIGIN" )
34- endif ()
3527
3628set (CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "limited configs" FORCE)
3729
@@ -82,6 +74,17 @@ function(installLSLApp target)
8274 set_property (INSTALL "${PROJECT_NAME} /$<TARGET_FILE_NAME:${target} >" PROPERTY
8375 CPACK_START_MENU_SHORTCUTS "${target} " )
8476
77+
78+ # Set runtime path, i.e. where shared libs are searched relative to the exe
79+ set (LIBDIRGENEXPR "../$<IF:$<BOOL:${LSL_UNIXFOLDERS} >,lib/,LSL/lib/>" )
80+ if (APPLE )
81+ set_property (TARGET ${target} APPEND
82+ PROPERTY INSTALL_RPATH "@executable_path/;@executable_path/${LIBDIRGENEXPR} " )
83+ elseif (UNIX )
84+ set_property (TARGET ${target}
85+ PROPERTY INSTALL_RPATH "\$ ORIGIN:\$ ORIGIN/${LIBDIRGENEXPR} " )
86+ endif ()
87+
8588 if (LSL_UNIXFOLDERS)
8689 include (GNUInstallDirs)
8790 set (lsldir "\$ {CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} " )
@@ -125,6 +128,7 @@ function(installLSLApp target)
125128 # For MacOS we need to know if the installed target will be a .app bundle...
126129 if (APPLE )
127130 get_target_property (target_is_bundle ${target} MACOSX_BUNDLE )
131+ set (APPLE_APP_PATH "\$ {CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR} /${target} .app" )
128132 endif (APPLE )
129133
130134 # Copy lsl library. Logic is a bit complicated.
@@ -147,10 +151,13 @@ function(installLSLApp target)
147151 # Mac bundles need further fixup (mostly for 3rd party libs)
148152 # fixup_bundle appears to be broken for Qt apps. Use only for non-Qt.
149153 if (APPLE AND target_is_bundle AND NOT qtapp)
150- install (CODE "
151- include(BundleUtilities)
152- set(BU_CHMOD_BUNDLE_ITEMS ON)
153- fixup_bundle(\$ {CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR} /${target} .app \"\" \" ${lsldir} \" )
154+ install (CODE
155+ "
156+ get_filename_component(LIBDIR $<TARGET_FILE:LSL::lsl> DIRECTORY)
157+ message(STATUS \$ {LIBDIR})
158+ include(BundleUtilities)
159+ set(BU_CHMOD_BUNDLE_ITEMS ON)
160+ fixup_bundle(${APPLE_APP_PATH} \"\" \"\$ {LIBDIR}\" )
154161 "
155162 COMPONENT ${PROJECT_NAME}
156163 )
@@ -184,21 +191,25 @@ function(installLSLApp target)
184191 endwhile()"
185192 COMPONENT ${SHAREDLIBCOMPONENT} )
186193 elseif (APPLE )
187- # It should be enough to call fixup_bundle (see below ),
194+ # It should be enough to call fixup_bundle (see above ),
188195 # but this fails to install qt plugins (cocoa).
189- # Use macdeployqt instead (but this is bad at grabbing lsl dylib, so we did that above)
196+ # Use macdeployqt instead. This is bad at grabbing lsl dylib, so we already did it above.
190197 findQtInstallationTool("macdeployqt" )
191198 install (CODE "
192- if(\$ {CMAKE_INSTALL_CONFIG_NAME} STREQUAL Debug)
193- set(debug 1)
194- endif()
195199 message(STATUS \" Running Qt Deploy Tool for $<TARGET_FILE:${target} >...\" )
196200 execute_process(COMMAND
197- echo \" ${QT_DEPLOYQT_EXECUTABLE} \"
198- $<TARGET_FILE:${target} >
199- -verbose=1
200- $<$<BOOL:\$ {debug}>:--use-debug-libs>
201+ \" ${QT_DEPLOYQT_EXECUTABLE} \"
202+ \" ${APPLE_APP_PATH} \"
203+ -verbose=1 -always-overwrite
204+ \$ <\$ <STREQUAL:\$ {CMAKE_INSTALL_CONFIG_NAME},\" Debug\" >:--use-debug-libs>
205+ COMMAND_ECHO STDOUT
206+ OUTPUT_VARIABLE DEPLOYOUTPUT
207+ ERROR_VARIABLE DEPLOYOUTPUT
208+ RESULT_VARIABLE DEPLOYSTATUS
201209 )
210+ if(\$ {DEPLOYSTATUS})
211+ message(WARNING \"\$ {DEPLOYOUTPUT}\" )
212+ endif()
202213 " )
203214 endif ()
204215endfunction ()
0 commit comments