← Back to team overview

kicad-developers team mailing list archive

CPack integration for crossplatform creation of binary and source archives -- patch


Dear all,

As I was trying to find a neat way to create mac packages on the fly I bumped to CPack. This application is shipped with CMake and can be used inside the existing CMakeLists.txt configuration. For mac I enabled for now only DragNDrop packages which are like zip archives instead of full-fledged PackageMaker installers. The most neat thing is it creates the archives by itself without using any external script or utility. Then the packaging/mac-osx/dmg-generator directory can be removed from the source-tree if this patch is applied.

If you look deeper at CPack or CMake CPack module it also integrates generation of NSIS installer for windows and self-extracting shell script for *NIX. This takes us a whole bunch of work from our hands if other people want to do snapshots/nightly builds or actual releasing the software.

A console output on my mac when creating source archives (make sure you do a out of source build or else all the CMake cache stuff will also be in the source archive!)

white:darwin jerry$ sudo make package_source
Run CPack packaging tool for source...
CPack: Create package using TGZ
CPack: Install projects
CPack: - Install directory: /Users/jerry/Work/kicad/repository
CPack: Compress package
CPack: Finalize package
CPack: Package /Users/jerry/Work/kicad/build/darwin/kicad-2010.07.23-Source.tar.gz generated.

When creating binary package(s) which can be selected with the CPACK_GENERATOR variable they can be build with the *make package* command.

For more information see cmake --help-module CPack

I attached the main CMakeLists.txt patch. Only maybe other people have
a suggestion to extract the date from BZR or system when building instead of changing the 3 variables BUILD_ YEAR, MONTH, DAY.

Kind regards,
Jerry Jacobs

=== modified file 'CMakeLists.txt'
--- CMakeLists.txt	2010-06-13 04:10:16 +0000
+++ CMakeLists.txt	2010-07-23 16:45:09 +0000
@@ -1,5 +1,11 @@
+# Set build date for automated builds and packages
+# This needs to be done in a automatic way some day
+set(BUILD_YEAR  2010)
+set(BUILD_MONTH 07)
+set(BUILD_DAY   23)
 # test the minimum Cmake version requirement (could be different under unix or Windows
     cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR)
@@ -263,4 +269,32 @@
             PATTERN ".svn" EXCLUDE)
+# Package binarie and source builds with CPack
+#  for help about this variables see cmake --help-module CPack
+# Set package resource files
+# Exclude files when building the Source package
+set(CPACK_SOURCE_IGNORE_FILES "/.bzr/;/.swp/")
+# Set package version
+# Set APPLE configuration for CPack usage
+# Load the CPack module for CMake
+# Load the CTest module for CMake

Follow ups