Setting paths which depend on CMAKE_INSTALL_PREFIX

Alexander Neundorf neundorf at kde.org
Mon Jun 15 20:36:53 CEST 2009


On Friday 05 June 2009, Andreas Pakulat wrote:
> On 04.06.09 23:49:14, David Jarvie wrote:
> > I'm creating a separate package for KAlarm, and want to default its
> > installation path to the KDE installation directory. In CMakeLists.txt
> > I've got:
> >
> > find_package(KDE4 4.1.0 REQUIRED)
> > if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
> >    set(CMAKE_INSTALL_PREFIX "${KDE4_INSTALL_DIR}" CACHE PATH "Install
> > prefix") endif (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
> >
> > According to what I've read on this mailing list, this ought to set all
> > the other KDE install paths used by cmake to use the new value of
> > CMAKE_INSTALL_PREFIX also. However, it actually installs into /usr/local
> > instead (which is not where my KDE is installed). I seem to have to add
> > the following definitions (copied from FindKDE4Internal.cmake with
> > appropriate amendments) after the 'set' above to make it work:
> >
> > set(EXEC_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE PATH "Base
> > directory for executables and libraries")
> > #   set(BIN_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/bin" CACHE PATH "The
> > install dir for executables")
> > #   set(LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE
> > PATH "The subdirectory relative to the install prefix where libraries
> > will be installed")
> > ...etc.
> >
> > Is there any way to set all the install paths to use the new definition
> > of CMAKE_INSTALL_PREFIX automatically, without having to define each one
> > like this?
>
> No, because they're set in FindKDE4Internal.cmake, which is run by the
> find_package(KDE4) call. So you'd have to set CMAKE_INSTALL_PREFIX
> before doing the find_package, but of course you don't know the kde
> install prefix.
>
> However I don't think defaulting to the kde install prefix is a good
> idea, because then people with kde4 packages from their distro and
> running cmake .. in the builddir for kalarm will screw their /usr
> directory. /usr belongs to the distribution and self-compiled apps
> are not supposed to install anything there. Thats also why cmake and
> other buildtools default to /usr/local and not /usr.

I fully agree with Andreas (and his other posts in this thread).

If the user wants to install it to /usr, he should run
cmake -DCMAKE_INSTALL_PREFIX=/usr <dir>

(or cmake-gui <dir>, which makes it easier to discover).

Right from the beginning I didn't want to have too much magic in the cmake 
stuff (there is now enough already), and changing the default behaviour of 
cmake to install to /usr/local/ to do something else would be very 
KDE-specific behaviour. I.e. in KDE cmake would behave differently than 
everywhere else, i.e. also differently than documented everywhere else.

Or you add the "configure" script which exists right now in kdelibs/ to 
kalarm. If then the unknowing user runs ./configure, he will get the output 
which tells him that --prefix now equal -DCMAKE_INSTALL_PATH

Alex


More information about the Kde-buildsystem mailing list