[Cmake-commits] CMake branch, master, updated. v3.14.0-433-g8c0b7aa

Kitware Robot kwrobot at kitware.com
Tue Mar 19 13:43:07 EDT 2019


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, master has been updated
       via  8c0b7aa17dcbe24b38453843544bc61a25e1a851 (commit)
       via  f1e53266e9ce7e8a9568bde23f865136be958887 (commit)
       via  8634576dcb03087fc507b8012a47f1ecc852f65f (commit)
       via  c7c6a4a2cc06fd22eeb1c545dba030eddf39363a (commit)
       via  7c47fd8cd1e7d9aae60412ce7544fdfa82c9e798 (commit)
       via  73f23d1e0087a3b025ab7ba6b3e6195f19b40e1b (commit)
      from  d2101e944a03056dc2180dd790ba85175e04d653 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8c0b7aa17dcbe24b38453843544bc61a25e1a851
commit 8c0b7aa17dcbe24b38453843544bc61a25e1a851
Merge: f1e5326 73f23d1
Author:     Kyle Edwards <kyle.edwards at kitware.com>
AuthorDate: Tue Mar 19 17:39:06 2019 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Mar 19 13:39:18 2019 -0400

    Merge topic 'cmake--install'
    
    73f23d1e00 cmake: add '--install <dir>' option
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Acked-by: Alex Turbov <i.zaufi at gmail.com>
    Acked-by: Bartosz <gang65 at poczta.onet.pl>
    Acked-by: Cristian Adam <cristian.adam at gmail.com>
    Rejected-by: Alex Turbov <i.zaufi at gmail.com>
    Merge-request: !3069


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f1e53266e9ce7e8a9568bde23f865136be958887
commit f1e53266e9ce7e8a9568bde23f865136be958887
Merge: d2101e9 8634576
Author:     Kyle Edwards <kyle.edwards at kitware.com>
AuthorDate: Tue Mar 19 17:37:48 2019 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Mar 19 13:37:59 2019 -0400

    Merge topic 'improve-tar-command'
    
    8634576dcb cmake: Don't interrupt archive creation if unable to read a file.
    c7c6a4a2cc Help: Update 'tar' documentation with supported arguments
    7c47fd8cd1 cmake: tar: Display warning when no files provided during archive creation
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !3080


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8634576dcb03087fc507b8012a47f1ecc852f65f
commit 8634576dcb03087fc507b8012a47f1ecc852f65f
Author:     Bartosz Kosiorek <bartosz.kosiorek at tomtom.com>
AuthorDate: Fri Mar 8 14:53:35 2019 +0100
Commit:     Bartosz Kosiorek <bartosz.kosiorek at tomtom.com>
CommitDate: Mon Mar 18 17:55:35 2019 +0100

    cmake: Don't interrupt archive creation if unable to read a file.
    
    Rationale:
    Currently during creation of archive by 'tar',
    if error appears, it interrupt archive creation.
    As a result only part of files are archived
    
    This behaviour is not consistent with 'copy_directory', native 'tar'
    and other command behaviour.
    With this Merge Request this behaviour is fixed.

