From a8fb73b668cbcd02587d81b52e628a38e38b5790 Mon Sep 17 00:00:00 2001 From: Boyuan Yang Date: Fri, 4 Sep 2020 21:05:54 -0400 Subject: [PATCH] Use ${CMAKE_INSTALL_PREFIX} to provide APP_PREFIX Currently the value of $prefix is hardcoded in the source code. This is not a good choice given we have switched to CMake and that CMake provides the builtin variable ${CMAKE_INSTALL_PREFIX} to provide this information. This patch uses the value of ${CMAKE_INSTALL_PREFIX} to populate flameshot's internal variable APP_PREFIX as well as using it in generating the org.flameshot.Flameshot.service file with a proper $prefix value (via CMAKE_INSTALL_FULL_BINDIR as provided by GNUInstallDirs). --- ....service => org.flameshot.Flameshot.service.in} | 2 +- data/dbus/other-path/service-gen.sh | 14 -------------- data/dbus/package/org.flameshot.Flameshot.service | 3 --- src/CMakeLists.txt | 6 +++--- 4 files changed, 4 insertions(+), 21 deletions(-) rename data/dbus/{make/org.dharkael.Flameshot.service => org.flameshot.Flameshot.service.in} (50%) delete mode 100644 data/dbus/other-path/service-gen.sh delete mode 100644 data/dbus/package/org.flameshot.Flameshot.service diff --git a/data/dbus/make/org.dharkael.Flameshot.service b/data/dbus/org.flameshot.Flameshot.service.in similarity index 50% rename from data/dbus/make/org.dharkael.Flameshot.service rename to data/dbus/org.flameshot.Flameshot.service.in index 9866f785..781ffa8a 100644 --- a/data/dbus/make/org.dharkael.Flameshot.service +++ b/data/dbus/org.flameshot.Flameshot.service.in @@ -1,3 +1,3 @@ [D-BUS Service] Name=org.flameshot.Flameshot -Exec=/usr/local/bin/flameshot +Exec=${CMAKE_INSTALL_FULL_BINDIR}/flameshot diff --git a/data/dbus/other-path/service-gen.sh b/data/dbus/other-path/service-gen.sh deleted file mode 100644 index 69e956e8..00000000 --- a/data/dbus/other-path/service-gen.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/bash - -DIR=$(pwd) -TARGET="/usr/bin" - -if [ -n "$1" ] - then - TARGET=${1%/} -fi - -FILE='[D-BUS Service]\nName=org.dharkael.Flameshot\nExec=##REPLACE##/flameshot' - -FILE=${FILE//##REPLACE##/$TARGET} -echo -e $FILE > $DIR/org.dharkael.Flameshot.service diff --git a/data/dbus/package/org.flameshot.Flameshot.service b/data/dbus/package/org.flameshot.Flameshot.service deleted file mode 100644 index 354eed21..00000000 --- a/data/dbus/package/org.flameshot.Flameshot.service +++ /dev/null @@ -1,3 +0,0 @@ -[D-BUS Service] -Name=org.flameshot.Flameshot -Exec=/usr/bin/flameshot diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 74efb17a..6442004f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -102,7 +102,7 @@ target_link_libraries( Qt5::Network Qt5::Widgets) -target_compile_definitions(flameshot PRIVATE APP_PREFIX="/usr") +target_compile_definitions(flameshot PRIVATE APP_PREFIX="${CMAKE_INSTALL_PREFIX}") target_compile_definitions(flameshot PRIVATE APP_VERSION="v0.8.0") target_compile_definitions(flameshot PRIVATE IMGUR_CLIENT_ID="313baf0c7b4d3ff") target_compile_definitions(flameshot PRIVATE QAPPLICATION_CLASS=QApplication) @@ -137,8 +137,8 @@ configure_file(${CMAKE_SOURCE_DIR}/docs/bash-completion/flameshot configure_file(${CMAKE_SOURCE_DIR}/data/dbus/org.flameshot.Flameshot.xml ${CMAKE_CURRENT_BINARY_DIR}/share/dbus-1/interfaces/org.flameshot.Flameshot.xml COPYONLY) -configure_file(${CMAKE_SOURCE_DIR}/data/dbus/package/org.flameshot.Flameshot.service - ${CMAKE_CURRENT_BINARY_DIR}/share/dbus-1/services/org.flameshot.Flameshot.service COPYONLY) +configure_file(${CMAKE_SOURCE_DIR}/data/dbus/org.flameshot.Flameshot.service.in + ${CMAKE_CURRENT_BINARY_DIR}/share/dbus-1/services/org.flameshot.Flameshot.service) # Install Icons configure_file(${CMAKE_SOURCE_DIR}/data/img/hicolor/48x48/apps/flameshot.png