[Cmake-commits] CMake branch, next, updated. v3.0.0-3865-gc0648b0
Brad King
brad.king at kitware.com
Mon Jun 23 16:48:12 EDT 2014
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, next has been updated
via c0648b0ca7a74d8ee2e6380ba510c7629f6ad8fe (commit)
via 7abd574798f9900abfe502f3941cffaa774062b1 (commit)
from cd57f1396212c086e59a9784b56b0b69f34be784 (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 -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c0648b0ca7a74d8ee2e6380ba510c7629f6ad8fe
commit c0648b0ca7a74d8ee2e6380ba510c7629f6ad8fe
Merge: cd57f13 7abd574
Author: Brad King <brad.king at kitware.com>
AuthorDate: Mon Jun 23 16:48:10 2014 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Jun 23 16:48:10 2014 -0400
Merge topic 'cmake-E-env' into next
7abd5747 cmake: Add '-E env' command-line tool
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7abd574798f9900abfe502f3941cffaa774062b1
commit 7abd574798f9900abfe502f3941cffaa774062b1
Author: Brad King <brad.king at kitware.com>
AuthorDate: Mon Jun 23 16:33:33 2014 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Jun 23 16:47:49 2014 -0400
cmake: Add '-E env' command-line tool
Extend the cmake command-line interface to support
cmake -E env [--unset=NAME]... [NAME=VALUE]... COMMAND [ARG]...
This will be useful to run processes with modified environments
without using a shell or a full "cmake -P" script to wrap it.
Extend the RunCMake.CommandLine test to cover success and failure cases.
Inspired-by: Jonathan Bohren <jbo at jhu.edu>
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index 5743ab7..8dfc16a 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -38,7 +38,7 @@ Options
For true platform independence, CMake provides a list of commands
that can be used on all systems. Run with -E help for the usage
information. Commands available are: chdir, compare_files, copy,
- copy_directory, copy_if_different, echo, echo_append, environment,
+ copy_directory, copy_if_different, echo, echo_append, env, environment,
make_directory, md5sum, remove, remove_directory, rename, sleep, tar, time,
touch, touch_nocreate. In addition, some platform specific commands
are available. On Windows: delete_regv, write_regv. On
diff --git a/Help/release/dev/cmake-E-env.rst b/Help/release/dev/cmake-E-env.rst
new file mode 100644
index 0000000..4bdcd0c
--- /dev/null
+++ b/Help/release/dev/cmake-E-env.rst
@@ -0,0 +1,4 @@
+cmake-E-env
+-----------
+
+* The :manual:`cmake(1)` ``-E`` option learned a new ``env`` command.
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 9aee975..a0c67e0 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -61,6 +61,8 @@ void CMakeCommandUsage(const char* program)
<< " echo [string]... - displays arguments as text\n"
<< " echo_append [string]... - displays arguments as text but no new "
"line\n"
+ << " env [--unset=NAME]... [NAME=VALUE]... COMMAND [ARG]...\n"
+ << " - run command in a modified environment\n"
<< " environment - display the current environment\n"
<< " make_directory dir - create a directory\n"
<< " md5sum file1 [...] - compute md5sum of files\n"
@@ -190,6 +192,55 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
return 0;
}
+ else if (args[1] == "env" )
+ {
+ std::vector<std::string>::const_iterator ai = args.begin() + 2;
+ std::vector<std::string>::const_iterator ae = args.end();
+ for(; ai != ae; ++ai)
+ {
+ std::string const& a = *ai;
+ if(cmHasLiteralPrefix(a, "--unset="))
+ {
+ // Unset environment variable.
+ cmSystemTools::UnPutEnv(a.c_str() + 8);
+ }
+ else if(!a.empty() && a[0] == '-')
+ {
+ // Environment variable and command names cannot start in '-',
+ // so this must be an unknown option.
+ std::cerr << "cmake -E env: unknown option '" << a << "'"
+ << std::endl;
+ return 1;
+ }
+ else if(a.find("=") != a.npos)
+ {
+ // Set environment variable.
+ cmSystemTools::PutEnv(a.c_str());
+ }
+ else
+ {
+ // This is the beginning of the command.
+ break;
+ }
+ }
+
+ if(ai == ae)
+ {
+ std::cerr << "cmake -E env: no command given" << std::endl;
+ return 1;
+ }
+
+ // Execute command from remaining arguments.
+ std::vector<std::string> cmd(ai, ae);
+ int retval;
+ if(cmSystemTools::RunSingleCommand(
+ cmd, 0, &retval, NULL, cmSystemTools::OUTPUT_PASSTHROUGH))
+ {
+ return retval;
+ }
+ return 1;
+ }
+
#if defined(CMAKE_BUILD_WITH_CMAKE)
// Command to create a symbolic link. Fails on platforms not
// supporting them.
diff --git a/Tests/RunCMake/CommandLine/E_env-bad-arg1-result.txt b/Tests/RunCMake/CommandLine/E_env-bad-arg1-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_env-bad-arg1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_env-bad-arg1-stderr.txt b/Tests/RunCMake/CommandLine/E_env-bad-arg1-stderr.txt
new file mode 100644
index 0000000..2143ba4
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_env-bad-arg1-stderr.txt
@@ -0,0 +1 @@
+^cmake -E env: unknown option '-bad-arg1'$
diff --git a/Tests/RunCMake/CommandLine/E_env-no-command0-result.txt b/Tests/RunCMake/CommandLine/E_env-no-command0-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_env-no-command0-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_env-no-command0-stderr.txt b/Tests/RunCMake/CommandLine/E_env-no-command0-stderr.txt
new file mode 100644
index 0000000..d2efa53
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_env-no-command0-stderr.txt
@@ -0,0 +1 @@
+^cmake -E env: no command given$
diff --git a/Tests/RunCMake/CommandLine/E_env-no-command1-result.txt b/Tests/RunCMake/CommandLine/E_env-no-command1-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_env-no-command1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_env-no-command1-stderr.txt b/Tests/RunCMake/CommandLine/E_env-no-command1-stderr.txt
new file mode 100644
index 0000000..d2efa53
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_env-no-command1-stderr.txt
@@ -0,0 +1 @@
+^cmake -E env: no command given$
diff --git a/Tests/RunCMake/CommandLine/E_env-set-stdout.txt b/Tests/RunCMake/CommandLine/E_env-set-stdout.txt
new file mode 100644
index 0000000..feff117
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_env-set-stdout.txt
@@ -0,0 +1 @@
+^-- TEST_ENV is correctly set in environment: 1$
diff --git a/Tests/RunCMake/CommandLine/E_env-set.cmake b/Tests/RunCMake/CommandLine/E_env-set.cmake
new file mode 100644
index 0000000..c2639b6
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_env-set.cmake
@@ -0,0 +1,5 @@
+if(DEFINED ENV{TEST_ENV})
+ message(STATUS "TEST_ENV is correctly set in environment: $ENV{TEST_ENV}")
+else()
+ message(FATAL_ERROR "TEST_ENV is incorrectly not set in environment")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_env-unset-stdout.txt b/Tests/RunCMake/CommandLine/E_env-unset-stdout.txt
new file mode 100644
index 0000000..a1d5c01
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_env-unset-stdout.txt
@@ -0,0 +1 @@
+^-- TEST_ENV is correctly not set in environment$
diff --git a/Tests/RunCMake/CommandLine/E_env-unset.cmake b/Tests/RunCMake/CommandLine/E_env-unset.cmake
new file mode 100644
index 0000000..04976fb
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_env-unset.cmake
@@ -0,0 +1,5 @@
+if(DEFINED ENV{TEST_ENV})
+ message(FATAL_ERROR "TEST_ENV is incorrectly set in environment")
+else()
+ message(STATUS "TEST_ENV is correctly not set in environment")
+endif()
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index f3d9637..5622a5b 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -31,6 +31,12 @@ if(UNIX)
)
endif()
+run_cmake_command(E_env-no-command0 ${CMAKE_COMMAND} -E env)
+run_cmake_command(E_env-no-command1 ${CMAKE_COMMAND} -E env TEST_ENV=1)
+run_cmake_command(E_env-bad-arg1 ${CMAKE_COMMAND} -E env -bad-arg1)
+run_cmake_command(E_env-set ${CMAKE_COMMAND} -E env TEST_ENV=1 ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_env-set.cmake)
+run_cmake_command(E_env-unset ${CMAKE_COMMAND} -E env TEST_ENV=1 ${CMAKE_COMMAND} -E env --unset=TEST_ENV ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_env-unset.cmake)
+
run_cmake_command(E_sleep-no-args ${CMAKE_COMMAND} -E sleep)
run_cmake_command(E_sleep-bad-arg1 ${CMAKE_COMMAND} -E sleep x)
run_cmake_command(E_sleep-bad-arg2 ${CMAKE_COMMAND} -E sleep 1 -1)
-----------------------------------------------------------------------
Summary of changes:
Help/manual/cmake.1.rst | 2 +-
Help/release/dev/cmake-E-env.rst | 4 ++
Source/cmcmd.cxx | 51 ++++++++++++++++++++
.../E_env-bad-arg1-result.txt} | 0
.../RunCMake/CommandLine/E_env-bad-arg1-stderr.txt | 1 +
.../E_env-no-command0-result.txt} | 0
.../CommandLine/E_env-no-command0-stderr.txt | 1 +
.../E_env-no-command1-result.txt} | 0
.../CommandLine/E_env-no-command1-stderr.txt | 1 +
Tests/RunCMake/CommandLine/E_env-set-stdout.txt | 1 +
Tests/RunCMake/CommandLine/E_env-set.cmake | 5 ++
Tests/RunCMake/CommandLine/E_env-unset-stdout.txt | 1 +
Tests/RunCMake/CommandLine/E_env-unset.cmake | 5 ++
Tests/RunCMake/CommandLine/RunCMakeTest.cmake | 6 +++
14 files changed, 77 insertions(+), 1 deletion(-)
create mode 100644 Help/release/dev/cmake-E-env.rst
copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => CommandLine/E_env-bad-arg1-result.txt} (100%)
create mode 100644 Tests/RunCMake/CommandLine/E_env-bad-arg1-stderr.txt
copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => CommandLine/E_env-no-command0-result.txt} (100%)
create mode 100644 Tests/RunCMake/CommandLine/E_env-no-command0-stderr.txt
copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => CommandLine/E_env-no-command1-result.txt} (100%)
create mode 100644 Tests/RunCMake/CommandLine/E_env-no-command1-stderr.txt
create mode 100644 Tests/RunCMake/CommandLine/E_env-set-stdout.txt
create mode 100644 Tests/RunCMake/CommandLine/E_env-set.cmake
create mode 100644 Tests/RunCMake/CommandLine/E_env-unset-stdout.txt
create mode 100644 Tests/RunCMake/CommandLine/E_env-unset.cmake
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list