if((APPLE OR WIN32) AND NOT ${CMAKE_VERSION} VERSION_LESS 2.8.8)
  find_package(Qt5 COMPONENTS Core REQUIRED)
  set(pfx "")
  if(NOT APPLE)
    set(pfx "bin/")
  endif()

  set(sfx "")
  if(APPLE)
    set(sfx ".app")
  elseif(WIN32)
    set(sfx ".exe")
  endif()

  get_target_property(output_name molequeue OUTPUT_NAME)
  if(output_name)
    set(exe "${pfx}${output_name}${sfx}")
  else()
    set(exe "${pfx}molequeue${sfx}")
  endif()

  get_property(MoleQueue_PLUGINS GLOBAL PROPERTY MoleQueue_PLUGINS)
  set(plugins "")
  foreach(plugin ${MoleQueue_PLUGINS})
    # get_property(location TARGET ${plugin} PROPERTY LOCATION)
    list(APPEND plugins ${plugin})
  endforeach()

  set(dirs "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBRARY_DIR}")
  if(CMAKE_PREFIX_PATH)
    foreach(dir ${CMAKE_PREFIX_PATH})
      list(APPEND dirs "${dir}/bin" "${dir}/lib")
    endforeach()
  endif()

  find_package(Qt5 COMPONENTS Widgets Network REQUIRED)

  include(InstallRequiredSystemLibraries)
  include(DeployQt5)
  install_qt5_executable(${exe} "${plugins}" "" "${dirs}" "lib/molequeue/plugins")
endif()
