2009-10-02 01:21:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2006-02-28 00:38:22 +03:00
|
|
|
|
2009-10-02 01:21:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2006-02-28 00:38:22 +03:00
|
|
|
|
2009-10-02 01:21:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2006-02-28 00:38:22 +03:00
|
|
|
#include "cmFindBase.h"
|
|
|
|
|
|
|
|
cmFindBase::cmFindBase()
|
|
|
|
{
|
2008-01-17 17:02:31 +03:00
|
|
|
cmSystemTools::ReplaceString(this->GenericDocumentationPathsOrder,
|
|
|
|
"FIND_ARGS_XXX", "<VAR> NAMES name");
|
2006-02-28 00:38:22 +03:00
|
|
|
this->AlreadyInCache = false;
|
2006-07-18 23:21:26 +04:00
|
|
|
this->AlreadyInCacheWithoutMetaInfo = false;
|
2006-03-02 21:30:22 +03:00
|
|
|
this->GenericDocumentation =
|
2008-01-18 01:49:30 +03:00
|
|
|
" FIND_XXX(<VAR> name1 [path1 path2 ...])\n"
|
2006-03-02 21:43:39 +03:00
|
|
|
"This is the short-hand signature for the command that "
|
2006-03-02 21:30:22 +03:00
|
|
|
"is sufficient in many cases. It is the same "
|
2008-01-18 01:49:30 +03:00
|
|
|
"as FIND_XXX(<VAR> name1 [PATHS path1 path2 ...])\n"
|
2006-03-02 21:30:22 +03:00
|
|
|
" FIND_XXX(\n"
|
2008-01-10 06:09:19 +03:00
|
|
|
" <VAR>\n"
|
2006-03-04 07:00:09 +03:00
|
|
|
" name | NAMES name1 [name2 ...]\n"
|
2008-06-09 23:08:59 +04:00
|
|
|
" [HINTS path1 [path2 ... ENV var]]\n"
|
2008-01-18 01:49:30 +03:00
|
|
|
" [PATHS path1 [path2 ... ENV var]]\n"
|
2006-03-02 21:30:22 +03:00
|
|
|
" [PATH_SUFFIXES suffix1 [suffix2 ...]]\n"
|
|
|
|
" [DOC \"cache documentation string\"]\n"
|
2006-03-17 01:49:16 +03:00
|
|
|
" [NO_DEFAULT_PATH]\n"
|
2006-03-24 22:16:31 +03:00
|
|
|
" [NO_CMAKE_ENVIRONMENT_PATH]\n"
|
|
|
|
" [NO_CMAKE_PATH]\n"
|
|
|
|
" [NO_SYSTEM_ENVIRONMENT_PATH]\n"
|
|
|
|
" [NO_CMAKE_SYSTEM_PATH]\n"
|
2008-01-17 17:02:31 +03:00
|
|
|
" [CMAKE_FIND_ROOT_PATH_BOTH |\n"
|
|
|
|
" ONLY_CMAKE_FIND_ROOT_PATH |\n"
|
|
|
|
" NO_CMAKE_FIND_ROOT_PATH]\n"
|
2006-03-02 21:30:22 +03:00
|
|
|
" )\n"
|
|
|
|
""
|
|
|
|
"This command is used to find a SEARCH_XXX_DESC. "
|
|
|
|
"A cache entry named by <VAR> is created to store the result "
|
2006-10-19 17:18:59 +04:00
|
|
|
"of this command. "
|
|
|
|
"If the SEARCH_XXX is found the result is stored in the variable "
|
|
|
|
"and the search will not be repeated unless the variable is cleared. "
|
|
|
|
"If nothing is found, the result will be "
|
|
|
|
"<VAR>-NOTFOUND, and the search will be attempted again the "
|
|
|
|
"next time FIND_XXX is invoked with the same variable. "
|
|
|
|
"The name of the SEARCH_XXX that "
|
2006-03-02 21:30:22 +03:00
|
|
|
"is searched for is specified by the names listed "
|
|
|
|
"after the NAMES argument. Additional search locations "
|
2006-03-17 01:49:16 +03:00
|
|
|
"can be specified after the PATHS argument. If ENV var is "
|
2008-06-09 23:08:59 +04:00
|
|
|
"found in the HINTS or PATHS section the environment variable var "
|
2006-03-17 01:49:16 +03:00
|
|
|
"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 "
|
2006-03-02 21:30:22 +03:00
|
|
|
"after DOC will be used for the documentation string in "
|
2008-10-14 16:43:19 +04:00
|
|
|
"the cache. "
|
|
|
|
"PATH_SUFFIXES specifies additional subdirectories to check below "
|
|
|
|
"each search path."
|
|
|
|
"\n"
|
2006-03-17 01:49:16 +03:00
|
|
|
"If NO_DEFAULT_PATH is specified, then no additional paths are "
|
|
|
|
"added to the search. "
|
|
|
|
"If NO_DEFAULT_PATH is not specified, the search process is as follows:\n"
|
2008-06-09 23:22:09 +04:00
|
|
|
"1. Search paths specified in cmake-specific cache variables. "
|
|
|
|
"These are intended to be used on the command line with a -DVAR=value. "
|
|
|
|
"This can be skipped if NO_CMAKE_PATH is passed.\n"
|
2007-12-19 19:06:47 +03:00
|
|
|
" <prefix>/XXX_SUBDIR for each <prefix> in CMAKE_PREFIX_PATH\n"
|
2006-03-02 21:30:22 +03:00
|
|
|
" CMAKE_XXX_PATH\n"
|
2008-01-17 17:02:31 +03:00
|
|
|
" CMAKE_XXX_MAC_PATH\n"
|
2008-06-09 23:22:09 +04:00
|
|
|
"2. Search paths specified in cmake-specific environment variables. "
|
|
|
|
"These are intended to be set in the user's shell configuration. "
|
|
|
|
"This can be skipped if NO_CMAKE_ENVIRONMENT_PATH is passed.\n"
|
2007-12-19 19:06:47 +03:00
|
|
|
" <prefix>/XXX_SUBDIR for each <prefix> in CMAKE_PREFIX_PATH\n"
|
2006-03-02 21:30:22 +03:00
|
|
|
" CMAKE_XXX_PATH\n"
|
2008-01-17 17:02:31 +03:00
|
|
|
" CMAKE_XXX_MAC_PATH\n"
|
2008-06-09 23:08:59 +04:00
|
|
|
"3. Search the paths specified by the HINTS option. "
|
|
|
|
"These should be paths computed by system introspection, such as a "
|
|
|
|
"hint provided by the location of another item already found. "
|
|
|
|
"Hard-coded guesses should be specified with the PATHS option.\n"
|
|
|
|
"4. Search the standard system environment variables. "
|
2006-03-24 22:16:31 +03:00
|
|
|
"This can be skipped if NO_SYSTEM_ENVIRONMENT_PATH is an argument.\n"
|
2006-03-02 21:30:22 +03:00
|
|
|
" PATH\n"
|
|
|
|
" XXX_SYSTEM\n" // replace with "", LIB, or INCLUDE
|
2008-06-09 23:08:59 +04:00
|
|
|
"5. Search cmake variables defined in the Platform files "
|
2006-03-24 22:16:31 +03:00
|
|
|
"for the current system. This can be skipped if NO_CMAKE_SYSTEM_PATH "
|
|
|
|
"is passed.\n"
|
2007-12-19 18:34:43 +03:00
|
|
|
" <prefix>/XXX_SUBDIR for each <prefix> in CMAKE_SYSTEM_PREFIX_PATH\n"
|
2006-03-02 21:30:22 +03:00
|
|
|
" CMAKE_SYSTEM_XXX_PATH\n"
|
2008-01-17 17:02:31 +03:00
|
|
|
" CMAKE_SYSTEM_XXX_MAC_PATH\n"
|
2008-06-09 23:08:59 +04:00
|
|
|
"6. Search the paths specified by the PATHS option "
|
|
|
|
"or in the short-hand version of the command. "
|
|
|
|
"These are typically hard-coded guesses.\n"
|
2008-01-17 17:02:31 +03:00
|
|
|
;
|
|
|
|
this->GenericDocumentation += this->GenericDocumentationMacPolicy;
|
|
|
|
this->GenericDocumentation += this->GenericDocumentationRootPath;
|
|
|
|
this->GenericDocumentation += this->GenericDocumentationPathsOrder;
|
2006-02-28 00:38:22 +03:00
|
|
|
}
|
2006-03-02 21:30:22 +03:00
|
|
|
|
2006-02-28 00:38:22 +03:00
|
|
|
bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
|
|
|
|
{
|
|
|
|
if(argsIn.size() < 2 )
|
|
|
|
{
|
|
|
|
this->SetError("called with incorrect number of arguments");
|
|
|
|
return false;
|
|
|
|
}
|
2006-04-13 19:00:52 +04:00
|
|
|
|
2006-03-28 23:45:22 +04:00
|
|
|
// CMake versions below 2.3 did not search all these extra
|
|
|
|
// locations. Preserve compatibility unless a modern argument is
|
|
|
|
// passed.
|
2008-03-07 23:30:35 +03:00
|
|
|
bool compatibility = this->Makefile->NeedBackwardsCompatibility(2,3);
|
2006-03-28 23:45:22 +04:00
|
|
|
|
2006-02-28 00:38:22 +03:00
|
|
|
// copy argsIn into args so it can be modified,
|
|
|
|
// in the process extract the DOC "documentation"
|
|
|
|
size_t size = argsIn.size();
|
|
|
|
std::vector<std::string> args;
|
|
|
|
bool foundDoc = false;
|
|
|
|
for(unsigned int j = 0; j < size; ++j)
|
|
|
|
{
|
|
|
|
if(foundDoc || argsIn[j] != "DOC" )
|
|
|
|
{
|
2006-03-17 01:49:16 +03:00
|
|
|
if(argsIn[j] == "ENV")
|
|
|
|
{
|
|
|
|
if(j+1 < size)
|
|
|
|
{
|
|
|
|
j++;
|
|
|
|
cmSystemTools::GetPath(args, argsIn[j].c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
args.push_back(argsIn[j]);
|
|
|
|
}
|
2006-02-28 00:38:22 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(j+1 < size)
|
|
|
|
{
|
|
|
|
foundDoc = true;
|
|
|
|
this->VariableDocumentation = argsIn[j+1];
|
|
|
|
j++;
|
|
|
|
if(j >= size)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this->VariableName = args[0];
|
|
|
|
if(this->CheckForVariableInCache())
|
|
|
|
{
|
|
|
|
this->AlreadyInCache = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
this->AlreadyInCache = false;
|
2008-01-17 17:02:31 +03:00
|
|
|
|
|
|
|
// Find the current root path mode.
|
|
|
|
this->SelectDefaultRootPathMode();
|
|
|
|
|
|
|
|
// Find the current bundle/framework search policy.
|
|
|
|
this->SelectDefaultMacMode();
|
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
2007-05-17 21:20:44 +04:00
|
|
|
|
2006-02-28 00:38:22 +03:00
|
|
|
bool newStyle = false;
|
2008-06-09 23:08:59 +04:00
|
|
|
enum Doing { DoingNone, DoingNames, DoingPaths, DoingPathSuffixes,
|
|
|
|
DoingHints };
|
|
|
|
Doing doing = DoingNames; // assume it starts with a name
|
2006-02-28 00:38:22 +03:00
|
|
|
for (unsigned int j = 1; j < args.size(); ++j)
|
|
|
|
{
|
|
|
|
if(args[j] == "NAMES")
|
|
|
|
{
|
2008-06-09 23:08:59 +04:00
|
|
|
doing = DoingNames;
|
2006-02-28 00:38:22 +03:00
|
|
|
newStyle = true;
|
|
|
|
}
|
|
|
|
else if (args[j] == "PATHS")
|
|
|
|
{
|
2008-06-09 23:08:59 +04:00
|
|
|
doing = DoingPaths;
|
|
|
|
newStyle = true;
|
|
|
|
}
|
|
|
|
else if (args[j] == "HINTS")
|
|
|
|
{
|
|
|
|
doing = DoingHints;
|
2006-02-28 00:38:22 +03:00
|
|
|
newStyle = true;
|
|
|
|
}
|
|
|
|
else if (args[j] == "PATH_SUFFIXES")
|
2006-03-28 23:45:22 +04:00
|
|
|
{
|
2008-06-09 23:08:59 +04:00
|
|
|
doing = DoingPathSuffixes;
|
2006-03-28 23:45:22 +04:00
|
|
|
compatibility = false;
|
2006-02-28 00:38:22 +03:00
|
|
|
newStyle = true;
|
|
|
|
}
|
2006-03-28 23:45:22 +04:00
|
|
|
else if (args[j] == "NO_SYSTEM_PATH")
|
2006-02-28 00:38:22 +03:00
|
|
|
{
|
2008-06-09 23:08:59 +04:00
|
|
|
doing = DoingNone;
|
2006-03-17 01:49:16 +03:00
|
|
|
this->NoDefaultPath = true;
|
2006-02-28 00:38:22 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
else if (this->CheckCommonArgument(args[j]))
|
2006-03-24 22:16:31 +03:00
|
|
|
{
|
2008-06-09 23:08:59 +04:00
|
|
|
doing = DoingNone;
|
2006-03-28 23:45:22 +04:00
|
|
|
compatibility = false;
|
2008-06-10 21:22:18 +04:00
|
|
|
// Some common arguments were accidentally supported by CMake
|
|
|
|
// 2.4 and 2.6.0 in the short-hand form of the command, so we
|
|
|
|
// must support it even though it is not documented.
|
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
2007-05-17 21:20:44 +04:00
|
|
|
}
|
2008-06-09 23:08:59 +04:00
|
|
|
else if(doing == DoingNames)
|
2006-02-28 00:38:22 +03:00
|
|
|
{
|
2008-06-09 23:08:59 +04:00
|
|
|
this->Names.push_back(args[j]);
|
|
|
|
}
|
|
|
|
else if(doing == DoingPaths)
|
|
|
|
{
|
|
|
|
this->AddUserPath(args[j], this->UserPaths);
|
|
|
|
}
|
|
|
|
else if(doing == DoingHints)
|
|
|
|
{
|
|
|
|
this->AddUserPath(args[j], this->UserHints);
|
|
|
|
}
|
|
|
|
else if(doing == DoingPathSuffixes)
|
|
|
|
{
|
|
|
|
this->AddPathSuffix(args[j]);
|
2006-02-28 00:38:22 +03:00
|
|
|
}
|
|
|
|
}
|
2006-03-28 23:45:22 +04:00
|
|
|
|
|
|
|
// Now that arguments have been parsed check the compatibility
|
|
|
|
// setting. If we need to be compatible with CMake 2.2 and earlier
|
|
|
|
// do not add the CMake system paths. It is safe to add the CMake
|
|
|
|
// environment paths and system environment paths because that
|
|
|
|
// existed in 2.2. It is safe to add the CMake user variable paths
|
|
|
|
// because the user or project has explicitly set them.
|
|
|
|
if(compatibility)
|
|
|
|
{
|
|
|
|
this->NoCMakeSystemPath = true;
|
|
|
|
}
|
|
|
|
|
2006-02-28 00:38:22 +03:00
|
|
|
if(this->VariableDocumentation.size() == 0)
|
|
|
|
{
|
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
2007-05-17 21:20:44 +04:00
|
|
|
this->VariableDocumentation = "Where can ";
|
2006-02-28 00:38:22 +03:00
|
|
|
if(this->Names.size() == 0)
|
|
|
|
{
|
|
|
|
this->VariableDocumentation += "the (unknown) library be found";
|
|
|
|
}
|
|
|
|
else if(this->Names.size() == 1)
|
|
|
|
{
|
2006-05-10 23:46:45 +04:00
|
|
|
this->VariableDocumentation += "the "
|
|
|
|
+ this->Names[0] + " library be found";
|
2006-02-28 00:38:22 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->VariableDocumentation += "one of the " + this->Names[0];
|
|
|
|
for (unsigned int j = 1; j < this->Names.size() - 1; ++j)
|
|
|
|
{
|
|
|
|
this->VariableDocumentation += ", " + this->Names[j];
|
|
|
|
}
|
2006-05-10 23:46:45 +04:00
|
|
|
this->VariableDocumentation += " or "
|
|
|
|
+ this->Names[this->Names.size() - 1] + " libraries be found";
|
2006-02-28 00:38:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// look for old style
|
|
|
|
// FIND_*(VAR name path1 path2 ...)
|
|
|
|
if(!newStyle)
|
|
|
|
{
|
2008-06-10 21:22:18 +04:00
|
|
|
// All the short-hand arguments have been recorded as names.
|
|
|
|
std::vector<std::string> shortArgs = this->Names;
|
2006-03-05 16:38:24 +03:00
|
|
|
this->Names.clear(); // clear out any values in Names
|
2008-06-10 21:22:18 +04:00
|
|
|
this->Names.push_back(shortArgs[0]);
|
|
|
|
for(unsigned int j = 1; j < shortArgs.size(); ++j)
|
2006-02-28 00:38:22 +03:00
|
|
|
{
|
2008-06-10 21:22:18 +04:00
|
|
|
this->AddUserPath(shortArgs[j], this->UserPaths);
|
2006-02-28 00:38:22 +03:00
|
|
|
}
|
|
|
|
}
|
2008-06-06 02:20:16 +04:00
|
|
|
this->ExpandPaths();
|
2008-01-17 17:02:31 +03:00
|
|
|
|
|
|
|
// Handle search root stuff.
|
|
|
|
this->RerootPaths(this->SearchPaths);
|
2008-06-09 19:57:56 +04:00
|
|
|
|
|
|
|
// Add a trailing slash to all prefixes to aid the search process.
|
|
|
|
this->AddTrailingSlashes(this->SearchPaths);
|
|
|
|
|
2006-02-28 00:38:22 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-06-06 02:20:16 +04:00
|
|
|
void cmFindBase::ExpandPaths()
|
2006-02-28 00:38:22 +03:00
|
|
|
{
|
2008-06-09 19:58:29 +04:00
|
|
|
this->AddCMakeVariablePath();
|
2008-06-09 23:22:09 +04:00
|
|
|
this->AddCMakeEnvironmentPath();
|
2008-06-09 23:08:59 +04:00
|
|
|
this->AddUserHintsPath();
|
2008-06-09 19:58:29 +04:00
|
|
|
this->AddSystemEnvironmentPath();
|
|
|
|
this->AddCMakeSystemVariablePath();
|
2008-06-09 23:08:59 +04:00
|
|
|
this->AddUserGuessPath();
|
2008-06-06 02:20:16 +04:00
|
|
|
|
|
|
|
// Add suffixes and clean up paths.
|
|
|
|
this->AddPathSuffixes();
|
2007-10-26 17:55:40 +04:00
|
|
|
}
|
|
|
|
|
2008-06-06 02:20:16 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmFindBase::AddPrefixPaths(std::vector<std::string> const& in_paths,
|
|
|
|
PathType pathType)
|
2007-10-26 17:55:40 +04:00
|
|
|
{
|
|
|
|
// default for programs
|
2008-01-17 17:02:31 +03:00
|
|
|
std::string subdir = "bin";
|
2007-10-26 17:55:40 +04:00
|
|
|
|
|
|
|
if (this->CMakePathName == "INCLUDE")
|
|
|
|
{
|
2008-01-17 17:02:31 +03:00
|
|
|
subdir = "include";
|
2007-10-26 17:55:40 +04:00
|
|
|
}
|
|
|
|
else if (this->CMakePathName == "LIBRARY")
|
|
|
|
{
|
2008-01-17 17:02:31 +03:00
|
|
|
subdir = "lib";
|
2007-10-26 17:55:40 +04:00
|
|
|
}
|
|
|
|
else if (this->CMakePathName == "FRAMEWORK")
|
|
|
|
{
|
|
|
|
subdir = ""; // ? what to do for frameworks ?
|
|
|
|
}
|
|
|
|
|
2008-06-06 02:20:16 +04:00
|
|
|
for(std::vector<std::string>::const_iterator it = in_paths.begin();
|
|
|
|
it != in_paths.end(); ++it)
|
2007-10-26 17:55:40 +04:00
|
|
|
{
|
2008-01-17 17:02:31 +03:00
|
|
|
std::string dir = it->c_str();
|
|
|
|
if(!subdir.empty() && !dir.empty() && dir[dir.size()-1] != '/')
|
|
|
|
{
|
|
|
|
dir += "/";
|
|
|
|
}
|
2008-05-23 23:52:15 +04:00
|
|
|
std::string add = dir + subdir;
|
|
|
|
if(add != "/")
|
2008-05-23 23:25:04 +04:00
|
|
|
{
|
2008-06-06 02:20:16 +04:00
|
|
|
this->AddPathInternal(add, pathType);
|
2008-05-23 23:25:04 +04:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
if (subdir == "bin")
|
2007-10-26 17:55:40 +04:00
|
|
|
{
|
2008-06-06 02:20:16 +04:00
|
|
|
this->AddPathInternal(dir+"sbin", pathType);
|
2007-10-26 17:55:40 +04:00
|
|
|
}
|
2008-05-23 23:25:04 +04:00
|
|
|
if(!subdir.empty() && *it != "/")
|
2007-12-28 20:01:37 +03:00
|
|
|
{
|
2008-06-06 02:20:16 +04:00
|
|
|
this->AddPathInternal(*it, pathType);
|
2007-12-28 20:01:37 +03:00
|
|
|
}
|
2007-10-26 17:55:40 +04:00
|
|
|
}
|
2006-02-28 00:38:22 +03:00
|
|
|
}
|
|
|
|
|
2008-06-06 02:20:16 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmFindBase::AddCMakePrefixPath(const char* variable)
|
2006-03-30 20:55:19 +04:00
|
|
|
{
|
2008-06-06 02:20:16 +04:00
|
|
|
// Get a path from a CMake variable.
|
|
|
|
if(const char* varPath = this->Makefile->GetDefinition(variable))
|
|
|
|
{
|
|
|
|
std::vector<std::string> tmp;
|
|
|
|
cmSystemTools::ExpandListArgument(varPath, tmp);
|
|
|
|
this->AddPrefixPaths(tmp, CMakePath);
|
|
|
|
}
|
2006-12-28 23:31:47 +03:00
|
|
|
}
|
|
|
|
|
2008-06-06 02:20:16 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmFindBase::AddEnvPrefixPath(const char* variable)
|
2006-12-28 23:31:47 +03:00
|
|
|
{
|
2008-06-06 02:20:16 +04:00
|
|
|
// Get a path from the environment.
|
|
|
|
std::vector<std::string> tmp;
|
|
|
|
cmSystemTools::GetPath(tmp, variable);
|
|
|
|
this->AddPrefixPaths(tmp, EnvPath);
|
2006-03-30 20:55:19 +04:00
|
|
|
}
|
|
|
|
|
2008-06-06 02:20:16 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmFindBase::AddCMakeEnvironmentPath()
|
|
|
|
{
|
2008-06-09 19:58:29 +04:00
|
|
|
if(!this->NoCMakeEnvironmentPath && !this->NoDefaultPath)
|
2006-02-28 00:38:22 +03:00
|
|
|
{
|
2008-06-06 02:20:16 +04:00
|
|
|
// Add CMAKE_*_PATH environment variables
|
|
|
|
std::string var = "CMAKE_";
|
|
|
|
var += this->CMakePathName;
|
|
|
|
var += "_PATH";
|
|
|
|
this->AddEnvPrefixPath("CMAKE_PREFIX_PATH");
|
|
|
|
this->AddEnvPath(var.c_str());
|
2008-06-09 19:58:29 +04:00
|
|
|
|
|
|
|
if(this->CMakePathName == "PROGRAM")
|
|
|
|
{
|
|
|
|
this->AddEnvPath("CMAKE_APPBUNDLE_PATH");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->AddEnvPath("CMAKE_FRAMEWORK_PATH");
|
|
|
|
}
|
2006-02-28 00:38:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-06 02:20:16 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmFindBase::AddCMakeVariablePath()
|
|
|
|
{
|
2008-06-09 19:58:29 +04:00
|
|
|
if(!this->NoCMakePath && !this->NoDefaultPath)
|
2007-12-19 18:34:43 +03:00
|
|
|
{
|
2008-06-06 02:20:16 +04:00
|
|
|
// Add CMake varibles of the same name as the previous environment
|
|
|
|
// varibles CMAKE_*_PATH to be used most of the time with -D
|
|
|
|
// command line options
|
|
|
|
std::string var = "CMAKE_";
|
|
|
|
var += this->CMakePathName;
|
|
|
|
var += "_PATH";
|
|
|
|
this->AddCMakePrefixPath("CMAKE_PREFIX_PATH");
|
|
|
|
this->AddCMakePath(var.c_str());
|
2008-06-09 19:58:29 +04:00
|
|
|
|
|
|
|
if(this->CMakePathName == "PROGRAM")
|
|
|
|
{
|
|
|
|
this->AddCMakePath("CMAKE_APPBUNDLE_PATH");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->AddCMakePath("CMAKE_FRAMEWORK_PATH");
|
|
|
|
}
|
2007-12-19 18:34:43 +03:00
|
|
|
}
|
2006-02-28 00:38:22 +03:00
|
|
|
}
|
|
|
|
|
2008-06-06 02:20:16 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmFindBase::AddSystemEnvironmentPath()
|
2006-02-28 00:38:22 +03:00
|
|
|
{
|
2008-06-09 19:58:29 +04:00
|
|
|
if(!this->NoSystemEnvironmentPath && !this->NoDefaultPath)
|
2008-05-27 22:47:46 +04:00
|
|
|
{
|
2008-06-06 02:20:16 +04:00
|
|
|
// Add LIB or INCLUDE
|
|
|
|
if(!this->EnvironmentPath.empty())
|
2008-05-27 22:47:46 +04:00
|
|
|
{
|
2008-06-06 02:20:16 +04:00
|
|
|
this->AddEnvPath(this->EnvironmentPath.c_str());
|
2008-05-27 22:47:46 +04:00
|
|
|
}
|
2008-06-06 02:20:16 +04:00
|
|
|
// Add PATH
|
|
|
|
this->AddEnvPath(0);
|
2008-05-27 22:47:46 +04:00
|
|
|
}
|
2008-06-06 02:20:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmFindBase::AddCMakeSystemVariablePath()
|
|
|
|
{
|
2008-06-09 19:58:29 +04:00
|
|
|
if(!this->NoCMakeSystemPath && !this->NoDefaultPath)
|
2006-02-28 00:38:22 +03:00
|
|
|
{
|
2008-06-06 02:20:16 +04:00
|
|
|
std::string var = "CMAKE_SYSTEM_";
|
|
|
|
var += this->CMakePathName;
|
|
|
|
var += "_PATH";
|
|
|
|
this->AddCMakePrefixPath("CMAKE_SYSTEM_PREFIX_PATH");
|
|
|
|
this->AddCMakePath(var.c_str());
|
2008-06-09 19:58:29 +04:00
|
|
|
|
|
|
|
if(this->CMakePathName == "PROGRAM")
|
|
|
|
{
|
|
|
|
this->AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH");
|
|
|
|
}
|
2006-02-28 00:38:22 +03:00
|
|
|
}
|
2008-06-06 02:20:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2008-06-09 23:08:59 +04:00
|
|
|
void cmFindBase::AddUserHintsPath()
|
|
|
|
{
|
|
|
|
this->AddPathsInternal(this->UserHints, CMakePath);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmFindBase::AddUserGuessPath()
|
|
|
|
{
|
|
|
|
this->AddPathsInternal(this->UserPaths, CMakePath);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2008-06-06 02:20:16 +04:00
|
|
|
void cmFindBase::AddPathSuffixes()
|
|
|
|
{
|
|
|
|
std::vector<std::string>& paths = this->SearchPaths;
|
|
|
|
std::vector<std::string> finalPath = paths;
|
|
|
|
std::vector<std::string>::iterator i;
|
2006-12-28 23:31:47 +03:00
|
|
|
// clear the path
|
|
|
|
paths.clear();
|
|
|
|
// convert all paths to unix slashes and add search path suffixes
|
|
|
|
// if there are any
|
2006-02-28 00:38:22 +03:00
|
|
|
for(i = finalPath.begin();
|
|
|
|
i != finalPath.end(); ++i)
|
|
|
|
{
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(*i);
|
|
|
|
// copy each finalPath combined with SearchPathSuffixes
|
|
|
|
// to the SearchPaths ivar
|
2006-05-10 23:46:45 +04:00
|
|
|
for(std::vector<std::string>::iterator j =
|
|
|
|
this->SearchPathSuffixes.begin();
|
2006-02-28 00:38:22 +03:00
|
|
|
j != this->SearchPathSuffixes.end(); ++j)
|
|
|
|
{
|
2008-04-07 06:19:06 +04:00
|
|
|
// if *i is only / then do not add a //
|
|
|
|
// this will get incorrectly considered a network
|
|
|
|
// path on windows and cause huge delays.
|
|
|
|
std::string p = *i;
|
|
|
|
if(p.size() && p[p.size()-1] != '/')
|
|
|
|
{
|
|
|
|
p += std::string("/");
|
|
|
|
}
|
|
|
|
p += *j;
|
2006-11-11 22:06:38 +03:00
|
|
|
// add to all paths because the search path may be modified
|
|
|
|
// later with lib being replaced for lib64 which may exist
|
2006-12-28 23:31:47 +03:00
|
|
|
paths.push_back(p);
|
2006-02-28 00:38:22 +03:00
|
|
|
}
|
2008-10-13 17:58:22 +04:00
|
|
|
// now put the path without the path suffixes in the SearchPaths
|
2006-12-28 23:31:47 +03:00
|
|
|
paths.push_back(*i);
|
2006-02-28 00:38:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmFindBase::PrintFindStuff()
|
|
|
|
{
|
2006-03-29 22:33:49 +04:00
|
|
|
std::cerr << "SearchFrameworkLast: " << this->SearchFrameworkLast << "\n";
|
|
|
|
std::cerr << "SearchFrameworkOnly: " << this->SearchFrameworkOnly << "\n";
|
|
|
|
std::cerr << "SearchFrameworkFirst: " << this->SearchFrameworkFirst << "\n";
|
2006-04-13 19:00:52 +04:00
|
|
|
std::cerr << "SearchAppBundleLast: " << this->SearchAppBundleLast << "\n";
|
|
|
|
std::cerr << "SearchAppBundleOnly: " << this->SearchAppBundleOnly << "\n";
|
|
|
|
std::cerr << "SearchAppBundleFirst: " << this->SearchAppBundleFirst << "\n";
|
2006-02-28 00:38:22 +03:00
|
|
|
std::cerr << "VariableName " << this->VariableName << "\n";
|
2006-05-10 23:46:45 +04:00
|
|
|
std::cerr << "VariableDocumentation "
|
|
|
|
<< this->VariableDocumentation << "\n";
|
2006-03-17 01:49:16 +03:00
|
|
|
std::cerr << "NoDefaultPath " << this->NoDefaultPath << "\n";
|
2006-05-10 23:46:45 +04:00
|
|
|
std::cerr << "NoCMakeEnvironmentPath "
|
|
|
|
<< this->NoCMakeEnvironmentPath << "\n";
|
2006-03-24 22:16:31 +03:00
|
|
|
std::cerr << "NoCMakePath " << this->NoCMakePath << "\n";
|
2006-05-10 23:46:45 +04:00
|
|
|
std::cerr << "NoSystemEnvironmentPath "
|
|
|
|
<< this->NoSystemEnvironmentPath << "\n";
|
2006-03-24 22:16:31 +03:00
|
|
|
std::cerr << "NoCMakeSystemPath " << this->NoCMakeSystemPath << "\n";
|
2006-02-28 00:38:22 +03:00
|
|
|
std::cerr << "EnvironmentPath " << this->EnvironmentPath << "\n";
|
|
|
|
std::cerr << "CMakePathName " << this->CMakePathName << "\n";
|
|
|
|
std::cerr << "Names ";
|
|
|
|
for(unsigned int i =0; i < this->Names.size(); ++i)
|
|
|
|
{
|
|
|
|
std::cerr << this->Names[i] << " ";
|
|
|
|
}
|
|
|
|
std::cerr << "\n";
|
|
|
|
std::cerr << "\n";
|
|
|
|
std::cerr << "SearchPathSuffixes ";
|
|
|
|
for(unsigned int i =0; i < this->SearchPathSuffixes.size(); ++i)
|
|
|
|
{
|
|
|
|
std::cerr << this->SearchPathSuffixes[i] << "\n";
|
|
|
|
}
|
|
|
|
std::cerr << "\n";
|
|
|
|
std::cerr << "SearchPaths\n";
|
|
|
|
for(unsigned int i =0; i < this->SearchPaths.size(); ++i)
|
|
|
|
{
|
|
|
|
std::cerr << "[" << this->SearchPaths[i] << "]\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmFindBase::CheckForVariableInCache()
|
|
|
|
{
|
2006-07-18 23:21:26 +04:00
|
|
|
if(const char* cacheValue =
|
|
|
|
this->Makefile->GetDefinition(this->VariableName.c_str()))
|
2006-02-28 00:38:22 +03:00
|
|
|
{
|
2006-07-18 23:21:26 +04:00
|
|
|
cmCacheManager::CacheIterator it =
|
2006-05-10 23:46:45 +04:00
|
|
|
this->Makefile->GetCacheManager()->
|
|
|
|
GetCacheIterator(this->VariableName.c_str());
|
2006-07-18 23:21:26 +04:00
|
|
|
bool found = !cmSystemTools::IsNOTFOUND(cacheValue);
|
|
|
|
bool cached = !it.IsAtEnd();
|
|
|
|
if(found)
|
|
|
|
{
|
|
|
|
// If the user specifies the entry on the command line without a
|
|
|
|
// type we should add the type and docstring but keep the
|
|
|
|
// original value. Tell the subclass implementations to do
|
|
|
|
// this.
|
|
|
|
if(cached && it.GetType() == cmCacheManager::UNINITIALIZED)
|
|
|
|
{
|
|
|
|
this->AlreadyInCacheWithoutMetaInfo = true;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(cached)
|
2006-02-28 00:38:22 +03:00
|
|
|
{
|
|
|
|
const char* hs = it.GetProperty("HELPSTRING");
|
|
|
|
this->VariableDocumentation = hs?hs:"(none)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|