[CMake] 'make package': Is setting generators to different default paths possible?

Winfried winkus4u at arcor.de
Thu Mar 10 17:41:11 EST 2016


It's possible to invoke several CPack generators with one call of 'make
package' by configuring in CMakeLists.txt:
set(CPACK_GENERATOR "STGZ;TGZ;TZ;RPM;DEB")
So far, so good!

A generated package can and shall be relocatable. In other words: You can
determine at package install time, **where** in the file system the content
of the package shall be installed to.
If you install the package without an explicit target location, the default
value is used. Each CPack generator has it's own individual predefined
default value (/usr for RPM, ...).
" This default value may be overwritten from the CMakeLists.txt or the cpack
command line by setting an alternative value.
e.g. set(CPACK_PACKAGING_INSTALL_PREFIX “/opt”) " ( ->doc of
CPACK_PACKAGING_INSTALL_PREFIX)

My question:
It's not unusual that one package has different default locations for
different distributions.
So, is it possible to configure different default locations for RPM and DEB,
so that one call of 'make package' can generate a .rpm package with default
location '/opt/kde3' and a .deb package with default location
'/usr/local/kde' ?

My problem:
When I tried set(CPACK_PACKAGING_INSTALL_PREFIX “/opt/kde3”), 'cmake
-DCMAKE_INSTALL_PREFIX=/opt/kde3 ..' ran normal, but 'make package' aborted
with an error messages (repeated several times):

CMake Error at /usr/share/cmake/Modules/CPackRPM.cmake:623 (file):
  file RELATIVE_PATH must be passed a full path to the directory:
  “/opt/kde3”
Call Stack (most recent call first):
  /usr/share/cmake/Modules/CPackRPM.cmake:1282
(cpack_rpm_prepare_relocation_paths)
  /usr/share/cmake/Modules/CPackRPM.cmake:1770 (cpack_rpm_generate_package)

The code:
# CPACK
include(InstallRequiredSystemLibraries)
set(CPACK_GENERATOR "STGZ;TGZ;TZ;RPM;DEB")
set(CPACK_PACKAGING_INSTALL_PREFIX “/opt/kde3”)
#set(CPACK_SET_DESTDIR "ON") 

set(CPACK_PACKAGE_VERSION       "${TuxMinds_VERSION}")
set(CPACK_PACKAGE_VERSION_MAJOR "${TuxMinds_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${TuxMinds_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${TuxMinds_VERSION_PATCH}")

set(CPACK_PACKAGE_NAME                "${P_NAME}")
set(CPACK_PACKAGE_FILE_NAME          
"${P_NAME}-${CPACK_PACKAGE_VERSION}-1.x86_64")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An easy to use GUI for robot
programming and remote control tool")
set(CPACK_PACKAGE_VENDOR              "Winfried
<manjarofan at users.sourceforge.net>")
set(CPACK_PACKAGE_DESCRIPTION_FILE    "${TuxMinds_SOURCE_DIR}/DESCRIPTION")
set(CPACK_RESOURCE_FILE_LICENSE       "${TuxMinds_SOURCE_DIR}/COPYING")

# RPM
#set(CPACK_RPM_PACKAGE_NAME    "${CPACK_PACKAGE_NAME}")                done
by default!
#set(CPACK_RPM_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")             done
by default!
#set(CPACK_RPM_PACKAGE_RELEASE "1")                                    done
by default, do alter if packaging errors have to be fixed!
#set(CPACK_RPM_PACKAGE_RELEASE "2")                        activate, if the
previous packaging was buggy and/or for fancy Linux distro specific
numbering!
#set(CPACK_RPM_PACKAGE_SUMMARY "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") done
by default!
#set(CPACK_RPM_PACKAGE_VENDOR  "${CPACK_PACKAGE_VENDOR}")              done
by default!
if(BUILD_X64)
  set(CPACK_RPM_PACKAGE_ARCH "x86_64")
else(BUILD_X64)
  set(CPACK_RPM_PACKAGE_ARCH "i386")
endif(BUILD_X64)
set(CPACK_RPM_FILE_NAME
     
"${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}.${CPACK_RPM_PACKAGE_ARCH}.rpm") 
set(CPACK_RPM_PACKAGE_LICENSE "${CPACK_RESOURCE_FILE_LICENSE}")

# DEB

INCLUDE(CPack)

Before trying set(CPACK_PACKAGING_INSTALL_PREFIX “/opt/kde3”) I tried
set(CPACK_SET_DESTDIR "ON").
Files in the package were in the right place but I was warned that the
resulting .rpm package isn't relocatable anymore.



--
View this message in context: http://cmake.3232098.n2.nabble.com/make-package-Is-setting-generators-to-different-default-paths-possible-tp7592978.html
Sent from the CMake mailing list archive at Nabble.com.


More information about the CMake mailing list