From e659766a911fe70e3a55c5310969e09c1aff3864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 20 Jul 2021 10:40:52 +0200 Subject: [PATCH] When install at the system path /usr install the rules file at the pkg config udevdir --- CMakeLists.txt | 71 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e67b1f4b9d8b..7e6ddb2739de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1370,27 +1370,56 @@ if(UNIX AND NOT APPLE) ) option(INSTALL_USER_UDEV_RULES "Install user udev rule file for USB HID and Bulk controllers" ON) - if (INSTALL_USER_UDEV_RULES) - install( - FILES - "${CMAKE_CURRENT_SOURCE_DIR}/res/linux/mixxx-usb-uaccess.rules" - DESTINATION - "${MIXXX_INSTALL_DATADIR}/udev/rules.d" - ) - install(CODE " - message(STATUS \"Important Note: Installation of udev rules\n\" - \"The udev rule file for USB HID and Bulk controller permissions will be\n\" - \"installed to:\n\" - \" ${CMAKE_INSTALL_PREFIX}/${MIXXX_INSTALL_DATADIR}/udev/rules.d.\n\" - \"If you are installing Mixxx from source for your own use, copy\n\" - \"mixxx-usb-uaccess.rules to /etc/udev/rules.d/ and run:\n\" - \" udevadm control --reload-rules && udevadm trigger\n\" - \"as root to load the rules.\n\" - \"If you are building a package for a distribution, the correct directory for\n\" - \"system rules is either /lib/udev/rules.d (e.g. Debian, Fedora) or\n\" - \"/usr/lib/udev/rules.d (e.g. Arch Linux) with an appropriate priority prefix.\n\" - \"Adjust your package script accordingly and set -DINSTALL_USER_UDEV_RULES=OFF\") - ") + if(INSTALL_USER_UDEV_RULES) + set(MIXXX_UDEVDIR "${MIXXX_INSTALL_DATADIR}/udev") + if (CMAKE_INSTALL_PREFIX STREQUAL "/usr") + message(FATAL_ERROR "Bla") + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules( PKGCONFIG_UDEV udev) + if (PKGCONFIG_UDEV_FOUND) + execute_process( + COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=udevdir udev + OUTPUT_VARIABLE PKGCONFIG_UDEVDIR + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(PKGCONFIG_UDEVDIR) + file(TO_CMAKE_PATH "${PKGCONFIG_UDEVDIR}" MIXXX_UDEVDIR) + endif() + endif() + endif() + endif() + if (MIXXX_UDEVDIR STREQUAL "${MIXXX_INSTALL_DATADIR}/udev") + install( + FILES + "${CMAKE_CURRENT_SOURCE_DIR}/res/linux/mixxx-usb-uaccess.rules" + DESTINATION + "${MIXXX_UDEVDIR}/rules.d" + ) + install(CODE " + message(STATUS \"Important Note: Installation of udev rules\n\" + \"The udev rule file for USB HID and Bulk controller permissions have been\n\" + \"installed to:\n\" + \" ${MIXXX_UDEVDIR}/rules.d.\n\" + \"If you are installing Mixxx from source for your own use, copy\n\" + \"mixxx-usb-uaccess.rules to /etc/udev/rules.d/ and run:\n\" + \" udevadm control --reload-rules && udevadm trigger\n\" + \"as root to load the rules.\n\" + \"If you are building a package for a distribution, the correct directory for\n\" + \"system rules is either /lib/udev/rules.d (e.g. Debian, Fedora) or\n\" + \"/usr/lib/udev/rules.d (e.g. Arch Linux) with an appropriate priority prefix.\n\" + \"Adjust your package script accordingly and set -DINSTALL_USER_UDEV_RULES=OFF\") + ") + else() + install( + FILES + "${CMAKE_CURRENT_SOURCE_DIR}/res/linux/mixxx-usb-uaccess.rules" + DESTINATION + "${MIXXX_UDEVDIR}/rules.d" + RENAME + "69-mixxx-usb-uaccess.rules" + ) + endif() endif() endif()