[ANNOUNCE] correct (new) way to install libraries and executables

Alexander Neundorf neundorf at kde.org
Mon May 26 22:59:41 CEST 2008


Hi,

to install executables and libraries the install() command is used, usually 
like this:

install(TARGETS kdeui DESTINATION ${LIB_INSTALL_DIR})
install(TARGETS kwrite DESTINATION ${BIN_INSTALL_DIR})

While this works on regular UNIX systems, this has problems on Windows and a 
bit also on OSX, more on that later.
So, instead of using the syntax above (which stays working as it always did), 
the variable INSTALL_TARGETS_DEFAULT_ARGS should be used for installing 
regular* executables and libraries:

install(TARGETS kdeui ${INSTALL_TARGETS_DEFAULT_ARGS})
install(TARGETS kwrite ${INSTALL_TARGETS_DEFAULT_ARGS})

or shorter:

install(TARGETS kdeui kwrite ${INSTALL_TARGETS_DEFAULT_ARGS})

INSTALL_TARGETS_DEFAULT_ARGS contains default values for installing 
executables and libraries, which means:

executables will be installed to 
-${BIN_INSTALL_DIR} on all platforms
-except on OSX, here application bundles (all apps not marked as "NOGUI") are 
installed to ${BUNDLE_INSTALL_DIR}
-the default for BUNDLE_INSTALL_DIR is /Applications/KDE . To the Mac 
developers: is that ok ? (I think I'll change it to /Applications/KDE4, to 
avoid potential trouble once we have KDE5)


shared libraries will be installed to
UNIX, including OSX: ${LIB_INSTALL_DIR}
Windows: the dll will go into ${BIN_INSTALL_DIR}, the lib will go into 
${LIB_INSTALL_DOR}

static libraries will be installed to ${LIB_INSTALL_DIR} on all platforms


So, if you want your libraries and applications to install correctly on all 
platforms, use INSTALL_TARGETS_DEFAULT_ARGS for all regular* libraries and 
executables.

What do I mean with "regular" ?
Don't use INSTALL_TARGETS_DEFAULT_ARGS for plugins, they still have to go into 
${PLUGIN_INSTALL_DIR}
Don't use it for executables which go into SBIN_INSTALL_DIR and 
LIBEXEC_INSTALL_DIR respectively.

Bye
Alex

P.S. INSTALL_TARGETS_DEFAULT_ARGS is set like this (in 
kdelibs/cmake/modules/FindKDE4Internal.cmake):

set(INSTALL_TARGETS_DEFAULT_ARGS  RUNTIME DESTINATION "${BIN_INSTALL_DIR}"
                  LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
                  ARCHIVE DESTINATION "${LIB_INSTALL_DIR}" COMPONENT Devel )



# on the Mac support an extra install directory for application bundles
# starting with cmake 2.6
if(APPLE)
   if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER "2.5")
      set(INSTALL_TARGETS_DEFAULT_ARGS  ${INSTALL_TARGETS_DEFAULT_ARGS}
                                  BUNDLE DESTINATION "${BUNDLE_INSTALL_DIR}" )
   endif("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER "2.5")
endif(APPLE)



More information about the Kde-buildsystem mailing list