Setting paths which depend on CMAKE_INSTALL_PREFIX

Andreas Pakulat apaku at gmx.de
Fri Jun 5 08:46:27 CEST 2009


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.

Andreas
 
-- 
You two ought to be more careful--your love could drag on for years and years.


More information about the Kde-buildsystem mailing list