https://public.kitware.com/Wiki/api.php?action=feedcontributions&user=Paulfitz&feedformat=atomKitwarePublic - User contributions [en]2024-03-29T10:02:16ZUser contributionsMediaWiki 1.38.6https://public.kitware.com/Wiki/index.php?title=CMake:Packaging_With_CPack&diff=30687CMake:Packaging With CPack2010-09-22T13:39:11Z<p>Paulfitz: /* CPack Generators */ grammar fix</p>
<hr />
<div><!-- CPack documentation and manual --><br />
=Introduction=<br />
<br />
''CPack'' is a powerful, easy to use, cross-platform software packaging tool distributed with [http://www.cmake.org CMake] since version 2.4.2. It uses the [[CMake:CPackPackageGenerators|generators]] concept from CMake, to abstract package generation on specific platforms, and it can be used with or without CMake.<br />
<br />
Using either a simple configuration file or the CMake module, a complex project can be packaged into an installer.<br />
<br />
=Using CPack without CMake=<br />
<br />
CPack can be used directly by specifying a CPackConfig.cmake file, which uses CMake syntax and defines several variables. Here is an example CPackConfig.cmake file for a Linux system:<br />
<br />
<pre><nowiki>SET(CPACK_CMAKE_GENERATOR "Unix Makefiles")<br />
SET(CPACK_GENERATOR "STGZ;TGZ;TZ")<br />
SET(CPACK_INSTALL_CMAKE_PROJECTS "/home/andy/vtk/CMake-bin;CMake;ALL;/")<br />
SET(CPACK_NSIS_DISPLAY_NAME "CMake 2.5")<br />
SET(CPACK_OUTPUT_CONFIG_FILE "/home/andy/vtk/CMake-bin/CPackConfig.cmake")<br />
SET(CPACK_PACKAGE_DESCRIPTION_FILE "/home/andy/vtk/CMake/Copyright.txt")<br />
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "CMake is a build tool")<br />
SET(CPACK_PACKAGE_EXECUTABLES "ccmake;CMake")<br />
SET(CPACK_PACKAGE_FILE_NAME "cmake-2.5.0-Linux-i686")<br />
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake 2.5")<br />
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "CMake 2.5.0")<br />
SET(CPACK_PACKAGE_NAME "CMake")<br />
SET(CPACK_PACKAGE_VENDOR "Kitware")<br />
SET(CPACK_PACKAGE_VERSION "2.5.0")<br />
SET(CPACK_PACKAGE_VERSION_MAJOR "2")<br />
SET(CPACK_PACKAGE_VERSION_MINOR "5")<br />
SET(CPACK_PACKAGE_VERSION_PATCH "0")<br />
SET(CPACK_RESOURCE_FILE_LICENSE "/home/andy/vtk/CMake/Copyright.txt")<br />
SET(CPACK_RESOURCE_FILE_README "/home/andy/vtk/CMake/Templates/CPack.GenericDescription.txt")<br />
SET(CPACK_RESOURCE_FILE_WELCOME "/home/andy/vtk/CMake/Templates/CPack.GenericWelcome.txt")<br />
SET(CPACK_SOURCE_GENERATOR "TGZ;TZ")<br />
SET(CPACK_SOURCE_OUTPUT_CONFIG_FILE "/home/andy/vtk/CMake-bin/CPackSourceConfig.cmake")<br />
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "cmake-2.5.0")<br />
SET(CPACK_SOURCE_STRIP_FILES "")<br />
SET(CPACK_STRIP_FILES "bin/ccmake;bin/cmake;bin/cpack;bin/ctest")<br />
SET(CPACK_SYSTEM_NAME "Linux-i686")<br />
SET(CPACK_TOPLEVEL_TAG "Linux-i686")</nowiki></pre><br />
<br />
These variables can also be overwritten on the command line using the option "-D":<br />
<br />
cpack -D CPACK_PACKAGE_VENDOR=Me -D CPACK_SYSTEM_NAME=super-duper-linux ...<br />
<br />
<br />
=Using CPack with CMake=<br />
<br />
CMake comes with a CPack module, which will automatically generate an appropriate CPack configuration file. To use the module, simply invoke the following command (BTW, failure to do so will result in an annoying "CPack Error: CPack project name not specified" message...):<br />
<br />
<pre><nowiki>INCLUDE(CPack)</nowiki></pre><br />
<br />
This generates a new target called ''"package"'' in your build system. When this target is built, CPack will be invoked to generate all of the packages. Internally, CPack will use [[CMake:Install_Commands | CMake's install mechanism]] to automatically populate the package.<br />
<br />
An example output of the ''"package"'' target (from a Linux Makefile) is:<br />
<br />
<pre><nowiki>Run CPack packaging tool...<br />
CPack: Create package using STGZ<br />
CPack: Install projects<br />
CPack: - Run preinstall target for: CMake<br />
CPack: - Install project: CMake<br />
CPack: - Strip files<br />
CPack: Compress package<br />
CPack: Finalize package<br />
CPack: Package /home/andy/CMake-bin/cmake-2.5.0-Linux-i686.sh generated.<br />
CPack: Create package using TGZ<br />
CPack: Install projects<br />
CPack: - Run preinstall target for: CMake<br />
CPack: - Install project: CMake<br />
CPack: - Strip files<br />
CPack: Compress package<br />
CPack: Finalize package<br />
CPack: Package /home/andy/CMake-bin/cmake-2.5.0-Linux-i686.tar.gz generated.<br />
CPack: Create package using TZ<br />
CPack: Install projects<br />
CPack: - Run preinstall target for: CMake<br />
CPack: - Install project: CMake<br />
CPack: - Strip files<br />
CPack: Compress package<br />
CPack: Finalize package<br />
CPack: Package /home/andy/CMake-bin/cmake-2.5.0-Linux-i686.tar.Z generated.</nowiki></pre><br />
<br />
<br />
==Using CMake variables to configure CPack==<br />
<br />
To configure CPack, it is possible to define [[CMake:CPackConfiguration| CPack variables]] inside a CMake file. These variables will be copied across to the generated CPackConfig.cmake file before CPack is invoked.<br />
<br />
This is an example CMake list section for CPack configuration:<br />
<br />
<pre><nowiki><br />
INCLUDE(InstallRequiredSystemLibraries)<br />
<br />
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "My funky project")<br />
SET(CPACK_PACKAGE_VENDOR "Me, myself, and I")<br />
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt")<br />
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")<br />
SET(CPACK_PACKAGE_VERSION_MAJOR "1")<br />
SET(CPACK_PACKAGE_VERSION_MINOR "3")<br />
SET(CPACK_PACKAGE_VERSION_PATCH "2")<br />
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")<br />
IF(WIN32 AND NOT UNIX)<br />
# There is a bug in NSI that does not handle full unix paths properly. Make<br />
# sure there is at least one set of four (4) backlasshes.<br />
SET(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")<br />
SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")<br />
SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} My Famous Project")<br />
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.my-project-home-page.org")<br />
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.my-personal-home-page.com")<br />
SET(CPACK_NSIS_CONTACT "me@my-personal-home-page.com")<br />
SET(CPACK_NSIS_MODIFY_PATH ON)<br />
ELSE(WIN32 AND NOT UNIX)<br />
SET(CPACK_STRIP_FILES "bin/MyExecutable")<br />
SET(CPACK_SOURCE_STRIP_FILES "")<br />
ENDIF(WIN32 AND NOT UNIX)<br />
SET(CPACK_PACKAGE_EXECUTABLES "MyExecutable" "My Executable")<br />
INCLUDE(CPack)</nowiki></pre><br />
<br />
== CPack Generators ==<br />
There are several [[CMake:CPackPackageGenerators|generators]] usable with CPack.<br />
<br />
{{CMake/Template/Footer}}</div>Paulfitzhttps://public.kitware.com/Wiki/index.php?title=Really_Cool_CMake_Features&diff=30551Really Cool CMake Features2010-09-20T13:08:08Z<p>Paulfitz: undo spam link from 3qdesigns123</p>
<hr />
<div>CMake is a mature tool with many features, both big and small. Many go unnoticed or are taken for granted. Help us create a comprehensive list of features that make CMake really cool. Please list your addition under the appropriate package: CMake, CTest, or CPack.<br />
<br />
== CMake Features ==<br />
<br />
<br />
* Color output for make<br />
* Progress output for make<br />
* Incremental linking support with vs 8,9 and manifests<br />
* Supports out-of-tree builds<br />
* Auto-rerun of cmake if any cmake input files change (works with vs 8, 9 using ide macros)<br />
* Auto depend information for C++, C, and Fortran<br />
** [http://graphviz.org/ Graphviz] output for visualizing dependency trees<br />
* Full support for library versions <br />
* Full cross platform install system<br />
* Generate project files for major IDEs: Visual Studio, Xcode, Eclipse, KDevelop<br />
** not tied to make, other portable generators like ant possible<br />
* Ability to add custom rules and targets<br />
* Compute link depend information, and chaining of dependent libraries<br />
* Works with parallel make and is fast, can build very large projects like KDE on build farms<br />
* make help, make foo.s, make foo.E, VERBOSE=1 make PROJECT/fast<br />
* Advanced RPATH handling, full support for all kinds of static/shared libs and plugins, no more cryptic foo.la libtool "libraries"<br />
* support for chrpath, i.e. changing the RPATH without need to actually link again<br />
* Works on many host operating systems (a full list would be good)<br />
* Supports many toolchains: GNU, MS, Borland, Sun, also e.g sdcc<br />
* Beta cross compiling, to Linux, Windows, eCos, supercomputers, no OS, from 8bit uCs to 64bit CPUs<br />
* Full dependencies: build a target in some directory, and everything this target depends on will be up to date<br />
* Extensive test suite and nightly builds/test on many platforms<br />
* modular design (e.g. the Find modules, language, toolchain and OS support files) * > easily extendable<br />
* just one tool instead of automake+autoconf+libtool+m4+shell+make<br />
* Good scripting language that supports:<br />
** control structures (conditional, iterative)<br />
** regular expressions, eliminating need for grep+awk+sed+perl<br />
** macros (similar to functions, with counted or vararg parameters)<br />
** portable commands for file and directory manipulation<br />
* Extensive auxiliary cmake modules for finding and simplifying use of popular libraries (boost, sdl, fltk, etc.) and utilities (swig, etc). <br />
* Comes with a GUI layer for easy edition of input variables, both Curses and QT based options.<br />
* Command line support<br />
* it's a native tool, windows devs don't have to deal with POSIX shells, OSX devs can continue to use XCode<br />
* .tar.gz archiving available on all platforms: no need to chase down tar/gzip for Windows<br />
* can create OSX library frameworks<br />
* can create OSX application bundles<br />
* scales well for really, really big projects like KDE<br />
<br />
== CTest Features ==<br />
* Run all or sub-sets of tests for a project<br />
* Submit testing results to Dart 1,2 and CDash<br />
* Run tests that build and run --build-and-test command<br />
* support coverage with gcc, and bullseye coverage tools<br />
* support memory checking with valgrind, purify, and bounds checker<br />
<br />
== CPack Features ==<br />
* Simple Declarative creation of packages/installers using CMake+CPack<br />
* Create Source or Binary packages<br />
* A wealth of supported formats:<br />
** Create professional windows installers with [http://nsis.sourceforge.net/Main_Page NSIS]<br />
** Create tar.gz tar.Z on any platform<br />
** Create self extracting tar.gz .sh files<br />
** Create rpm <br />
** Create Debian .deb files<br />
** Create Cygwin setup packages</div>Paulfitz