diff --git a/Help/release/dev/cmake-e-tar-creating-archive.rst b/Help/release/dev/cmake-e-tar-creating-archive.rst
new file mode 100644
index 0000000..717855c
--- /dev/null
+++ b/Help/release/dev/cmake-e-tar-creating-archive.rst
@@ -0,0 +1,6 @@
+cmake-e-tar-creating-archive
+----------------------------
+
+* The :manual:`cmake(1)` ``-E tar`` tool now continues adding files to an
+  archive, even if some of the files aren't readable. This behavior is more
+  consistent with the classic ``tar`` tool.
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx
index 23be603..177ba02 100644
--- a/Source/cmArchiveWrite.cxx
+++ b/Source/cmArchiveWrite.cxx
@@ -179,12 +179,10 @@ cmArchiveWrite::~cmArchiveWrite()
 bool cmArchiveWrite::Add(std::string path, size_t skip, const char* prefix,
                          bool recursive)
 {
-  if (this->Okay()) {
-    if (!path.empty() && path.back() == '/') {
-      path.erase(path.size() - 1);
-    }
-    this->AddPath(path.c_str(), skip, prefix, recursive);
+  if (!path.empty() && path.back() == '/') {
+    path.erase(path.size() - 1);
   }
+  this->AddPath(path.c_str(), skip, prefix, recursive);
   return this->Okay();
 }
 
@@ -220,6 +218,7 @@ bool cmArchiveWrite::AddPath(const char* path, size_t skip, const char* prefix,
 
 bool cmArchiveWrite::AddFile(const char* file, size_t skip, const char* prefix)
 {
+  this->Error = "";
   // Skip the file if we have no name for it.  This may happen on a
   // top-level directory, which does not need to be included anyway.
   if (skip >= strlen(file)) {
@@ -241,7 +240,7 @@ bool cmArchiveWrite::AddFile(const char* file, size_t skip, const char* prefix)
   cm_archive_entry_copy_pathname(e, dest);
   if (archive_read_disk_entry_from_file(this->Disk, e, -1, nullptr) !=
       ARCHIVE_OK) {
-    this->Error = "archive_read_disk_entry_from_file '";
+    this->Error = "Unable to read from file '";
     this->Error += file;
     this->Error += "': ";
     this->Error += cm_archive_error_string(this->Disk);
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index d762106..41f8cf4 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1658,20 +1658,18 @@ bool cmSystemTools::CreateTar(const char* outFileName,
 
   a.SetMTime(mtime);
   a.SetVerbose(verbose);
+  bool tarCreatedSuccessfully = true;
   for (auto path : files) {
     if (cmSystemTools::FileIsFullPath(path)) {
       // Get the relative path to the file.
       path = cmSystemTools::RelativePath(cwd, path);
     }
     if (!a.Add(path)) {
-      break;
+      cmSystemTools::Error(a.GetError());
+      tarCreatedSuccessfully = false;
     }
   }
-  if (!a) {
-    cmSystemTools::Error(a.GetError());
-    return false;
-  }
-  return true;
+  return tarCreatedSuccessfully;
 #else
   (void)outFileName;
   (void)files;
diff --git a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
index 24bb9a9..c8a3de9 100644
--- a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
@@ -12,12 +12,13 @@ external_command_test(bad-from2  tar cvf bad.tar --files-from=.)
 external_command_test(bad-from3  tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from3.txt)
 external_command_test(bad-from4  tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from4.txt)
 external_command_test(bad-from5  tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from5.txt)
+external_command_test(bad-file   tar cf  bad.tar badfile.txt ${CMAKE_CURRENT_LIST_DIR}/test-file.txt)
 external_command_test(end-opt1   tar cvf bad.tar -- --bad)
 external_command_test(end-opt2   tar cvf bad.tar --)
-external_command_test(mtime      tar cvf bad.tar "--mtime=1970-01-01 00:00:00 UTC" .)
-external_command_test(bad-format tar cvf bad.tar "--format=bad-format" .)
-external_command_test(zip-bz2    tar cvjf bad.tar "--format=zip" .)
-external_command_test(7zip-gz    tar cvzf bad.tar "--format=7zip" .)
+external_command_test(mtime      tar cvf bad.tar "--mtime=1970-01-01 00:00:00 UTC" ${CMAKE_CURRENT_LIST_DIR}/test-file.txt)
+external_command_test(bad-format tar cvf bad.tar "--format=bad-format" ${CMAKE_CURRENT_LIST_DIR}/test-file.txt)
+external_command_test(zip-bz2    tar cvjf bad.tar "--format=zip" ${CMAKE_CURRENT_LIST_DIR}/test-file.txt)
+external_command_test(7zip-gz    tar cvzf bad.tar "--format=7zip" ${CMAKE_CURRENT_LIST_DIR}/test-file.txt)
 
 run_cmake(7zip)
 run_cmake(gnutar)
diff --git a/Tests/RunCMake/CommandLineTar/bad-file-result.txt b/Tests/RunCMake/CommandLineTar/bad-file-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/bad-file-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLineTar/bad-file-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-file-stderr.txt
new file mode 100644
index 0000000..1f9f748
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/bad-file-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error: Unable to read from file 'badfile.txt': .*
+CMake Error: Problem creating tar: bad.tar$
diff --git a/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt
index 1417d4d..fb0702a 100644
--- a/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt
@@ -1,2 +1,2 @@
-^CMake Error: archive_read_disk_entry_from_file 'does-not-exist':.*
+^CMake Error: Unable to read from file 'does-not-exist':.*
 CMake Error: Problem creating tar: bad.tar$
diff --git a/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt
index 1417d4d..fb0702a 100644
--- a/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt
@@ -1,2 +1,2 @@
-^CMake Error: archive_read_disk_entry_from_file 'does-not-exist':.*
+^CMake Error: Unable to read from file 'does-not-exist':.*
 CMake Error: Problem creating tar: bad.tar$
diff --git a/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt b/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt
index 1fddf6d..1342dc8 100644
--- a/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt
+++ b/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt
@@ -1,2 +1,2 @@
-^CMake Error: archive_read_disk_entry_from_file '--bad':.*
+^CMake Error: Unable to read from file '--bad':.*
 CMake Error: Problem creating tar: bad.tar$
diff --git a/Tests/RunCMake/CommandLineTar/test-file.txt b/Tests/RunCMake/CommandLineTar/test-file.txt
new file mode 100644
index 0000000..e69de29

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c7c6a4a2cc06fd22eeb1c545dba030eddf39363a
commit c7c6a4a2cc06fd22eeb1c545dba030eddf39363a
Author:     Bartosz Kosiorek <bartosz.kosiorek at tomtom.com>
AuthorDate: Fri Mar 8 14:52:30 2019 +0100
Commit:     Bartosz Kosiorek <bartosz.kosiorek at tomtom.com>
CommitDate: Mon Mar 18 17:08:20 2019 +0100

    Help: Update 'tar' documentation with supported arguments

diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index a3c7834..db035c2 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -483,6 +483,21 @@ Available commands are:
 ``tar [cxt][vf][zjJ] file.tar [<options>] [--] [<file>...]``
   Create or extract a tar or zip archive.  Options are:
 
+  ``c``
+    Create a new archive containing the specified files.
+    If used, the <file> argument is mandatory.
+  ``x``
+    Extract to disk from the archive.
+  ``t``
+    List archive contents to stdout.
+  ``v``
+    Produce verbose output.
+  ``z``
+    Compress the resulting archive with gzip.
+  ``j``
+    Compress the resulting archive with bzip2.
+  ``J``
+    Compress the resulting archive with XZ.
   ``--``
     Stop interpreting options and treat all remaining arguments
     as file names even if they start in ``-``.

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7c47fd8cd1e7d9aae60412ce7544fdfa82c9e798
commit 7c47fd8cd1e7d9aae60412ce7544fdfa82c9e798
Author:     Bartosz Kosiorek <bartosz.kosiorek at tomtom.com>
AuthorDate: Fri Mar 8 17:04:17 2019 +0100
Commit:     Bartosz Kosiorek <bartosz.kosiorek at tomtom.com>
CommitDate: Mon Mar 18 17:08:20 2019 +0100

    cmake: tar: Display warning when no files provided during archive creation

diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index f996a3e..0828a16 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -1114,6 +1114,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
           return 1;
         }
       } else if (flags.find_first_of('c') != std::string::npos) {
+        if (files.empty()) {
+          cmSystemTools::Message("tar: No files or directories specified",
+                                 "Warning");
+        }
         if (!cmSystemTools::CreateTar(outFile.c_str(), files, compress,
                                       verbose, mtime, format)) {
           cmSystemTools::Error("Problem creating tar: " + outFile);
diff --git a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
index 12635db..24bb9a9 100644
--- a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
@@ -4,6 +4,7 @@ function(external_command_test NAME)
   run_cmake_command(${NAME} ${CMAKE_COMMAND} -E ${ARGN})
 endfunction()
 
+external_command_test(without-files tar cvf bad.tar)
 external_command_test(bad-opt1   tar cvf bad.tar --bad)
 external_command_test(bad-mtime1 tar cvf bad.tar --mtime=bad .)
 external_command_test(bad-from1  tar cvf bad.tar --files-from=bad)
@@ -13,10 +14,10 @@ external_command_test(bad-from4  tar cvf bad.tar --files-from=${CMAKE_CURRENT_LI
 external_command_test(bad-from5  tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from5.txt)
 external_command_test(end-opt1   tar cvf bad.tar -- --bad)
 external_command_test(end-opt2   tar cvf bad.tar --)
-external_command_test(mtime      tar cvf bad.tar "--mtime=1970-01-01 00:00:00 UTC")
-external_command_test(bad-format tar cvf bad.tar "--format=bad-format")
-external_command_test(zip-bz2    tar cvjf bad.tar "--format=zip")
-external_command_test(7zip-gz    tar cvzf bad.tar "--format=7zip")
+external_command_test(mtime      tar cvf bad.tar "--mtime=1970-01-01 00:00:00 UTC" .)
+external_command_test(bad-format tar cvf bad.tar "--format=bad-format" .)
+external_command_test(zip-bz2    tar cvjf bad.tar "--format=zip" .)
+external_command_test(7zip-gz    tar cvzf bad.tar "--format=7zip" .)
 
 run_cmake(7zip)
 run_cmake(gnutar)
diff --git a/Tests/RunCMake/CommandLineTar/end-opt2-stderr.txt b/Tests/RunCMake/CommandLineTar/end-opt2-stderr.txt
new file mode 100644
index 0000000..70166f5
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/end-opt2-stderr.txt
@@ -0,0 +1 @@
+^tar: No files or directories specified
diff --git a/Tests/RunCMake/CommandLineTar/without-files-stderr.txt b/Tests/RunCMake/CommandLineTar/without-files-stderr.txt
new file mode 100644
index 0000000..70166f5
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/without-files-stderr.txt
@@ -0,0 +1 @@
+^tar: No files or directories specified

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=73f23d1e0087a3b025ab7ba6b3e6195f19b40e1b
commit 73f23d1e0087a3b025ab7ba6b3e6195f19b40e1b
Author:     Jiang Yi <jiangyilism at gmail.com>
AuthorDate: Wed Mar 6 20:49:51 2019 +0800
Commit:     Jiang Yi <jiangyilism at gmail.com>
CommitDate: Sun Mar 17 01:31:25 2019 +0800

    cmake: add '--install <dir>' option
    
    Fixes: #19023

diff --git a/Auxiliary/bash-completion/cmake b/Auxiliary/bash-completion/cmake
index 5d67b0b..8c0c5e8 100644
--- a/Auxiliary/bash-completion/cmake
+++ b/Auxiliary/bash-completion/cmake
@@ -96,7 +96,7 @@ _cmake()
             _filedir
             return
             ;;
-        --build|--open)
+        --build|--install|--open)
             _filedir -d
             return
             ;;
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index e9a08b5..3ea6bc4 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -16,6 +16,9 @@ Synopsis
  `Build a Project`_
   cmake --build <dir> [<options>] [-- <build-tool-options>]
 
+ `Install a Project`_
+  cmake --install <dir> [<options>]
+
  `Open a Project`_
   cmake --open <dir>
 
@@ -39,8 +42,8 @@ buildsystem generator CMake.  The above `Synopsis`_ lists various actions
 the tool can perform as described in sections below.
 
 To build a software project with CMake, `Generate a Project Buildsystem`_.
-Optionally use **cmake** to `Build a Project`_ or just run the
-corresponding build tool (e.g. ``make``) directly.  **cmake** can also
+Optionally use **cmake** to `Build a Project`_, `Install a Project`_ or just
+run the corresponding build tool (e.g. ``make``) directly.  **cmake** can also
 be used to `View Help`_.
 
 The other actions are meant for use by software developers writing
@@ -302,6 +305,41 @@ following options:
 
 Run ``cmake --build`` with no options for quick help.
 
+Install a Project
+=================
+
+CMake provides a command-line signature to install an already-generated
+project binary tree:
+
+.. code-block:: shell
+
+  cmake --install <dir> [<options>]
+
+This may be used after building a project to run installation without
+using the generated build system or the native build tool.
+The options are:
+
+``--install <dir>``
+  Project binary directory to install. This is required and must be first.
+
+``--config <cfg>``
+  For multi-configuration tools, choose configuration ``<cfg>``.
+
+``--component <comp>``
+  Component-based install. Only install component ``<comp>``.
+
+``--prefix <prefix>``
+  The installation prefix CMAKE_INSTALL_PREFIX.
+
+``--strip``
+  Strip before installing by setting CMAKE_INSTALL_DO_STRIP.
+
+``-v, --verbose``
+  Enable verbose output.
+
+  This option can be omitted if :envvar:`VERBOSE` environment variable is set.
+
+Run ``cmake --install`` with no options for quick help.
 
 Open a Project
 ==============
diff --git a/Help/release/dev/cmake--install_option.rst b/Help/release/dev/cmake--install_option.rst
new file mode 100644
index 0000000..8e526a0
--- /dev/null
+++ b/Help/release/dev/cmake--install_option.rst
@@ -0,0 +1,6 @@
+cmake--install-option
+---------------------
+
+* A new ``--install`` option was added to :manual:`cmake(1)`.
+  This may be used after building a project to run installation without
+  using the generated build system or the native build tool.
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 1c56bcd..d36ddf1 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -23,6 +23,7 @@
 #  include "cmsys/ConsoleBuf.hxx"
 #endif
 
+#include <cassert>
 #include <ctype.h>
 #include <iostream>
 #include <string.h>
@@ -71,11 +72,20 @@ static const char* cmDocumentationUsageNote[][2] = {
     "                   the build commands to be executed. \n"                \
     "  --             = Pass remaining options to the native tool.\n"
 
+#  define CMAKE_INSTALL_OPTIONS                                               \
+    "  <dir>              = Project binary directory to install.\n"           \
+    "  --config <cfg>     = For multi-configuration tools, choose <cfg>.\n"   \
+    "  --component <comp> = Component-based install. Only install <comp>.\n"  \
+    "  --prefix <prefix>  = The installation prefix CMAKE_INSTALL_PREFIX.\n"  \
+    "  --strip            = Performing install/strip.\n"                      \
+    "  -v --verbose       = Enable verbose output.\n"
+
 static const char* cmDocumentationOptions[][2] = {
   CMAKE_STANDARD_OPTIONS_TABLE,
   { "-E", "CMake command mode." },
   { "-L[A][H]", "List non-advanced cached variables." },
   { "--build <dir>", "Build a CMake-generated project binary tree." },
+  { "--install <dir>", "Install a CMake-generated project binary tree." },
   { "--open <dir>", "Open generated project in the associated application." },
   { "-N", "View mode only." },
   { "-P <file>", "Process script mode." },
@@ -114,6 +124,7 @@ static int do_command(int ac, char const* const* av)
 
 int do_cmake(int ac, char const* const* av);
 static int do_build(int ac, char const* const* av);
+static int do_install(int ac, char const* const* av);
 static int do_open(int ac, char const* const* av);
 
 static cmMakefile* cmakemainGetMakefile(cmake* cm)
@@ -188,6 +199,9 @@ int main(int ac, char const* const* av)
     if (strcmp(av[1], "--build") == 0) {
       return do_build(ac, av);
     }
+    if (strcmp(av[1], "--install") == 0) {
+      return do_install(ac, av);
+    }
     if (strcmp(av[1], "--open") == 0) {
       return do_open(ac, av);
     }
@@ -523,6 +537,117 @@ static int do_build(int ac, char const* const* av)
 #endif
 }
 
+static int do_install(int ac, char const* const* av)
+{
+#ifndef CMAKE_BUILD_WITH_CMAKE
+  std::cerr << "This cmake does not support --install\n";
+  return -1;
+#else
+  assert(1 < ac);
+
+  std::string config;
+  std::string component;
+  std::string prefix;
+  std::string dir;
+  bool strip = false;
+  bool verbose = cmSystemTools::HasEnv("VERBOSE");
+
+  enum Doing
+  {
+    DoingNone,
+    DoingDir,
+    DoingConfig,
+    DoingComponent,
+    DoingPrefix,
+  };
+
+  Doing doing = DoingDir;
+
+  for (int i = 2; i < ac; ++i) {
+    if (strcmp(av[i], "--config") == 0) {
+      doing = DoingConfig;
+    } else if (strcmp(av[i], "--component") == 0) {
+      doing = DoingComponent;
+    } else if (strcmp(av[i], "--prefix") == 0) {
+      doing = DoingPrefix;
+    } else if (strcmp(av[i], "--strip") == 0) {
+      strip = true;
+      doing = DoingNone;
+    } else if ((strcmp(av[i], "--verbose") == 0) ||
+               (strcmp(av[i], "-v") == 0)) {
+      verbose = true;
+      doing = DoingNone;
+    } else {
+      switch (doing) {
+        case DoingDir:
+          dir = cmSystemTools::CollapseFullPath(av[i]);
+          doing = DoingNone;
+          break;
+        case DoingConfig:
+          config = av[i];
+          doing = DoingNone;
+          break;
+        case DoingComponent:
+          component = av[i];
+          doing = DoingNone;
+          break;
+        case DoingPrefix:
+          prefix = av[i];
+          doing = DoingNone;
+          break;
+        default:
+          std::cerr << "Unknown argument " << av[i] << std::endl;
+          dir.clear();
+          break;
+      }
+    }
+  }
+
+  if (dir.empty()) {
+    std::cerr << "Usage: cmake --install <dir> "
+                 "[options]\nOptions:\n" CMAKE_INSTALL_OPTIONS;
+    return 1;
+  }
+
+  cmake cm(cmake::RoleScript, cmState::Script);
+
+  cmSystemTools::SetMessageCallback(
+    [&cm](const std::string& msg, const char* title) {
+      cmakemainMessageCallback(msg, title, &cm);
+    });
+  cm.SetProgressCallback([&cm](const std::string& msg, float prog) {
+    cmakemainProgressCallback(msg, prog, &cm);
+  });
+  cm.SetHomeDirectory("");
+  cm.SetHomeOutputDirectory("");
+  cm.SetDebugOutputOn(verbose);
+  cm.SetWorkingMode(cmake::SCRIPT_MODE);
+
+  std::vector<std::string> args{ av[0] };
+
+  if (!prefix.empty()) {
+    args.emplace_back("-DCMAKE_INSTALL_PREFIX=" + prefix);
+  }
+
+  if (!component.empty()) {
+    args.emplace_back("-DCMAKE_INSTALL_COMPONENT=" + component);
+  }
+
+  if (strip) {
+    args.emplace_back("-DCMAKE_INSTALL_DO_STRIP=1");
+  }
+
+  if (!config.empty()) {
+    args.emplace_back("-DCMAKE_INSTALL_CONFIG_NAME=" + config);
+  }
+
+  args.emplace_back("-P");
+  args.emplace_back(dir + "/cmake_install.cmake");
+
+  return cm.Run(args) ? 1 : 0;
+#endif
+}
+
 static int do_open(int ac, char const* const* av)
 {
 #ifndef CMAKE_BUILD_WITH_CMAKE
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index ff2a8a5..066e9b8 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -54,6 +54,14 @@ run_cmake_command(build-bad-dir
 run_cmake_command(build-bad-generator
   ${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-bad-generator)
 
+run_cmake_command(install-no-dir
+  ${CMAKE_COMMAND} --install)
+run_cmake_command(install-bad-dir
+  ${CMAKE_COMMAND} --install dir-does-not-exist)
+run_cmake_command(install-options-to-vars
+  ${CMAKE_COMMAND} --install ${RunCMake_SOURCE_DIR}/dir-install-options-to-vars
+  --strip --prefix /var/test --config sample --component pack)
+
 run_cmake_command(cache-bad-entry
   ${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-bad-entry/)
 run_cmake_command(cache-empty-entry
diff --git a/Tests/RunCMake/CommandLine/dir-install-options-to-vars/cmake_install.cmake b/Tests/RunCMake/CommandLine/dir-install-options-to-vars/cmake_install.cmake
new file mode 100644
index 0000000..fd4e67d
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/dir-install-options-to-vars/cmake_install.cmake
@@ -0,0 +1,15 @@
+if(CMAKE_INSTALL_PREFIX)
+  message("CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX}")
+endif()
+
+if(CMAKE_INSTALL_COMPONENT)
+  message("CMAKE_INSTALL_COMPONENT is ${CMAKE_INSTALL_COMPONENT}")
+endif()
+
+if(CMAKE_INSTALL_CONFIG_NAME)
+  message("CMAKE_INSTALL_CONFIG_NAME is ${CMAKE_INSTALL_CONFIG_NAME}")
+endif()
+
+if(CMAKE_INSTALL_DO_STRIP)
+  message("CMAKE_INSTALL_DO_STRIP is ${CMAKE_INSTALL_DO_STRIP}")
+endif()
diff --git a/Tests/RunCMake/CommandLine/install-bad-dir-result.txt b/Tests/RunCMake/CommandLine/install-bad-dir-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/install-bad-dir-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt b/Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt
new file mode 100644
index 0000000..320aecc
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: Error processing file:
diff --git a/Tests/RunCMake/CommandLine/install-no-dir-result.txt b/Tests/RunCMake/CommandLine/install-no-dir-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/install-no-dir-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/install-no-dir-stderr.txt b/Tests/RunCMake/CommandLine/install-no-dir-stderr.txt
new file mode 100644
index 0000000..d64f638
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/install-no-dir-stderr.txt
@@ -0,0 +1 @@
+^Usage: cmake --install <dir> \[options\]
diff --git a/Tests/RunCMake/CommandLine/install-options-to-vars-result.txt b/Tests/RunCMake/CommandLine/install-options-to-vars-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/install-options-to-vars-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/install-options-to-vars-stderr.txt b/Tests/RunCMake/CommandLine/install-options-to-vars-stderr.txt
new file mode 100644
index 0000000..f7b1583
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/install-options-to-vars-stderr.txt
@@ -0,0 +1,4 @@
+CMAKE_INSTALL_PREFIX is /var/test
+CMAKE_INSTALL_COMPONENT is pack
+CMAKE_INSTALL_CONFIG_NAME is sample
+CMAKE_INSTALL_DO_STRIP is 1

-----------------------------------------------------------------------

Summary of changes:
 Auxiliary/bash-completion/cmake                    |   2 +-
 Help/manual/cmake.1.rst                            |  57 +++++++++-
 Help/release/dev/cmake--install_option.rst         |   6 +
 Help/release/dev/cmake-e-tar-creating-archive.rst  |   6 +
 Source/cmArchiveWrite.cxx                          |  11 +-
 Source/cmSystemTools.cxx                           |  10 +-
 Source/cmakemain.cxx                               | 125 +++++++++++++++++++++
 Source/cmcmd.cxx                                   |   4 +
 Tests/RunCMake/CommandLine/RunCMakeTest.cmake      |   8 ++
 .../cmake_install.cmake                            |  15 +++
 .../install-bad-dir-result.txt}                    |   0
 .../CommandLine/install-bad-dir-stderr.txt         |   1 +
 .../install-no-dir-result.txt}                     |   0
 .../RunCMake/CommandLine/install-no-dir-stderr.txt |   1 +
 .../install-options-to-vars-result.txt}            |   0
 .../CommandLine/install-options-to-vars-stderr.txt |   4 +
 Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake   |  10 +-
 .../bad-file-result.txt}                           |   0
 Tests/RunCMake/CommandLineTar/bad-file-stderr.txt  |   2 +
 Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt |   2 +-
 Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt |   2 +-
 Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt  |   2 +-
 Tests/RunCMake/CommandLineTar/end-opt2-stderr.txt  |   1 +
 .../CommandLineTar/test-file.txt}                  |   0
 .../CommandLineTar/without-files-stderr.txt        |   1 +
 25 files changed, 248 insertions(+), 22 deletions(-)
 create mode 100644 Help/release/dev/cmake--install_option.rst
 create mode 100644 Help/release/dev/cmake-e-tar-creating-archive.rst
 create mode 100644 Tests/RunCMake/CommandLine/dir-install-options-to-vars/cmake_install.cmake
 copy Tests/RunCMake/{while/MissingArgument-result.txt => CommandLine/install-bad-dir-result.txt} (100%)
 create mode 100644 Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt
 copy Tests/RunCMake/{while/MissingArgument-result.txt => CommandLine/install-no-dir-result.txt} (100%)
 create mode 100644 Tests/RunCMake/CommandLine/install-no-dir-stderr.txt
 copy Tests/RunCMake/{target_link_options/LINK_OPTIONS-static-result.txt => CommandLine/install-options-to-vars-result.txt} (100%)
 create mode 100644 Tests/RunCMake/CommandLine/install-options-to-vars-stderr.txt
 copy Tests/RunCMake/{while/MissingArgument-result.txt => CommandLineTar/bad-file-result.txt} (100%)
 create mode 100644 Tests/RunCMake/CommandLineTar/bad-file-stderr.txt
 create mode 100644 Tests/RunCMake/CommandLineTar/end-opt2-stderr.txt
 copy Tests/{Wrapping/vtkIncluded.cxx => RunCMake/CommandLineTar/test-file.txt} (100%)
 create mode 100644 Tests/RunCMake/CommandLineTar/without-files-stderr.txt


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list