ENH: Use vector of plain strings and add cmake -E command for getting environment
This commit is contained in:
parent
f44fedd3e9
commit
fe1fda6431
|
@ -1280,9 +1280,9 @@ bool cmSystemTools::PutEnv(const char* value)
|
||||||
return ret == 0;
|
return ret == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<cmStdString> cmSystemTools::GetEnvironmentVariables()
|
std::vector<std::string> cmSystemTools::GetEnvironmentVariables()
|
||||||
{
|
{
|
||||||
std::vector<cmStdString> env;
|
std::vector<std::string> env;
|
||||||
int cc;
|
int cc;
|
||||||
for ( cc = 0; environ[cc]; ++ cc )
|
for ( cc = 0; environ[cc]; ++ cc )
|
||||||
{
|
{
|
||||||
|
|
|
@ -294,7 +294,7 @@ public:
|
||||||
/** put a string into the environment
|
/** put a string into the environment
|
||||||
of the form var=value */
|
of the form var=value */
|
||||||
static bool PutEnv(const char* value);
|
static bool PutEnv(const char* value);
|
||||||
static std::vector<cmStdString> GetEnvironmentVariables();
|
static std::vector<std::string> GetEnvironmentVariables();
|
||||||
|
|
||||||
/** Setup the environment to enable VS 8 IDE output. */
|
/** Setup the environment to enable VS 8 IDE output. */
|
||||||
static void EnableVSConsoleOutput();
|
static void EnableVSConsoleOutput();
|
||||||
|
|
|
@ -745,18 +745,18 @@ void CMakeCommandUsage(const char* program)
|
||||||
"content to directory 'destination'\n"
|
"content to directory 'destination'\n"
|
||||||
<< " compare_files file1 file2 - check if file1 is same as file2\n"
|
<< " compare_files file1 file2 - check if file1 is same as file2\n"
|
||||||
<< " echo [string]... - displays arguments as text\n"
|
<< " echo [string]... - displays arguments as text\n"
|
||||||
|
<< " environment - display the current enviroment\n"
|
||||||
<< " remove file1 file2 ... - remove the file(s)\n"
|
<< " remove file1 file2 ... - remove the file(s)\n"
|
||||||
<< " tar [cxt][vfz] file.tar file/dir1 file/dir2 ... - create a tar.\n"
|
<< " tar [cxt][vfz] file.tar file/dir1 file/dir2 ... - create a tar.\n"
|
||||||
<< " time command [args] ... - run command and return elapsed time\n";
|
<< " time command [args] ... - run command and return elapsed time\n"
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
errorStream
|
|
||||||
<< " write_regv key value - write registry value\n"
|
<< " write_regv key value - write registry value\n"
|
||||||
<< " delete_regv key - delete registry value\n"
|
<< " delete_regv key - delete registry value\n"
|
||||||
<< " comspec - on windows 9x use this for RunCommand\n";
|
<< " comspec - on windows 9x use this for RunCommand\n"
|
||||||
#else
|
#else
|
||||||
errorStream
|
<< " create_symlink old new - create a symbolic link new -> old\n"
|
||||||
<< " create_symlink old new - create a symbolic link new -> old\n";
|
|
||||||
#endif
|
#endif
|
||||||
|
;
|
||||||
|
|
||||||
cmSystemTools::Error(errorStream.str().c_str());
|
cmSystemTools::Error(errorStream.str().c_str());
|
||||||
}
|
}
|
||||||
|
@ -831,6 +831,19 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Command to create a symbolic link. Fails on platforms not
|
||||||
|
// supporting them.
|
||||||
|
else if (args[1] == "environment" )
|
||||||
|
{
|
||||||
|
std::vector<std::string> env = cmSystemTools::GetEnvironmentVariables();
|
||||||
|
std::vector<std::string>::iterator it;
|
||||||
|
for ( it = env.begin(); it != env.end(); ++ it )
|
||||||
|
{
|
||||||
|
std::cout << it->c_str() << std::endl;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove file
|
// Remove file
|
||||||
else if (args[1] == "remove" && args.size() > 2)
|
else if (args[1] == "remove" && args.size() > 2)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue