ENH: clean up find stuff so that NO_SYSTEM_PATH is backwards compatible and you get put system env variables in the find commands

This commit is contained in:
Bill Hoffman 2006-03-16 17:49:16 -05:00
parent 88f69f0df9
commit 0fa30e1a69
2 changed files with 41 additions and 61 deletions

View File

@ -19,10 +19,7 @@
cmFindBase::cmFindBase() cmFindBase::cmFindBase()
{ {
this->AlreadyInCache = false; this->AlreadyInCache = false;
this->NoSystemPath = false; this->NoDefaultPath = false;
this->NoCMakePath = false;
this->NoCMakeEnvironmentPath = false;
this->NoCMakeSystemPath = false;
// default is to search frameworks first on apple // default is to search frameworks first on apple
#if defined(__APPLE__) #if defined(__APPLE__)
this->SearchFrameworkFirst = true; this->SearchFrameworkFirst = true;
@ -39,13 +36,10 @@ cmFindBase::cmFindBase()
" FIND_XXX(\n" " FIND_XXX(\n"
" <VAR> \n" " <VAR> \n"
" name | NAMES name1 [name2 ...]\n" " name | NAMES name1 [name2 ...]\n"
" PATHS path1 [path2 ...]\n" " PATHS path1 [path2 ... ENV var]\n"
" [PATH_SUFFIXES suffix1 [suffix2 ...]]\n" " [PATH_SUFFIXES suffix1 [suffix2 ...]]\n"
" [DOC \"cache documentation string\"]\n" " [DOC \"cache documentation string\"]\n"
" [NO_CMAKE_ENVIRONMENT_PATH]\n" " [NO_DEFAULT_PATH]\n"
" [NO_CMAKE_PATH]\n"
" [NO_SYSTEM_PATH]\n"
" [NO_CMAKE_SYSTEM_PATH]\n"
" )\n" " )\n"
"" ""
"This command is used to find a SEARCH_XXX_DESC. " "This command is used to find a SEARCH_XXX_DESC. "
@ -54,31 +48,33 @@ cmFindBase::cmFindBase()
"<VAR>-NOTFOUND. The name of the SEARCH_XXX that " "<VAR>-NOTFOUND. The name of the SEARCH_XXX that "
"is searched for is specified by the names listed " "is searched for is specified by the names listed "
"after the NAMES argument. Additional search locations " "after the NAMES argument. Additional search locations "
"can be specified after the PATHS argument. The argument " "can be specified after the PATHS argument. If ENV var is "
"found in the PATHS section the environment variable var "
"will be read and converted from a system environment variable to "
"a cmake style list of paths. For example ENV PATH would be a way "
"to list the system path variable. The argument "
"after DOC will be used for the documentation string in " "after DOC will be used for the documentation string in "
"the cache. PATH_SUFFIXES can be used to give sub directories " "the cache. PATH_SUFFIXES can be used to give sub directories "
"that will be appended to the search paths.\n" "that will be appended to the search paths.\n"
"The search process is as follows:\n" "If NO_DEFAULT_PATH is specified, then no additional paths are "
"1. Search cmake specific environment variables. This " "added to the search. "
"can be skipped if NO_CMAKE_ENVIRONMENT_PATH is passed.\n" "If NO_DEFAULT_PATH is not specified, the search process is as follows:\n"
"1. Search cmake specific environment variables."
"" ""
" CMAKE_FRAMEWORK_PATH\n" " CMAKE_FRAMEWORK_PATH\n"
" CMAKE_XXX_PATH\n" " CMAKE_XXX_PATH\n"
"2. Search cmake variables with the same names as " "2. Search cmake variables with the same names as "
"the cmake specific environment variables. These " "the cmake specific environment variables. These "
"are intended to be used on the command line with a " "are intended to be used on the command line with a "
"-DVAR=value. This can be skipped if NO_CMAKE_PATH " "-DVAR=value. \n"
"is passed.\n"
"" ""
" CMAKE_FRAMEWORK_PATH\n" " CMAKE_FRAMEWORK_PATH\n"
" CMAKE_XXX_PATH\n" " CMAKE_XXX_PATH\n"
"3. Search the standard system environment variables. " "3. Search the standard system environment variables. "
"This can be skipped if NO_SYSTEM_PATH is an argument.\n"
" PATH\n" " PATH\n"
" XXX_SYSTEM\n" // replace with "", LIB, or INCLUDE " XXX_SYSTEM\n" // replace with "", LIB, or INCLUDE
"4. Search cmake variables defined in the Platform files " "4. Search cmake variables defined in the Platform files "
"for the current system. This can be skipped if NO_CMAKE_SYSTEM_PATH " "for the current system. \n"
"is passed.\n"
" CMAKE_SYSTEM_FRAMEWORK_PATH\n" " CMAKE_SYSTEM_FRAMEWORK_PATH\n"
" CMAKE_SYSTEM_XXX_PATH\n" " CMAKE_SYSTEM_XXX_PATH\n"
"5. Search the paths specified after PATHS or in the short-hand version " "5. Search the paths specified after PATHS or in the short-hand version "
@ -109,7 +105,18 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
{ {
if(foundDoc || argsIn[j] != "DOC" ) if(foundDoc || argsIn[j] != "DOC" )
{ {
args.push_back(argsIn[j]); if(argsIn[j] == "ENV")
{
if(j+1 < size)
{
j++;
cmSystemTools::GetPath(args, argsIn[j].c_str());
}
}
else
{
args.push_back(argsIn[j]);
}
} }
else else
{ {
@ -138,7 +145,7 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
bool doingPaths = false; bool doingPaths = false;
bool doingPathSuf = false; bool doingPathSuf = false;
bool newStyle = false; bool newStyle = false;
for (unsigned int j = 1; j < args.size(); ++j) for (unsigned int j = 1; j < args.size(); ++j)
{ {
if(args[j] == "NAMES") if(args[j] == "NAMES")
@ -167,28 +174,14 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
doingPaths = false; doingPaths = false;
doingPathSuf = false; doingPathSuf = false;
doingNames = false; doingNames = false;
this->NoSystemPath = true; this->NoDefaultPath = true;
} }
else if (args[j] == "NO_CMAKE_PATH") else if (args[j] == "NO_DEFAULT_PATH")
{ {
doingPaths = false; doingPaths = false;
doingPathSuf = false; doingPathSuf = false;
doingNames = false; doingNames = false;
this->NoCMakePath = true; this->NoDefaultPath = true;
}
else if (args[j] == "NO_CMAKE_ENVIRONMENT_PATH")
{
doingPaths = false;
doingPathSuf = false;
doingNames = false;
this->NoCMakeEnvironmentPath = true;
}
else if (args[j] == "NO_CMAKE_SYSTEM_PATH")
{
doingPaths = false;
doingPathSuf = false;
doingNames = false;
this->NoCMakeSystemPath = true;
} }
else else
{ {
@ -245,26 +238,19 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
void cmFindBase::ExpandPaths(std::vector<std::string> userPaths) void cmFindBase::ExpandPaths(std::vector<std::string> userPaths)
{ {
// Add CMAKE_*_PATH environment variables // if NO Default paths was not specified add the
if(!this->NoCMakeEnvironmentPath) // standard search paths.
if(!this->NoDefaultPath)
{ {
// Add CMAKE_*_PATH environment variables
this->AddEnvironmentVairables(); this->AddEnvironmentVairables();
} // Add CMake varibles of the same name as the previous environment
// Add CMake varibles of the same name as the previous environment // varibles CMAKE_*_PATH to be used most of the time with -D
// varibles CMAKE_*_PATH to be used most of the time with -D // command line options
// command line options
if(!this->NoCMakePath)
{
this->AddCMakeVairables(); this->AddCMakeVairables();
} // add System environment PATH and (LIB or INCLUDE)
// add System environment PATH and (LIB or INCLUDE)
if(!this->NoSystemPath)
{
this->AddSystemEnvironmentVairables(); this->AddSystemEnvironmentVairables();
} // Add CMAKE_SYSTEM_*_PATH variables which are defined in platform files
// Add CMAKE_SYSTEM_*_PATH variables which are defined in platform files
if(!this->NoCMakeSystemPath)
{
this->AddCMakeSystemVariables(); this->AddCMakeSystemVariables();
} }
// add the paths specified in the FIND_* call // add the paths specified in the FIND_* call
@ -399,10 +385,7 @@ void cmFindBase::PrintFindStuff()
{ {
std::cerr << "VariableName " << this->VariableName << "\n"; std::cerr << "VariableName " << this->VariableName << "\n";
std::cerr << "VariableDocumentation " << this->VariableDocumentation << "\n"; std::cerr << "VariableDocumentation " << this->VariableDocumentation << "\n";
std::cerr << "NoSystemPath " << this->NoSystemPath << "\n"; std::cerr << "NoDefaultPath " << this->NoDefaultPath << "\n";
std::cerr << "NoCMakeEnvironmentPath " << this->NoCMakeEnvironmentPath << "\n";
std::cerr << "NoCMakePath " << this->NoCMakePath << "\n";
std::cerr << "NoCMakeSystemPath " << this->NoCMakeSystemPath << "\n";
std::cerr << "EnvironmentPath " << this->EnvironmentPath << "\n"; std::cerr << "EnvironmentPath " << this->EnvironmentPath << "\n";
std::cerr << "CMakePathName " << this->CMakePathName << "\n"; std::cerr << "CMakePathName " << this->CMakePathName << "\n";
std::cerr << "Names "; std::cerr << "Names ";

View File

@ -65,10 +65,7 @@ protected:
cmStdString EnvironmentPath; // LIB,INCLUDE cmStdString EnvironmentPath; // LIB,INCLUDE
bool AlreadyInCache; bool AlreadyInCache;
bool NoSystemPath; bool NoDefaultPath;
bool NoCMakeEnvironmentPath;
bool NoCMakePath;
bool NoCMakeSystemPath;
bool SearchFrameworkFirst; bool SearchFrameworkFirst;
bool SearchFrameworkOnly; bool SearchFrameworkOnly;