diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6448c9848e9d3b5a90901573f64cffda2fbdf365..5607d50d0028ec1b9d268fd8a1dddbea612b7887 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -88,34 +88,10 @@ project(Gaudi VERSION 36.12
 # Add the "Developer" build type
 include(cmake/DeveloperBuildType.cmake)
 
-
-
-set(CMAKE_SKIP_BUILD_RPATH FALSE)         # don't skip the full RPATH for the build tree
- set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # use always the build RPATH for the build tree
- set(CMAKE_MACOSX_RPATH TRUE)              # use RPATH for MacOSX
- set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # point to directories outside the build tree to the install RPATH
-
- # Check whether to add RPATH to the installation (the build tree always has the RPATH enabled)
- if(APPLE)
-   set(CMAKE_INSTALL_NAME_DIR "@rpath")
-   set(CMAKE_INSTALL_RPATH "@loader_path/../lib")    # self relative LIBDIR
-   # the RPATH to be used when installing, but only if it's not a system directory
-   list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
-   if("${isSystemDir}" STREQUAL "-1")
-     set(CMAKE_INSTALL_RPATH "@loader_path/../lib")
-   endif("${isSystemDir}" STREQUAL "-1")
- elseif(DD4HEP_SET_RPATH)
-   set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # install LIBDIR
-   # the RPATH to be used when installing, but only if it's not a system directory
-   list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
-   if("${isSystemDir}" STREQUAL "-1")
-     set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
-   endif("${isSystemDir}" STREQUAL "-1")
- else()
-   set(CMAKE_SKIP_INSTALL_RPATH TRUE)           # skip the full RPATH for the install tree
- endif()
-
-
+# set RPATH (currently only on macOS)
+if(APPLE)
+  include(cmake/GaudiRPath.cmake)
+endif()
 
 # Set up the GAUDI_ATOMIC_LIBS variable
 include(cmake/GaudiAtomicLibs.cmake)
diff --git a/Gaudi/python/Gaudi/__init__.py b/Gaudi/python/Gaudi/__init__.py
index cf9a350c2e53af9a41da2241eb28482cde11b1d7..32029b8ec512a7c4f79ed0a1f8e8207dae76ac54 100644
--- a/Gaudi/python/Gaudi/__init__.py
+++ b/Gaudi/python/Gaudi/__init__.py
@@ -92,10 +92,12 @@ class Application(object):
             #       API must be protected acquiring the GIL
             #
             if sys.platform == "darwin":
-              libpaths = os.environ["GAUDI_LIBRARY_PATH"]
-              if not libpaths:
-                print("ERROR: GAUDI_LIBRARY_PATH is empty!")
-              for _path in libpaths.split(':'):
+              # LD_LIBRARY_PATH cannot be used for dlopen on macos;
+              # use custom variable GAUDI_LIBRARY_PATH instead
+              _libpaths = os.environ["GAUDI_LIBRARY_PATH"]
+              if not _libpaths:
+                print("WARNING: GAUDI_LIBRARY_PATH is empty!")
+              for _path in _libpaths.split(':'):
                   _lib = os.path.join(_path, "libGaudiKernel.dylib")
                   if os.path.isfile(_lib):
                     gkl = _GaudiKernelLib = ctypes.CDLL(
diff --git a/cmake/GaudiRPath.cmake b/cmake/GaudiRPath.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..e57aff6e6142178b3646cbb5f49790817c9d6299
--- /dev/null
+++ b/cmake/GaudiRPath.cmake
@@ -0,0 +1,28 @@
+# This file sets up Gaudi to fill the RPATH for its libraries.
+# It is inspired from DD4hep (https://github.com/AIDASoft/DD4hep/blob/master/cmake/DD4hepBuild.cmake)
+
+
+set(CMAKE_SKIP_BUILD_RPATH FALSE)         # don't skip the full RPATH for the build tree
+set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # use always the build RPATH for the build tree
+set(CMAKE_MACOSX_RPATH TRUE)              # use RPATH for MacOSX
+set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # point to directories outside the build tree to the install RPATH
+
+# Check whether to add RPATH to the installation (the build tree always has the RPATH enabled)
+if(APPLE)
+  set(CMAKE_INSTALL_NAME_DIR "@rpath")
+  set(CMAKE_INSTALL_RPATH "@loader_path/../lib")    # self relative LIBDIR
+  # the RPATH to be used when installing, but only if it's not a system directory
+  list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
+  if("${isSystemDir}" STREQUAL "-1")
+    set(CMAKE_INSTALL_RPATH "@loader_path/../lib")
+  endif("${isSystemDir}" STREQUAL "-1")
+elseif(DD4HEP_SET_RPATH)
+  set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # install LIBDIR
+  # the RPATH to be used when installing, but only if it's not a system directory
+  list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
+  if("${isSystemDir}" STREQUAL "-1")
+    set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
+  endif("${isSystemDir}" STREQUAL "-1")
+else()
+  set(CMAKE_SKIP_INSTALL_RPATH TRUE)           # skip the full RPATH for the install tree
+endif()