Bug 421621 - Setting CMAKE_INSTALL_PREFIX is not honoured when cmake is run
Summary: Setting CMAKE_INSTALL_PREFIX is not honoured when cmake is run
Status: REPORTED
Alias: None
Product: kdevelop
Classification: Applications
Component: Build tools: CMake (show other bugs)
Version: 5.5.1
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-16 15:27 UTC by Thomas Fischer
Modified: 2023-11-21 08:06 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Output of the build pane showing CMAKE_INSTALL_PREFIX=/usr (3.74 KB, image/png)
2020-05-16 15:27 UTC, Thomas Fischer
Details
Screenshot of the Configure CMake settings dialog showing CMAKE_INSTALL_PREFIX=/tmp/usr (1.67 KB, image/png)
2020-05-16 15:28 UTC, Thomas Fischer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Fischer 2020-05-16 15:27:35 UTC
Created attachment 128518 [details]
Output of the build pane showing CMAKE_INSTALL_PREFIX=/usr

To avoid conflicting with a distribution-based installation, I tried to configure a CMAKE_INSTALL_PREFIX to /tmp/usr instead of /usr. Such an approach works fine both when configuring, compiling, and installing the project on the command line as well as from within QtCreator.

In the "Configure CMake settings" dialog, I can set the CMAKE_INSTALL_PREFIX to /tmp/usr, but for the actual configuration of the project, it is not applied, i.e. cmake is run but command line as shown in the build output shows -DCMAKE_INSTALL_PREFIX=/usr. Subsequently, installation of files fails as the current user has, as expected, no write permissions to /usr.

Running the install phase as root is not what I want.
Comment 1 Thomas Fischer 2020-05-16 15:28:22 UTC
Created attachment 128519 [details]
Screenshot of the Configure CMake settings dialog showing CMAKE_INSTALL_PREFIX=/tmp/usr
Comment 2 Thomas Fischer 2020-05-17 13:29:30 UTC
Just upgraded my Gentoo Linux package from 5.4.6 (stable) to 5.5.1 (unstable). Same problem.
Comment 3 Igor Kushnir 2020-05-24 07:44:18 UTC
There is the Show Advanced button under the CMake Cache Values view. Clicking this button shows/hides additional CMake settings. One of these settings is "Installation prefix", which probably overrides your manually configured CMAKE_INSTALL_PREFIX cache value. Adjusting the path in this field should take effect.

I don't know if KDevelop's disregarding of CMAKE_INSTALL_PREFIX change in CMake Cache Values is a bug or an intentional feature (not particularly obvious or intuitive). Anyway, perhaps these settings shouldn't be labeled as "advanced" and should be visible by default...
Comment 4 Thomas Fischer 2020-05-30 12:01:33 UTC
(In reply to Igor Kushnir from comment #3)
> I don't know if KDevelop's disregarding of CMAKE_INSTALL_PREFIX change in
> CMake Cache Values is a bug or an intentional feature (not particularly
> obvious or intuitive). Anyway, perhaps these settings shouldn't be labeled
> as "advanced" and should be visible by default...

Actually, there are three places where a user may enter CMAKE_INSTALL_PREFIX:
1. In the "Cache values"
2. In the "Advanced" section, visible only after pressing the button "Show Advanced"
3. As an "Extra argument" in the form of "-DCMAKE_INSTALL_PREFIX=..."

Changing the path in the Advanced section (item 2 above), then applying the change does change the value in the Cached values. In any other direction I could not observe any effect.

My recommendations would be:
1. Have fields to enter an "Installation prefix" aka CMAKE_INSTALL_PREFIX at only one place, not both at Cached Values and Advanced. Drop one (or link/sync both).
2. In case the user enters "-DCMAKE_INSTALL_PREFIX=..." in the Extra arguments, extract the path, apply it to the dedicated input widget, and remove "-DCMAKE_INSTALL_PREFIX=..." remove from the Extra arguments.
Comment 5 Gleb Popov 2023-11-21 08:06:51 UTC
I sort of bumped into this with following reproducing steps.

1. For a loaded and configured project "Open Configuration..."
2. Set custom CMAKE_INSTALL_PREFIX
3. Everything is fine...
4. ... until you change something in CMakeLists.txt
5. KDevelop detects the change and reconfigures the project with 

/usr/local/bin/cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Debug /path/to/project

This reverts my custom CMAKE_INSTALL_PREFIX setting to the default one.