summaryrefslogtreecommitdiffstats
path: root/Source/cmFindCommon.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmFindCommon.cxx')
-rw-r--r--Source/cmFindCommon.cxx24
1 files changed, 20 insertions, 4 deletions
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx
index b44864e..5daa47d 100644
--- a/Source/cmFindCommon.cxx
+++ b/Source/cmFindCommon.cxx
@@ -62,10 +62,15 @@ void cmFindCommon::GenerateDocumentation()
"The CMake variable CMAKE_FIND_ROOT_PATH specifies one or more "
"directories to be prepended to all other search directories. "
"This effectively \"re-roots\" the entire search under given locations. "
- "By default it is empty. It is especially useful when "
+ "By default it is empty. "
+ "The variable CMAKE_SYSROOT can also be used to specify exactly one "
+ "directory to use as a prefix. Setting CMAKE_SYSROOT also has other "
+ "effects. See the documentation for that variable for more. "
+ "These are especially useful when "
"cross-compiling to point to the root directory of the "
"target environment and CMake will search there too. By default at first "
- "the directories listed in CMAKE_FIND_ROOT_PATH and then the non-rooted "
+ "the CMAKE_SYSROOT directory is searched, then the directories listed in "
+ "CMAKE_FIND_ROOT_PATH and then the non-rooted "
"directories will be searched. "
"The default behavior can be adjusted by setting "
"CMAKE_FIND_ROOT_PATH_MODE_XXX. This behavior can be manually "
@@ -187,16 +192,27 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
{
return;
}
+ const char* sysroot =
+ this->Makefile->GetDefinition("CMAKE_SYSROOT");
const char* rootPath =
this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH");
- if((rootPath == 0) || (strlen(rootPath) == 0))
+ const bool noSysroot = !sysroot || !*sysroot;
+ const bool noRootPath = !rootPath || !*rootPath;
+ if(noSysroot && noRootPath)
{
return;
}
// Construct the list of path roots with no trailing slashes.
std::vector<std::string> roots;
- cmSystemTools::ExpandListArgument(rootPath, roots);
+ if (sysroot)
+ {
+ roots.push_back(sysroot);
+ }
+ if (rootPath)
+ {
+ cmSystemTools::ExpandListArgument(rootPath, roots);
+ }
for(std::vector<std::string>::iterator ri = roots.begin();
ri != roots.end(); ++ri)
{