diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2023-02-24 15:17:45 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2023-02-24 15:17:45 (GMT) |
commit | 18e02ace5b2c2318252acea5f53062ef8bd0e3c6 (patch) | |
tree | 2fd11fc551fa2e1da1a21f11ba20cdc73f22e27b /Source | |
parent | 35ca2d524befc71b840808cce4e0a773ef722b71 (diff) | |
download | CMake-18e02ace5b2c2318252acea5f53062ef8bd0e3c6.zip CMake-18e02ace5b2c2318252acea5f53062ef8bd0e3c6.tar.gz CMake-18e02ace5b2c2318252acea5f53062ef8bd0e3c6.tar.bz2 |
install(CODE|SCRIPT): Support $<INSTALL_PREFIX> genex
Fixes: #24534
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmInstallCommand.cxx | 16 | ||||
-rw-r--r-- | Source/cmInstallScriptGenerator.cxx | 10 |
2 files changed, 14 insertions, 12 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 82adca8..56c8b26 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -359,13 +359,15 @@ bool HandleScriptMode(std::vector<std::string> const& args, } else if (doing_script) { doing_script = false; std::string script = arg; - if (!cmSystemTools::FileIsFullPath(script)) { - script = - cmStrCat(helper.Makefile->GetCurrentSourceDirectory(), '/', arg); - } - if (cmSystemTools::FileIsDirectory(script)) { - status.SetError("given a directory as value of SCRIPT argument."); - return false; + if (!cmHasLiteralPrefix(script, "$<INSTALL_PREFIX>")) { + if (!cmSystemTools::FileIsFullPath(script)) { + script = + cmStrCat(helper.Makefile->GetCurrentSourceDirectory(), '/', arg); + } + if (cmSystemTools::FileIsDirectory(script)) { + status.SetError("given a directory as value of SCRIPT argument."); + return false; + } } helper.Makefile->AddInstallGenerator( cm::make_unique<cmInstallScriptGenerator>( diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx index a5625fe..af531f2 100644 --- a/Source/cmInstallScriptGenerator.cxx +++ b/Source/cmInstallScriptGenerator.cxx @@ -56,12 +56,12 @@ bool cmInstallScriptGenerator::Compute(cmLocalGenerator* lg) std::string cmInstallScriptGenerator::GetScript( std::string const& config) const { - std::string script; + std::string script = this->Script; if (this->AllowGenex && this->ActionsPerConfig) { - script = cmGeneratorExpression::Evaluate(this->Script, - this->LocalGenerator, config); - } else { - script = this->Script; + cmGeneratorExpression::ReplaceInstallPrefix(script, + "${CMAKE_INSTALL_PREFIX}"); + script = + cmGeneratorExpression::Evaluate(script, this->LocalGenerator, config); } return script; } |