diff options
author | Brad King <brad.king@kitware.com> | 2017-05-09 14:08:15 -0400 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-05-09 14:21:54 -0400 |
commit | 53e89b6ab0cae7b9ba0316b3806abd986794a22c (patch) | |
tree | 45529a1a882e354379d151e88132be00a7286c99 /Source/cmRulePlaceholderExpander.cxx | |
parent | b69e061b8073efbd2c356f4508ea401c85e8dae3 (diff) | |
download | cmake-53e89b6ab0cae7b9ba0316b3806abd986794a22c.tar.gz |
Add options for separate compile and link sysroots
Add `CMAKE_SYSROOT_COMPILE` and `CMAKE_SYSROOT_LINK` variables to as
operation-specific alternatives to `CMAKE_SYSROOT`. This will be useful
for Android NDKs that compile and link with different sysroot values
(e.g. `r14` with unified headers).
Co-Author: Florent Castelli <florent.castelli@gmail.com>
Diffstat (limited to 'Source/cmRulePlaceholderExpander.cxx')
-rw-r--r-- | Source/cmRulePlaceholderExpander.cxx | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx index f190a5c359..d5d2f6752e 100644 --- a/Source/cmRulePlaceholderExpander.cxx +++ b/Source/cmRulePlaceholderExpander.cxx @@ -12,10 +12,11 @@ cmRulePlaceholderExpander::cmRulePlaceholderExpander( std::map<std::string, std::string> const& compilers, std::map<std::string, std::string> const& variableMappings, - std::string const& compilerSysroot) + std::string const& compilerSysroot, std::string const& linkerSysroot) : Compilers(compilers) , VariableMappings(variableMappings) , CompilerSysroot(compilerSysroot) + , LinkerSysroot(linkerSysroot) { } @@ -249,10 +250,19 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable( ret += compilerOptionExternalToolchain; ret += outputConverter->EscapeForShell(compilerExternalToolchain, true); } - if (!this->CompilerSysroot.empty() && !compilerOptionSysroot.empty()) { + std::string sysroot; + // Some platforms may use separate sysroots for compiling and linking. + // If we detect link flags, then we pass the link sysroot instead. + // FIXME: Use a more robust way to detect link line expansion. + if (replaceValues.LinkFlags) { + sysroot = this->LinkerSysroot; + } else { + sysroot = this->CompilerSysroot; + } + if (!sysroot.empty() && !compilerOptionSysroot.empty()) { ret += " "; ret += compilerOptionSysroot; - ret += outputConverter->EscapeForShell(this->CompilerSysroot, true); + ret += outputConverter->EscapeForShell(sysroot, true); } return ret; } |