Description
Running cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/.local && make && make install fails with the following error:
CMake Error at app/qtapp/rtkconv_qt/cmake_install.cmake:74 (file):
file cannot create directory: /applications. Maybe need administrative
privileges.
Call Stack (most recent call first):
app/qtapp/cmake_install.cmake:47 (include)
cmake_install.cmake:62 (include)
Root Cause
The top-level CMakeLists.txt does not include GNUInstallDirs. This means CMAKE_INSTALL_DATAROOTDIR is never defined and remains empty.
In app/qtapp/CMakeLists.txt, lines 4–5:
set(XDG_APPS_INSTALL_DIR "${CMAKE_INSTALL_DATAROOTDIR}/applications")
set(XDG_APPS_PIXMAPS_DIR "${CMAKE_INSTALL_DATAROOTDIR}/icons/")
With CMAKE_INSTALL_DATAROOTDIR empty, these evaluate to absolute paths /applications and /icons/ at the filesystem root. The install() rules in all 8 Qt app subdirectories (rtkconv_qt, rtkget_qt, rtklaunch_qt, rtknavi_qt, rtkplot_qt, rtkpost_qt, srctblbrows_qt, strsvr_qt) then attempt to write .desktop and icon files to these root paths, which requires root privileges.
Proposed Fix
Add include(GNUInstallDirs) to the top-level CMakeLists.txt right after project(). This standard CMake module defines CMAKE_INSTALL_DATAROOTDIR as share, so the paths correctly become share/applications and share/icons/.
Before:
project(rtklib LANGUAGES C CXX VERSION 2.4.3)
include(CTest)
After:
project(rtklib LANGUAGES C CXX VERSION 2.4.3)
include(GNUInstallDirs)
include(CTest)
Affected Files
CMakeLists.txt (add include(GNUInstallDirs))
app/qtapp/CMakeLists.txt (no change needed — variables will resolve correctly once GNUInstallDirs is included)
Environment
- OS: Any Linux
- CMake: 4.3
- Branch:
master (commit a9df4ff)
Description
Running
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/.local && make && make installfails with the following error:Root Cause
The top-level
CMakeLists.txtdoes not includeGNUInstallDirs. This meansCMAKE_INSTALL_DATAROOTDIRis never defined and remains empty.In
app/qtapp/CMakeLists.txt, lines 4–5:With
CMAKE_INSTALL_DATAROOTDIRempty, these evaluate to absolute paths/applicationsand/icons/at the filesystem root. Theinstall()rules in all 8 Qt app subdirectories (rtkconv_qt, rtkget_qt, rtklaunch_qt, rtknavi_qt, rtkplot_qt, rtkpost_qt, srctblbrows_qt, strsvr_qt) then attempt to write.desktopand icon files to these root paths, which requires root privileges.Proposed Fix
Add
include(GNUInstallDirs)to the top-levelCMakeLists.txtright afterproject(). This standard CMake module definesCMAKE_INSTALL_DATAROOTDIRasshare, so the paths correctly becomeshare/applicationsandshare/icons/.Before:
After:
Affected Files
CMakeLists.txt(addinclude(GNUInstallDirs))app/qtapp/CMakeLists.txt(no change needed — variables will resolve correctly onceGNUInstallDirsis included)Environment
master(commita9df4ff)