summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-11-19 17:41:57 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2013-11-19 17:41:57 (GMT)
commit46ec48c93d2d84cf79c8704c370e24d47a7536a5 (patch)
tree83dae82226242d9f31dfc8f77edf791d34cc65b4 /Source
parent1da77bf1ee4f3ba315ebb00da2eaeac474614cad (diff)
parent7cd65c97fabd9f3249739a81dd1260a1e0b59ee1 (diff)
downloadCMake-46ec48c93d2d84cf79c8704c370e24d47a7536a5.zip
CMake-46ec48c93d2d84cf79c8704c370e24d47a7536a5.tar.gz
CMake-46ec48c93d2d84cf79c8704c370e24d47a7536a5.tar.bz2
Merge topic 'cross-compiling-toolchain-variables'
7cd65c9 Add CMAKE_SYSROOT variable to set --sysroot when cross compiling. 5096967 Allow toolchain files to specify an external toolchain. 76552d5 Add compiler target compile options. f41ecd1 CMakeDetermineCompilerId: Look for internal file only on host
Diffstat (limited to 'Source')
-rw-r--r--Source/cmComputeLinkInformation.cxx20
-rw-r--r--Source/cmCoreTryCompile.cxx35
-rw-r--r--Source/cmFindCommon.cxx15
-rw-r--r--Source/cmLocalGenerator.cxx51
4 files changed, 114 insertions, 7 deletions
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index d4644c3..3152c2a 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -1901,6 +1901,8 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
}
if(use_build_rpath || use_link_rpath)
{
+ std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT");
+ cmSystemTools::ConvertToUnixSlashes(rootPath);
std::vector<std::string> const& rdirs = this->GetRuntimeSearchPath();
for(std::vector<std::string>::const_iterator ri = rdirs.begin();
ri != rdirs.end(); ++ri)
@@ -1909,9 +1911,14 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
// support or if using the link path as an rpath.
if(use_build_rpath)
{
- if(emitted.insert(*ri).second)
+ std::string d = *ri;
+ if (!rootPath.empty() && d.find(rootPath) == 0)
{
- runtimeDirs.push_back(*ri);
+ d = d.substr(rootPath.size());
+ }
+ if(emitted.insert(d).second)
+ {
+ runtimeDirs.push_back(d);
}
}
else if(use_link_rpath)
@@ -1924,9 +1931,14 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
!cmSystemTools::IsSubDirectory(ri->c_str(), topSourceDir) &&
!cmSystemTools::IsSubDirectory(ri->c_str(), topBinaryDir))
{
- if(emitted.insert(*ri).second)
+ std::string d = *ri;
+ if (!rootPath.empty() && d.find(rootPath) == 0)
+ {
+ d = d.substr(rootPath.size());
+ }
+ if(emitted.insert(d).second)
{
- runtimeDirs.push_back(*ri);
+ runtimeDirs.push_back(d);
}
}
}
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 479a699..bbfc427 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -405,6 +405,41 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
flag += this->Makefile->GetSafeDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
cmakeFlags.push_back(flag);
}
+ if (const char *cxxDef
+ = this->Makefile->GetDefinition("CMAKE_CXX_COMPILER_TARGET"))
+ {
+ std::string flag="-DCMAKE_CXX_COMPILER_TARGET=";
+ flag += cxxDef;
+ cmakeFlags.push_back(flag);
+ }
+ if (const char *cDef
+ = this->Makefile->GetDefinition("CMAKE_C_COMPILER_TARGET"))
+ {
+ std::string flag="-DCMAKE_C_COMPILER_TARGET=";
+ flag += cDef;
+ cmakeFlags.push_back(flag);
+ }
+ if (const char *tcxxDef = this->Makefile->GetDefinition(
+ "CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN"))
+ {
+ std::string flag="-DCMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=";
+ flag += tcxxDef;
+ cmakeFlags.push_back(flag);
+ }
+ if (const char *tcDef = this->Makefile->GetDefinition(
+ "CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN"))
+ {
+ std::string flag="-DCMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=";
+ flag += tcDef;
+ cmakeFlags.push_back(flag);
+ }
+ if (const char *rootDef
+ = this->Makefile->GetDefinition("CMAKE_SYSROOT"))
+ {
+ std::string flag="-DCMAKE_SYSROOT=";
+ flag += rootDef;
+ cmakeFlags.push_back(flag);
+ }
if(this->Makefile->GetDefinition("CMAKE_POSITION_INDEPENDENT_CODE")!=0)
{
fprintf(fout, "set(CMAKE_POSITION_INDEPENDENT_CODE \"ON\")\n");
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx
index 7beeda0..8c42811 100644
--- a/Source/cmFindCommon.cxx
+++ b/Source/cmFindCommon.cxx
@@ -138,16 +138,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 (rootPath)
+ {
+ cmSystemTools::ExpandListArgument(rootPath, roots);
+ }
+ if (sysroot)
+ {
+ roots.push_back(sysroot);
+ }
for(std::vector<std::string>::iterator ri = roots.begin();
ri != roots.end(); ++ri)
{
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 63ec576..d2784a9 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1043,11 +1043,38 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
// If this is the compiler then look for the extra variable
// _COMPILER_ARG1 which must be the first argument to the compiler
const char* compilerArg1 = 0;
+ const char* compilerTarget = 0;
+ const char* compilerOptionTarget = 0;
+ const char* compilerExternalToolchain = 0;
+ const char* compilerOptionExternalToolchain = 0;
+ const char* compilerSysroot = 0;
+ const char* compilerOptionSysroot = 0;
if(actualReplace == "CMAKE_${LANG}_COMPILER")
{
std::string arg1 = actualReplace + "_ARG1";
cmSystemTools::ReplaceString(arg1, "${LANG}", lang);
compilerArg1 = this->Makefile->GetDefinition(arg1.c_str());
+ compilerTarget
+ = this->Makefile->GetDefinition(
+ (std::string("CMAKE_") + lang + "_COMPILER_TARGET").c_str());
+ compilerOptionTarget
+ = this->Makefile->GetDefinition(
+ (std::string("CMAKE_") + lang +
+ "_COMPILE_OPTIONS_TARGET").c_str());
+ compilerExternalToolchain
+ = this->Makefile->GetDefinition(
+ (std::string("CMAKE_") + lang +
+ "_COMPILER_EXTERNAL_TOOLCHAIN").c_str());
+ compilerOptionExternalToolchain
+ = this->Makefile->GetDefinition(
+ (std::string("CMAKE_") + lang +
+ "_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN").c_str());
+ compilerSysroot
+ = this->Makefile->GetDefinition("CMAKE_SYSROOT");
+ compilerOptionSysroot
+ = this->Makefile->GetDefinition(
+ (std::string("CMAKE_") + lang +
+ "_COMPILE_OPTIONS_SYSROOT").c_str());
}
if(actualReplace.find("${LANG}") != actualReplace.npos)
{
@@ -1068,6 +1095,24 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
ret += " ";
ret += compilerArg1;
}
+ if (compilerTarget && compilerOptionTarget)
+ {
+ ret += " ";
+ ret += compilerOptionTarget;
+ ret += compilerTarget;
+ }
+ if (compilerExternalToolchain && compilerOptionExternalToolchain)
+ {
+ ret += " ";
+ ret += compilerOptionExternalToolchain;
+ ret += this->EscapeForShell(compilerExternalToolchain, true);
+ }
+ if (compilerSysroot && compilerOptionSysroot)
+ {
+ ret += " ";
+ ret += compilerOptionSysroot;
+ ret += this->EscapeForShell(compilerSysroot, true);
+ }
return ret;
}
return replace;
@@ -1462,6 +1507,8 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
return;
}
+ std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT");
+
std::vector<std::string> implicitDirs;
// Load implicit include directories for this language.
std::string impDirVar = "CMAKE_";
@@ -1474,7 +1521,9 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
for(std::vector<std::string>::const_iterator i = impDirVec.begin();
i != impDirVec.end(); ++i)
{
- emitted.insert(*i);
+ std::string d = rootPath + *i;
+ cmSystemTools::ConvertToUnixSlashes(d);
+ emitted.insert(d);
if (!stripImplicitInclDirs)
{
implicitDirs.push_back(*i);