set(SWIPL_ABS_INSTALL_ARCH_LIB "${CMAKE_INSTALL_PREFIX}/${SWIPL_INSTALL_ARCH_LIB}")

set(CMAKE_SKIP_BUILD_RPATH  FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
if(SWIPL_SHARED_LIB)
  set(CMAKE_INSTALL_RPATH "${SWIPL_ABS_INSTALL_ARCH_LIB}")
  set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

  list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
       "${SWIPL_ABS_INSTALL_ARCH_LIB}" isSystemDir)
  if(isSystemDir STREQUAL "-1")
     set(CMAKE_INSTALL_RPATH "${SWIPL_ABS_INSTALL_ARCH_LIB}")
  endif()
endif()

if(BUILD_MACOS_BUNDLE)
  set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks")
endif()
