Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmake build variables #265

Merged
merged 1 commit into from
Dec 28, 2022
Merged

Cmake build variables #265

merged 1 commit into from
Dec 28, 2022

Conversation

tpeacock19
Copy link
Contributor

This is not a major issue, but I wanted to create one before any potential PR. The current cmake setup does not allow for building without sudo privileges. I've made some local changes below that will respect the CMAKE_INSTALL_PREFIX and DESTDIR variables if present. As well as allowing the user to set the SESSION_BUS_DIR.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index fda9f08..463bf81 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -99,7 +99,12 @@ endif()
 if (NOT DEFINED FISH_COMPLETIONS_DIR)
     pkg_get_variable(FISH_COMPLETIONS_DIR fish completionsdir)
 endif()
-pkg_get_variable(SESSION_BUS_DIR dbus-1 session_bus_services_dir)
+if (NOT DEFINED SESSION_BUS_DIR)
+  pkg_get_variable(SESSION_BUS_DIR dbus-1 session_bus_services_dir)
+endif()
+if (NOT DEFINED CMAKE_INSTALL_PREFIX)
+  set(CMAKE_INSTALL_PREFIX "/" )
+endif()
 
 file(GLOB_RECURSE SKELETONS Extra/skeletons/*.skel)
 
@@ -108,11 +113,11 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.clight.clight.service
 install(FILES ${EXTRA_DIR}/clight.conf
         DESTINATION ${CLIGHT_CONFDIR})
 install(FILES ${EXTRA_DIR}/desktop/clight.desktop
-        DESTINATION /etc/xdg/autostart)
+        DESTINATION ${DESTDIR}${CMAKE_INSTALL_PREFIX}/etc/xdg/autostart)
 install(FILES ${EXTRA_DIR}/desktop/clightc.desktop
-        DESTINATION /usr/share/applications)
+        DESTINATION ${DESTDIR}${CMAKE_INSTALL_PREFIX}/usr/share/applications)
 install(FILES ${EXTRA_DIR}/icons/clight.svg
-        DESTINATION /usr/share/icons/hicolor/scalable/apps)
+        DESTINATION ${DESTDIR}${CMAKE_INSTALL_PREFIX}/usr/share/icons/hicolor/scalable/apps)
 install(FILES ${SKELETONS} DESTINATION ${CLIGHT_DATADIR})
 install(DIRECTORY DESTINATION ${CLIGHT_DATADIR}/modules.d/)
 

@FedeDP
Copy link
Owner

FedeDP commented Dec 11, 2022

Hi!

The current cmake setup does not allow for building without sudo privileges.

You mean running make install step requires sudo rights, right?
I am ok with fixing that!
I'd use CMAKE_INSTALL_SYSCONFDIR for etc files, and CMAKE_INSTALL_DATAROOTDIR for share files; there is no need to manually prepend ${DESTDIR}${CMAKE_INSTALL_PREFIX} while using those as they already deal with CMAKE_INSTALL_PREFIX internally.

@tpeacock19
Copy link
Contributor Author

You mean running make install step requires sudo rights, right?

You are right, its the installation that requires it. I've made the
changes you suggested.

Copy link
Owner

@FedeDP FedeDP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM!
Thank you!

@FedeDP FedeDP merged commit d5a73f6 into FedeDP:master Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants