Skip to content

make install fails: $CMAKE_INSTALL_DATAROOTDIR is empty because GNUInstallDirs is not included #839

@NeoChen1024

Description

@NeoChen1024

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions