CMake: Added CPack support for generating packages.

The inclusion of CPack adds two new build targets:
  * `package` will generate a binary installer for the current platform.
    This includes everything installed via CMake's install command.
  * `package_source` will generate a source installer for the current
    platform.  This includes all the source files.

We also expose a variety of CPack configuration options to the user,
which are mostly disabled by default.  By default, the `package_source`
target will only generate a `.tar.gz` of the sources.  The `package`
target will not generate anything.

Review: https://reviews.apache.org/r/55657/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/3eccf7e6
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/3eccf7e6
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/3eccf7e6

Branch: refs/heads/master
Commit: 3eccf7e66ea4a76d869b6e726cfac7d91115976a
Parents: 86f32a4
Author: Srinivas Brahmaroutu <[email protected]>
Authored: Mon Feb 27 17:33:10 2017 -0800
Committer: Joseph Wu <[email protected]>
Committed: Tue Feb 28 14:33:45 2017 -0800

----------------------------------------------------------------------
 CMakeLists.txt              | 57 ++++++++++++++++++++++++++++++++++++++++
 docs/configuration-cmake.md | 21 +++++++++++++++
 2 files changed, 78 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/3eccf7e6/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3c3297c..8e492cf 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -79,3 +79,60 @@ add_custom_target(
   tests
   DEPENDS ${STOUT_TESTS_TARGET} ${PROCESS_TESTS_TARGET} ${MESOS_TESTS_TARGET}
   )
+
+# PACKAGING.
+############
+# List of sources we will ignore when generating a source package.
+# We assume there are no artifacts from an autotools build.
+#
+# NOTE: An in-source build is not supported. The build directory
+# must be different than the source directory.
+set(CPACK_SOURCE_IGNORE_FILES
+  .clang-format;
+  .gitignore;
+  .reviewboardrc;
+  bootstrap.bat;
+  bootstrap;
+  configure.ac;
+  Doxyfile;
+  mesos.pc.in;
+  /.git/;
+  /docs/;
+  /m4/;
+  /mpi/;
+  /site/;
+  /support/;
+  ${CMAKE_BINARY_DIR};
+  )
+
+# Convert the ignore list to a string (as required by CPack).
+set(CPACK_SOURCE_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}")
+
+# Set the basename of any packages to 'mesos-<version>'.
+set(CPACK_PACKAGE_FILE_NAME "mesos-${MESOS_PACKAGE_VERSION}")
+set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
+
+# By default, all forms of binary packages are disabled.
+option(CPACK_BINARY_BUNDLE       "Enable to build OSX bundles"              
OFF)
+option(CPACK_BINARY_DEB          "Enable to build Debian packages"          
OFF)
+option(CPACK_BINARY_DRAGNDROP    "Enable to build OSX Drag'n'Drop packages" 
OFF)
+option(CPACK_BINARY_IFW          "Enable to build IFW packages"             
OFF)
+option(CPACK_BINARY_NSIS         "Enable to build NSIS packages"            
OFF)
+option(CPACK_BINARY_OSXX11       "Enable to build OSX X11 packages"         
OFF)
+option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages"    
OFF)
+option(CPACK_BINARY_RPM          "Enable to build RPM packages"             
OFF)
+option(CPACK_BINARY_STGZ         "Enable to build STGZ packages"            
OFF)
+option(CPACK_BINARY_TBZ2         "Enable to build TBZ2 packages"            
OFF)
+option(CPACK_BINARY_TGZ          "Enable to build TGZ packages"             
OFF)
+option(CPACK_BINARY_TXZ          "Enable to build TXZ packages"             
OFF)
+
+# Output a gzip'd tarball for the `package_source` target.
+SET(CPACK_SOURCE_TGZ ON)
+
+# By default, other forms of source packages are disabled.
+option(CPACK_SOURCE_TBZ2 "Enable to build TBZ2 source packages" OFF)
+option(CPACK_SOURCE_TXZ  "Enable to build TXZ source packages"  OFF)
+option(CPACK_SOURCE_TZ   "Enable to build TZ source packages"   OFF)
+option(CPACK_SOURCE_ZIP  "Enable to build ZIP source packages"  OFF)
+
+INCLUDE(CPack)

http://git-wip-us.apache.org/repos/asf/mesos/blob/3eccf7e6/docs/configuration-cmake.md
----------------------------------------------------------------------
diff --git a/docs/configuration-cmake.md b/docs/configuration-cmake.md
index 4115e60..c7cb09a 100644
--- a/docs/configuration-cmake.md
+++ b/docs/configuration-cmake.md
@@ -42,6 +42,27 @@ the CMake build system.
   </tr>
   <tr>
     <td>
+      
-DCPACK_BINARY_(BUNDLE|DEB|DRAGNDROP|IFW|NSIS|OSXX11|PACKAGEMAKER|RPM|STGZ|TBZ2|TGZ|TXZ)
+    </td>
+    <td>
+      This modifies the 'package' target to generate binary package of
+      the specified format.  A binary package contains everything that
+      would be installed via CMake's 'install' target.
+      [default=OFF]
+    </td>
+  </tr>
+  <tr>
+    <td>
+      -DCPACK_SOURCE_(TBZ2|TXZ|TZ|ZIP)
+    </td>
+    <td>
+      This modifies the 'package_source' target to generate a package of the
+      sources required to build and test Mesos, in the specified format.
+      [default=OFF]
+    </td>
+  </tr>
+  <tr>
+    <td>
       -DENABLE_LIBEVENT
     </td>
     <td>

Reply via email to