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

install target on Linux does not follow CMAKE_INSTALL_PREFIX #1224

Closed
cvuchener opened this issue Oct 27, 2020 · 10 comments
Closed

install target on Linux does not follow CMAKE_INSTALL_PREFIX #1224

cvuchener opened this issue Oct 27, 2020 · 10 comments
Assignees

Comments

@cvuchener
Copy link

I configured cmake using a custom install prefix, but installation fails because it tries to copy file into /usr instead of the expected prefix.

Install the project...
-- Install configuration: ""
-- Installing: /home/clement/opt/TIC-80/bin/tic80
-- Installing: /usr/share/applications/tic80.desktop
CMake Error at cmake_install.cmake:65 (file):
  file INSTALL cannot copy file
  "/home/clement/src/TIC-80/build/linux/tic80.desktop" to
  "/usr/share/applications/tic80.desktop": Permission denied.
@nesbox
Copy link
Owner

nesbox commented Oct 27, 2020

Did you use CMAKE_INSTALL_PREFIX variable?

@cvuchener
Copy link
Author

Yes (it is in the title), the cmake command I used was cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/opt/TIC-80.

@nesbox
Copy link
Owner

nesbox commented Oct 28, 2020

Seems tic80.desktop has to be installed exactly to the /usr/share/applications/ folder, in another case system won't see it.
Try to call sudo make install.
Maybe I'm not right, because I'm not familiar with Linux, sorry.

@cvuchener
Copy link
Author

Try to call sudo make install.

I use CMAKE_INSTALL_PREFIX because I don't want files to be installed outside of this prefix. sudo make install is the worst solution, it will create both root-owned files in my home folder and files in /usr.

Seems tic80.desktop has to be installed exactly to the /usr/share/applications/ folder, in another case system won't see it.

Desktop files may be installed in any XDG_DATA_DIRS (e.g. /usr/local/share/applications or ~/.local/share/applications). And creating a AppImage would require the desktop file to be installed in the package AppDir.

I've looked at tic80.desktop content, and there may be another issue with it. The path /usr/bin/tic80 is hard-coded, so it won't work if the tic80 is installed anywhere else. The default value for CMAKE_INSTALL_PREFIX is /usr/local, so it won't even work with the default cmake configuration. Looking at other desktop files, it seems that the binary is assumed to be in the PATH, they simply use the binary name, no absolute path.

@nesbox
Copy link
Owner

nesbox commented Oct 28, 2020

Just fixed tic80.desktop here a345652.

@nesbox
Copy link
Owner

nesbox commented Oct 28, 2020

In other words, I have to read one path from XDG_DATA_DIRS var and install tic80.desktop file to it, is it correct?
What about the folder for the icon? I'm using /usr/share/icons/ at the moment.
Thanks.

@cvuchener
Copy link
Author

In other words, I have to read one path from XDG_DATA_DIRS var and install tic80.desktop file to it, is it correct?

For installation, no. XDG_DATA_DIRS will be used by the desktop shell to find desktop files. cmake should simply install in CMAKE_INSTALL_PREFIX.

I think simply using relative path should be enough.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index be05eaf..a117566 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -892,8 +892,8 @@ if(BUILD_SDL)
 
         install(TARGETS ${TIC80_OUTPUT} DESTINATION bin)
  
-        SET(TIC80_DESKTOP_DIR     "/usr/share/applications/")
-        SET(TIC80_PIXMAPS_DIR     "/usr/share/icons/")
+        SET(TIC80_DESKTOP_DIR     "share/applications/")
+        SET(TIC80_PIXMAPS_DIR     "share/icons/")
 
         install (FILES ${PROJECT_SOURCE_DIR}/build/linux/tic80.desktop DESTINATION ${TIC80_DESKTOP_DIR})
         install (FILES ${PROJECT_SOURCE_DIR}/build/linux/tic80.xml DESTINATION ${TIC80_DESKTOP_DIR})

Just fixed tic80.desktop here a345652.

In the same manner, don't use absolute paths there. If the desktop file is somewhere standard and is found by the desktop shell, I think we can assume then tic80 is in the PATH. That how most desktop files seems work anyway.

Who made the debian package? Maybe they should comment on that. I don't know the debian package creation process very well.

@nesbox
Copy link
Owner

nesbox commented Oct 28, 2020

Removed all the absolute paths, could you please check the latest version?

@nesbox nesbox self-assigned this Oct 28, 2020
@cvuchener
Copy link
Author

Works for me. I also tested installing in ~/.local to make sure tic80.desktop worked and it does (TIC-80 starts and the icon is displayed correctly).

@nesbox
Copy link
Owner

nesbox commented Oct 28, 2020

Awesome, thank you.

@nesbox nesbox closed this as completed Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants