[CMake] CPACK installation path configuration

Yuri Timenkov ytimenkov at parallels.com
Wed Jul 23 07:59:52 EDT 2008


On Wednesday 23 July 2008 15:38:52 Johnson, Hans wrote:
> Yuri,
>
> Thanks for your help.  The problem was that I needed to set both
> CPACK_PACKAGING_INSTALL_PREFIX  and CPACK_PACKAGE_DEFAULT_LOCATION  to get
> the desired behavior.  I'm still not sure how these two options interact to
> produce the correct result.
>
> SET(CPACK_PACKAGING_INSTALL_PREFIX "/")
> SET( CPACK_PACKAGE_DEFAULT_LOCATION "/opt/${CPACK_PACKAGE_NAME}")
>
> >From my testing my guess is that the install path is constructed as:
>
> ${CPACK_PACKAGE_DEFAULT_LOCATION}/${CPACK_PACKAGING_INSTALL_PREFIX}/...
As I understand CPACK_PACKAGE_DEFAULT_LOCATION is Mac-specific option which is 
used by PackageMaker when installing pkg.
I suppose you need to fix CMAKE_INSTALL_PREFIX in top-level CMakeLists.txt. I 
use following technique:
# Replace CMAKE_INSTALL_PREFIX to Currently used one,
# If it wasn't overridden from command line / cache.
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
	set(CMAKE_INSTALL_PREFIX "/opt/MyProduct" CACHE PATH "Install path prefix, 
prepended onto install directories." FORCE)
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

And to avoid putting stuff in /usr, you should set 
CPACK_PACKAGING_INSTALL_PREFIX to "/" (or CPACK_SET_DESTDIR to true).

>
>
> Again,
> Thanks,
> Hans
>
> On 7/23/08 2:29 AM, "Yuri Timenkov" <ytimenkov at parallels.com> wrote:
> > What is your CMAKE_INSTALL_PREFIX? And where your product installs with
> > make install command?
> > Did you use CPACK_SET_DESTDIR?
> >
> > On Wednesday 23 July 2008 00:51:46 Hans Johnson wrote:
> >> Hello,
> >>
> >> I¹ve been trying to figure out how to use CPACK to distribute my package
> >> as a dmg, rpm, and tar.gz files.  I¹ve been able to successfully create
> >> the files, but the locations where the resulting files are being put are
> >> not as desired.
> >>
> >> I¹d like the resulting binary to be installed in
> >> /opt/BRAINSFit/bin/BRAINSFit
> >> Currently PackageMaker installs in /opt/BRAINSFit/usr/bin/BRAINSFit and
> >> RPM installs in /usr/bin/BRAINSFit.
> >>
> >> The  CMakeList.txt files are included in my previous message.
> >>
> >> Any help or suggestions on what to try would be enormously appreciated.
> >>
> >> Thanks,
> >> Hans
> >>
> >>
> >>
> >> From: Johnson Hans <hans-johnson at uiowa.edu>
> >> Date: Sat, 19 Jul 2008 12:29:48 -0500
> >> To: <cmake at cmake.org>
> >> Subject: CPACK installation path configuration
> >>
> >> Hello,
> >>
> >> I am trying to use cpack to create distributions of a project available
> >> on NITRC:
> >> svn checkout https://www.nitrc.org/svn/multimodereg BRAINSFit
> >>
> >> I¹d like the resulting binary to be installed in
> >> /opt/BRAINSFit/bin/BRAINSFit
> >>
> >> Currently PackageMaker installs in /opt/BRAINSFit/usr/bin/BRAINSFit and
> >> RPM installs in /usr/bin/BRAINSFit.
> >>
> >> Can someone please help me fix my CPACK variables so that the desired
> >> install locations are respected?
> >>
> >> ======
> >> I¹m using CMake 2.6.0
> >>
> >> Any other advise about CPACK style issues would also be appreciated
> >> because I¹ll be repeating this process for several other packages next
> >> week.
> >>
> >> Thanks,
> >> Hans
> >>
> >> ====CMakeLists.txt====
> >> PROJECT(BRAINSFit)
> >> cmake_minimum_required(VERSION 2.6)
> >> cmake_policy(VERSION 2.6)
> >>
> >> INCLUDE(${BRAINSFit_SOURCE_DIR}/IJMacros.txt)
> >>
> >> #the following are required to uses Dart
> >> ENABLE_TESTING()
> >> INCLUDE(Dart)
> >>
> >> #-----------------------------------------------------------------------
> >>--- - --
> >> # Output directories.
> >>  IF(NOT LIBRARY_OUTPUT_PATH)
> >>    SET (LIBRARY_OUTPUT_PATH ${BRAINSFit_BINARY_DIR}/bin CACHE INTERNAL
> >> "Single output directory for building all librari
> >> es.")
> >>  ENDIF(NOT LIBRARY_OUTPUT_PATH)
> >>  IF(NOT EXECUTABLE_OUTPUT_PATH)
> >>    SET (EXECUTABLE_OUTPUT_PATH ${BRAINSFit_BINARY_DIR}/bin CACHE
> >> INTERNAL "Single output directory for building all exec
> >> utables.")
> >>  ENDIF(NOT EXECUTABLE_OUTPUT_PATH)
> >>  MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
> >>
> >>
> >> OPTION(BUILD_AGAINST_SLICER3 "If OFF, then build self contained version
> >> that only depends on ITK ." OFF)
> >> MARK_AS_ADVANCED(BUILD_AGAINST_SLICER3)
> >>
> >> OPTION(BRAINSFit_BUILD_LOCAL_CLP "If ON, then build self contained
> >> version that only depends on ITK ." ON)
> >> MARK_AS_ADVANCED(BRAINSFit_BUILD_LOCAL_CLP)
> >>
> >> IF(BUILD_AGAINST_SLICER3)
> >>   FIND_PACKAGE(Slicer3 REQUIRED)
> >>   IF (Slicer3_FOUND)
> >>     INCLUDE(${Slicer3_USE_FILE})
> >>   ELSE (Slicer3_FOUND)
> >>     MESSAGE(ERROR "Cannot build without a Slicer3 build tree or a
> >> Slicer3 installation. Please set Slicer3_DIR.")
> >>   ENDIF (Slicer3_FOUND)
> >> ELSE(BUILD_AGAINST_SLICER3)
> >>   FIND_PACKAGE(ITK)
> >>   IF(ITK_FOUND)
> >>     INCLUDE(${ITK_USE_FILE})
> >>   ELSE(ITK_FOUND)
> >>     MESSAGE(FATAL_ERROR
> >>             "Cannot build without ITK.  Please set ITK_DIR.")
> >>   ENDIF(ITK_FOUND)
> >>   IF(BRAINSFit_BUILD_LOCAL_CLP)
> >>     MESSAGE(WARNING "Building local Slicer Execution Model")
> >> CMakeLists.txt
> >> 1,1            Top
> >> "CMakeLists.txt" 144L, 5487C
> >>                  RUNTIME DESTINATION bin
> >>                  LIBRARY DESTINATION lib
> >>                  ARCHIVE DESTINATION lib/static)
> >>
> >> INCLUDE(InstallRequiredSystemLibraries)
> >>
> >>
> >> SET(CPACK_PACKAGE_VERSION_MAJOR "2")
> >> SET(CPACK_PACKAGE_VERSION_MINOR "4")
> >> SET(CPACK_PACKAGE_VERSION_PATCH "1")
> >>
> >> SET(CPACK_PACKAGE_NAME "BRAINSFit")
> >> SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${BRAINSFit}-dev")
> >> SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${BRAINSFit}-A program for
> >> medical image registraiton with mutual information met
> >> ric.")
> >> SET(CPACK_PACKAGE_DESCRIPTION_FILE "${BRAINSFit_SOURCE_DIR}/ReadMe.txt")
> >> SET(CPACK_RESOURCE_FILE_LICENSE "${BRAINSFit_SOURCE_DIR}/Copyright.txt")
> >>
> >> SET(CPACK_PACKAGE_DEFAULT_LOCATION "/opt/${CPACK_PACKAGE_NAME}")
> >> SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${BRAINSFit}")
> >>
> >> SET(CPACK_PACKAGE_VENDOR "NAMIC Tool Developed at The University of
> >> Iowa")
> >>
> >> SET(CPACK_SOURCE_GENERATOR "TGZ;TZ")
> >> #SET(CPACK_SOURCE_IGNORE_FILES "/CVS/;/\\.svn/;\\.swp$;\\.#;/#;\\.*~")
> >> SET(CPACK_SOURCE_IGNORE_FILES "")
> >>   SET(CPACK_PACKAGE_EXECUTABLES "BRAINSFit";"A program for registering
> >> medical images with mutual information.")
> >>
> >> IF(WIN32 AND NOT UNIX)
> >>   SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
> >> "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VE
> >>RSI O N_M
> >> INOR}.${CPACK_PACKAGE_VERSION_PATCH}")
> >>   # There is a bug in NSI that does not handle full unix paths properly.
> >> Make
> >>   # sure there is at least one set of four (4) backlasshes.
> >>   SET(CPACK_PACKAGE_ICON
> >> "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
> >>   SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")
> >>   SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} My
> >> Famous Project")
> >>   SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.nitrc.org")
> >>   SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.nitrc.org")
> >>   SET(CPACK_NSIS_CONTACT "hans-johnson at uiowa.edu")
> >>   SET(CPACK_NSIS_MODIFY_PATH ON)
> >> ELSE(WIN32 AND NOT UNIX)
> >>   SET(CPACK_STRIP_FILES OFF)
> >>   SET(CPACK_SOURCE_STRIP_FILES OFF)
> >> ENDIF(WIN32 AND NOT UNIX)
> >>
> >> INCLUDE(CPack)



More information about the CMake mailing list