[CMake] CPack: how to change /usr install location ?

Eric Noulard eric.noulard at gmail.com
Wed Mar 18 13:27:45 EDT 2009


2009/3/18 Stephen Collyer <scollyer at netspinner.co.uk>:
> I've been trying to use CPack to generate an RPM package with cmake 2.6.2.
>
> I have the following trivial CMakeLists.txt:
>
> ############################################
>
> PROJECT(PRINT)
> CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
>
> ADD_LIBRARY(print print.cpp)
>
> SET(PRINTER_SRCS main.cpp)
> ADD_EXECUTABLE(printer ${PRINTER_SRCS})
> TARGET_LINK_LIBRARIES(printer print)
>
> INSTALL(TARGETS printer print
>         ARCHIVE DESTINATION print
>         LIBRARY DESTINATION print
>         RUNTIME DESTINATION print)
>
> SET(CPACK_PACKAGE_NAME "print")
> SET(CPACK_PACKAGE_INSTALL_DIRECTORY "print-package")
> SET(CPACK_GENERATOR "RPM")
> INCLUDE(CPack)
>
> ###################################
>
> Regardless of what I put in CPACK_PACKAGE_INSTALL_DIRECTORY, the generated
> rpm installs into /usr/print.
>
> Can someone tell me what I would have to do to install into, say, /opt ?

Yes,

set CMAKE_INSTALL_PREFIX to /opt (using cmake command line, ccmake
,cmake-gui etc...)

when packaging RPM with CPack you should

SET(CPACK_SET_DESTDIR "ON")

in your CMakeLists.txt.

More information on CPack RPM may be found there:
http://www.vtk.org/Wiki/CMake:CPackPackageGenerators#RPM_.28Unix_Only.29



-- 
Erk


More information about the CMake mailing list