mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-04 12:49:36 -06:00
committed by
Brad King
parent
d526327079
commit
cb01b8c8ba
@@ -86,7 +86,7 @@ Set Environment Variable
|
|||||||
|
|
||||||
.. code-block:: cmake
|
.. code-block:: cmake
|
||||||
|
|
||||||
set(ENV{<variable>} <value>...)
|
set(ENV{<variable>} [<value>])
|
||||||
|
|
||||||
Sets an :manual:`Environment Variable <cmake-env-variables(7)>`
|
Sets an :manual:`Environment Variable <cmake-env-variables(7)>`
|
||||||
to the given value.
|
to the given value.
|
||||||
@@ -95,3 +95,10 @@ Subsequent calls of ``$ENV{<variable>}`` will return this new value.
|
|||||||
This command affects only the current CMake process, not the process
|
This command affects only the current CMake process, not the process
|
||||||
from which CMake was called, nor the system environment at large,
|
from which CMake was called, nor the system environment at large,
|
||||||
nor the environment of subsequent build or test processes.
|
nor the environment of subsequent build or test processes.
|
||||||
|
|
||||||
|
If no argument is given after ``ENV{<variable>}`` or if ``<value>`` is
|
||||||
|
an empty string, then this command will clear any existing value of the
|
||||||
|
environment variable.
|
||||||
|
|
||||||
|
Arguments after ``<value>`` are ignored. If extra arguments are found,
|
||||||
|
then an author warning is issued.
|
||||||
|
|||||||
@@ -38,6 +38,14 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args,
|
|||||||
putEnvArg += args[1];
|
putEnvArg += args[1];
|
||||||
cmSystemTools::PutEnv(putEnvArg);
|
cmSystemTools::PutEnv(putEnvArg);
|
||||||
}
|
}
|
||||||
|
// if there's extra arguments, warn user
|
||||||
|
// that they are ignored by this command.
|
||||||
|
if (args.size() > 2) {
|
||||||
|
std::string m = "Only the first value argument is used when setting "
|
||||||
|
"an environment variable. Argument '" +
|
||||||
|
args[2] + "' and later are unused.";
|
||||||
|
this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, m);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6
Tests/RunCMake/set/ExtraEnvValue-stderr.txt
Normal file
6
Tests/RunCMake/set/ExtraEnvValue-stderr.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
CMake Warning \(dev\) at ExtraEnvValue.cmake:1 \(set\):
|
||||||
|
Only the first value argument is used when setting an environment variable.
|
||||||
|
Argument 'value_2' and later are unused.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
||||||
|
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||||
1
Tests/RunCMake/set/ExtraEnvValue.cmake
Normal file
1
Tests/RunCMake/set/ExtraEnvValue.cmake
Normal file
@@ -0,0 +1 @@
|
|||||||
|
set (ENV{sample_key} value_1 value_2)
|
||||||
@@ -4,3 +4,4 @@ run_cmake(ParentScope)
|
|||||||
run_cmake(ParentPulling)
|
run_cmake(ParentPulling)
|
||||||
run_cmake(ParentPullingRecursive)
|
run_cmake(ParentPullingRecursive)
|
||||||
run_cmake(UnknownCacheType)
|
run_cmake(UnknownCacheType)
|
||||||
|
run_cmake(ExtraEnvValue)
|
||||||
|
|||||||
Reference in New Issue
Block a user