ENH: Add argument -N which prevents CMake from doing configure and generate. This should be improved at some point that it will do all the error checking such as whether the CMakeLists.txt exists etc. It should essentially load cache, go through cmake lists, but not modify cache and other files in the build directory. The second feature is ability to display cache values. You run with argument -L (or -LH /-LA / -LAH) and it will display all nonadvanced cached variables (-L) / all cached variable (-LA) / and cached variables with corresponding help string (-LH -LAH).

This commit is contained in:
Andy Cedilnik 2003-04-29 10:07:30 -04:00
parent e72535fda7
commit 565200b893
1 changed files with 65 additions and 1 deletions

View File

@ -53,6 +53,16 @@ static const cmDocumentationEntry cmDocumentationOptions[] =
"Wizard mode runs cmake interactively without a GUI. The user is " "Wizard mode runs cmake interactively without a GUI. The user is "
"prompted to answer questions about the project configuration. " "prompted to answer questions about the project configuration. "
"The answers are used to set cmake cache values."}, "The answers are used to set cmake cache values."},
{"-L[A][H]", "List non-advanced cached variables.",
"List cache variables will run CMake and list all the variables from the "
"CMake cache that are not marked as INTERNAL or ADVANCED. This will "
"effectively display current CMake settings, which can be then changed "
"with -D option. Changing some of the variable may result in more "
"variables being created. If A is specified, then it will display also "
"advanced variables. If H is specified, it will also display help for "
"each variable."},
{"-N", "View mode only.",
"Only load the cache. Do not actually run configure and generate steps."},
{0,0,0} {0,0,0}
}; };
@ -113,6 +123,10 @@ int do_cmake(int ac, char** av)
bool wiz = false; bool wiz = false;
bool command = false; bool command = false;
bool list_cached = false;
bool list_all_cached = false;
bool list_help = false;
bool view_only = false;
std::vector<std::string> args; std::vector<std::string> args;
for(int i =0; i < ac; ++i) for(int i =0; i < ac; ++i)
{ {
@ -124,6 +138,28 @@ int do_cmake(int ac, char** av)
{ {
command = true; command = true;
} }
else if (strcmp(av[i], "-N") == 0)
{
view_only = true;
}
else if (strcmp(av[i], "-L") == 0)
{
list_cached = true;
}
else if (strcmp(av[i], "-LA") == 0)
{
list_all_cached = true;
}
else if (strcmp(av[i], "-LH") == 0)
{
list_cached = true;
list_help = true;
}
else if (strcmp(av[i], "-LAH") == 0)
{
list_all_cached = true;
list_help = true;
}
else else
{ {
args.push_back(av[i]); args.push_back(av[i]);
@ -143,7 +179,35 @@ int do_cmake(int ac, char** av)
} }
cmake cm; cmake cm;
cm.SetProgressCallback(updateProgress, 0); cm.SetProgressCallback(updateProgress, 0);
return cm.Run(args); int res = cm.Run(args, view_only);
if ( list_cached || list_all_cached )
{
cmCacheManager::CacheIterator it = cm.GetCacheManager()->GetCacheIterator();
std::cout << "-- Cache values" << std::endl;
for ( it.Begin(); !it.IsAtEnd(); it.Next() )
{
cmCacheManager::CacheEntryType t = it.GetType();
if ( t != cmCacheManager::INTERNAL && t != cmCacheManager::STATIC &&
t != cmCacheManager::UNINITIALIZED )
{
bool advanced = it.PropertyExists("ADVANCED");
if ( list_all_cached || !advanced)
{
if ( list_help )
{
std::cout << "// " << it.GetProperty("HELPSTRING") << std::endl;
}
std::cout << it.GetName() << ":" << cmCacheManager::TypeToString(it.GetType())
<< "=" << it.GetValue() << std::endl;
if ( list_help )
{
std::cout << std::endl;
}
}
}
}
}
return res;
} }
void updateProgress(const char *msg, float prog, void*) void updateProgress(const char *msg, float prog, void*)