diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-04-13 12:46:57 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2013-06-07 11:32:52 (GMT) |
commit | de4da665d3205afa239749c41513a315c3831f51 (patch) | |
tree | 02ab204c77efc1a89b620b38c118913c06c125f8 /Source/cmFindCommon.cxx | |
parent | bb879bcf2dd8a65eeb285ef67aa72c16aab01938 (diff) | |
download | CMake-de4da665d3205afa239749c41513a315c3831f51.zip CMake-de4da665d3205afa239749c41513a315c3831f51.tar.gz CMake-de4da665d3205afa239749c41513a315c3831f51.tar.bz2 |
Use --sysroot when cross compiling.
As CMAKE_ROOT_FIND_PATH can be a list, a new CMAKE_SYSROOT is
introduced, which is never a list.
The contents of this variable is passed to supporting compilers
as --sysroot. It is also accounted for when processing implicit
link directories reported by the compiler, and when generating
RPATH information.
Diffstat (limited to 'Source/cmFindCommon.cxx')
-rw-r--r-- | Source/cmFindCommon.cxx | 24 |
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) { |