diff options
author | Nils Gladitz <n.gladitz@abberior-instruments.com> | 2021-05-19 12:10:58 +0200 |
---|---|---|
committer | Craig Scott <craig.scott@crascit.com> | 2021-05-24 08:21:49 +1000 |
commit | 26e36111d326bbf69f437ef1335423ea3b2835e2 (patch) | |
tree | badbd556c99870e9729e9fdc84eb304d70d34876 /Source/CPack/cmCPackGenerator.cxx | |
parent | d98a7cdb25611ed6f1e856fd4c4ff980225b89cd (diff) | |
download | cmake-26e36111d326bbf69f437ef1335423ea3b2835e2.tar.gz |
CPack: Implement new variable CPACK_CUSTOM_INSTALL_VARIABLES
The new variable allows projects to define custom key=value pairs of
variables to be set in CPack cmake_install.cmake script invocations.
This allows install(SCRIPT|CODE) to be parameterized at runtime.
Diffstat (limited to 'Source/CPack/cmCPackGenerator.cxx')
-rw-r--r-- | Source/CPack/cmCPackGenerator.cxx | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index cd2adaa304..00e274d6d0 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -902,6 +902,23 @@ int cmCPackGenerator::InstallCMakeProject( this->IsOn("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")) { mf.AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION", "1"); } + + std::vector<std::string> custom_variables; + this->MakefileMap->GetDefExpandList("CPACK_CUSTOM_INSTALL_VARIABLES", + custom_variables); + + for (auto const& custom_variable : custom_variables) { + std::string value; + + auto i = custom_variable.find('='); + + if (i != std::string::npos) { + value = custom_variable.substr(i + 1); + } + + mf.AddDefinition(custom_variable.substr(0, i), value); + } + // do installation bool res = mf.ReadListFile(installFile); // forward definition of CMAKE_ABSOLUTE_DESTINATION_FILES |