From 209d725acdd6b49e575ea593bc7ff9834438bede Mon Sep 17 00:00:00 2001 From: Zhu Zihao Date: Tue, 31 Aug 2021 00:21:23 +0800 Subject: [PATCH] Allow user to specify custom prefix for resource files. * CMakeLists.txt: include GNUInstallDirs. * cpufreq/CMakeLists.txt: Replace hardcoded path with ${CMAKE_INSTALL_XXXXX} variables. * session/CMakeLists.txt: Ditto. * shutdown-ui/CMakeLists.txt: Ditto. * setting-daemon/CMakeLists.txt: Ditto. * screen-brightness/CMakeLists.txt: Ditto. * polkit-agent/CMakeLists.txt: Ditto. * screen-brightness/org.cutefish.brightness.pkexec.policy: Rename to file with ".in" extension. Replace hardcoded path with @CMAKE_INSTALL_FULL_XXXXX@ variables. * cpufreq/org.cutefish.cpufreq.pkexec.policy: Ditto. --- CMakeLists.txt | 2 ++ cpufreq/CMakeLists.txt | 8 +++++++- ...kexec.policy => org.cutefish.cpufreq.pkexec.policy.in} | 4 ++-- polkit-agent/CMakeLists.txt | 4 ++-- screen-brightness/CMakeLists.txt | 8 +++++++- ...ec.policy => org.cutefish.brightness.pkexec.policy.in} | 4 ++-- session/CMakeLists.txt | 2 +- settings-daemon/CMakeLists.txt | 2 +- shutdown-ui/CMakeLists.txt | 2 +- 9 files changed, 25 insertions(+), 11 deletions(-) rename cpufreq/{org.cutefish.cpufreq.pkexec.policy => org.cutefish.cpufreq.pkexec.policy.in} (80%) rename screen-brightness/{org.cutefish.brightness.pkexec.policy => org.cutefish.brightness.pkexec.policy.in} (79%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0677c56..a130c7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,8 @@ find_package(ECM REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH}) +include(GNUInstallDirs) + add_subdirectory(polkit-agent) add_subdirectory(screen-brightness) add_subdirectory(session) diff --git a/cpufreq/CMakeLists.txt b/cpufreq/CMakeLists.txt index 7676a33..fe80995 100644 --- a/cpufreq/CMakeLists.txt +++ b/cpufreq/CMakeLists.txt @@ -13,5 +13,11 @@ target_link_libraries(${TARGET} Qt5::X11Extras ) +configure_file( + org.cutefish.cpufreq.pkexec.policy.in + org.cutefish.cpufreq.pkexec.policy + @ONLY +) + install(TARGETS ${TARGET} DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES org.cutefish.cpufreq.pkexec.policy DESTINATION /usr/share/polkit-1/actions/) +install(FILES org.cutefish.cpufreq.pkexec.policy DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/polkit-1/actions/) diff --git a/cpufreq/org.cutefish.cpufreq.pkexec.policy b/cpufreq/org.cutefish.cpufreq.pkexec.policy.in similarity index 80% rename from cpufreq/org.cutefish.cpufreq.pkexec.policy rename to cpufreq/org.cutefish.cpufreq.pkexec.policy.in index 8f134e9..bea6b8f 100644 --- a/cpufreq/org.cutefish.cpufreq.pkexec.policy +++ b/cpufreq/org.cutefish.cpufreq.pkexec.policy.in @@ -10,6 +10,6 @@ no yes - /usr/bin/cutefish-cpufreq + @CMAKE_INSTALL_FULL_BINDIR@/cutefish-cpufreq - \ No newline at end of file + diff --git a/polkit-agent/CMakeLists.txt b/polkit-agent/CMakeLists.txt index 8a28947..f888e47 100644 --- a/polkit-agent/CMakeLists.txt +++ b/polkit-agent/CMakeLists.txt @@ -41,8 +41,8 @@ install(TARGETS cutefish-polkit-agent install(FILES cutefish-polkit-agent.desktop - DESTINATION "/etc/xdg/autostart" + DESTINATION "${CMAKE_INSTALL_FULL_SYSCONFDIR}/xdg/autostart" COMPONENT Runtime ) -install(FILES ${QM_FILES} DESTINATION /usr/share/cutefish-polkit-agent/translations) +install(FILES ${QM_FILES} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cutefish-polkit-agent/translations) diff --git a/screen-brightness/CMakeLists.txt b/screen-brightness/CMakeLists.txt index 6f1c02d..e7405bc 100644 --- a/screen-brightness/CMakeLists.txt +++ b/screen-brightness/CMakeLists.txt @@ -17,5 +17,11 @@ target_link_libraries(${PROJECT_NAME} Qt5::Widgets ) +configure_file( + org.cutefish.brightness.pkexec.policy.in + org.cutefish.brightness.pkexec.policy + @ONLY +) + install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES org.cutefish.brightness.pkexec.policy DESTINATION /usr/share/polkit-1/actions/) +install(FILES org.cutefish.brightness.pkexec.policy DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/polkit-1/actions/) diff --git a/screen-brightness/org.cutefish.brightness.pkexec.policy b/screen-brightness/org.cutefish.brightness.pkexec.policy.in similarity index 79% rename from screen-brightness/org.cutefish.brightness.pkexec.policy rename to screen-brightness/org.cutefish.brightness.pkexec.policy.in index 278fdcc..4cec516 100644 --- a/screen-brightness/org.cutefish.brightness.pkexec.policy +++ b/screen-brightness/org.cutefish.brightness.pkexec.policy.in @@ -10,6 +10,6 @@ no yes - /usr/bin/cutefish-screen-brightness + @CMAKE_INSTALL_FULL_BINDIR@/cutefish-screen-brightness - \ No newline at end of file + diff --git a/session/CMakeLists.txt b/session/CMakeLists.txt index bbd6ee5..0185b72 100644 --- a/session/CMakeLists.txt +++ b/session/CMakeLists.txt @@ -31,4 +31,4 @@ target_link_libraries(${TARGET} ) install(TARGETS ${TARGET} DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES cutefish-xsession.desktop DESTINATION /usr/share/xsessions/) +install(FILES cutefish-xsession.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/xsessions/) diff --git a/settings-daemon/CMakeLists.txt b/settings-daemon/CMakeLists.txt index 3f7948a..abdc5f7 100644 --- a/settings-daemon/CMakeLists.txt +++ b/settings-daemon/CMakeLists.txt @@ -73,4 +73,4 @@ add_custom_target(translations DEPENDS ${QM_FILES} SOURCES ${TS_FILES}) add_dependencies(${TARGET} translations) install(TARGETS ${TARGET} DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES ${QM_FILES} DESTINATION /usr/share/${TARGET}/translations) +install(FILES ${QM_FILES} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${TARGET}/translations) diff --git a/shutdown-ui/CMakeLists.txt b/shutdown-ui/CMakeLists.txt index 485d46b..cf1193e 100644 --- a/shutdown-ui/CMakeLists.txt +++ b/shutdown-ui/CMakeLists.txt @@ -18,6 +18,6 @@ file(GLOB TS_FILES translations/*.ts) qt5_create_translation(QM_FILES ${TS_FILES}) add_custom_target(shutdown-translations DEPENDS ${QM_FILES} SOURCES ${TS_FILES}) add_dependencies(cutefish-shutdown shutdown-translations) -install(FILES ${QM_FILES} DESTINATION /usr/share/cutefish-shutdown/translations) +install(FILES ${QM_FILES} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cutefish-shutdown/translations) install(TARGETS cutefish-shutdown RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})