summaryrefslogtreecommitdiffstats
path: root/Source/CPack
diff options
context:
space:
mode:
authorVitaly Stakhovsky <vvs31415@gitlab.org>2020-08-01 19:00:00 (GMT)
committerVitaly Stakhovsky <vvs31415@gitlab.org>2020-09-02 11:27:32 (GMT)
commit11425041f04fd0945480b8f9e9933d1549b93981 (patch)
tree9cafffd6774513f686440b31795cbb3b5e38b65c /Source/CPack
parent99b21e58e020fedc6d09a619c1a8dc2e9ea7e2c5 (diff)
downloadCMake-11425041f04fd0945480b8f9e9933d1549b93981.zip
CMake-11425041f04fd0945480b8f9e9933d1549b93981.tar.gz
CMake-11425041f04fd0945480b8f9e9933d1549b93981.tar.bz2
cmMakefile::GetDefinition: return cmProp
Diffstat (limited to 'Source/CPack')
-rw-r--r--Source/CPack/cmCPackGenerator.cxx31
-rw-r--r--Source/CPack/cpack.cxx31
2 files changed, 33 insertions, 29 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index 3880f65..a9fe91c 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -20,6 +20,7 @@
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
+#include "cmProperty.h"
#include "cmState.h"
#include "cmStateSnapshot.h"
#include "cmStringAlgorithms.h"
@@ -905,8 +906,8 @@ int cmCPackGenerator::InstallCMakeProject(
// forward definition of CMAKE_ABSOLUTE_DESTINATION_FILES
// to CPack (may be used by generators like CPack RPM or DEB)
// in order to transparently handle ABSOLUTE PATH
- if (const char* def = mf.GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")) {
- mf.AddDefinition("CPACK_ABSOLUTE_DESTINATION_FILES", def);
+ if (cmProp def = mf.GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")) {
+ mf.AddDefinition("CPACK_ABSOLUTE_DESTINATION_FILES", *def);
}
// Now rebuild the list of files after installation
@@ -939,11 +940,11 @@ int cmCPackGenerator::InstallCMakeProject(
}
}
- if (auto d = mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) {
+ if (cmProp d = mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) {
if (!absoluteDestFiles.empty()) {
absoluteDestFiles += ";";
}
- absoluteDestFiles += d;
+ absoluteDestFiles += *d;
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"Got some ABSOLUTE DESTINATION FILES: " << absoluteDestFiles
<< std::endl);
@@ -954,12 +955,13 @@ int cmCPackGenerator::InstallCMakeProject(
GetComponentInstallDirNameSuffix(component);
if (nullptr != this->GetOption(absoluteDestFileComponent)) {
std::string absoluteDestFilesListComponent =
- cmStrCat(this->GetOption(absoluteDestFileComponent), ';', d);
+ cmStrCat(this->GetOption(absoluteDestFileComponent), ';', *d);
this->SetOption(absoluteDestFileComponent,
absoluteDestFilesListComponent.c_str());
} else {
- this->SetOption(absoluteDestFileComponent,
- mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"));
+ this->SetOption(
+ absoluteDestFileComponent,
+ cmToCStr(mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")));
}
}
}
@@ -982,7 +984,7 @@ bool cmCPackGenerator::ReadListFile(const char* moduleName)
void cmCPackGenerator::SetOptionIfNotSet(const std::string& op,
const char* value)
{
- const char* def = this->MakefileMap->GetDefinition(op);
+ cmProp def = this->MakefileMap->GetDefinition(op);
if (cmNonempty(def)) {
return;
}
@@ -1214,30 +1216,31 @@ bool cmCPackGenerator::IsOn(const std::string& name) const
bool cmCPackGenerator::IsSetToOff(const std::string& op) const
{
- const char* ret = this->MakefileMap->GetDefinition(op);
+ cmProp ret = this->MakefileMap->GetDefinition(op);
if (cmNonempty(ret)) {
- return cmIsOff(ret);
+ return cmIsOff(*ret);
}
return false;
}
bool cmCPackGenerator::IsSetToEmpty(const std::string& op) const
{
- const char* ret = this->MakefileMap->GetDefinition(op);
+ cmProp ret = this->MakefileMap->GetDefinition(op);
if (ret) {
- return !*ret;
+ return ret->empty();
}
return false;
}
const char* cmCPackGenerator::GetOption(const std::string& op) const
{
- const char* ret = this->MakefileMap->GetDefinition(op);
+ cmProp ret = this->MakefileMap->GetDefinition(op);
if (!ret) {
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"Warning, GetOption return NULL for: " << op << std::endl);
+ return nullptr;
}
- return ret;
+ return ret->c_str();
}
std::vector<std::string> cmCPackGenerator::GetOptions() const
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index 3a400b7..6c80753 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -12,6 +12,7 @@
#include "cmDocumentationFormatter.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
+#include "cmProperty.h"
#include "cmState.h"
#include "cmStateSnapshot.h"
#include "cmStringAlgorithms.h"
@@ -324,21 +325,22 @@ int main(int argc, char const* const* argv)
}
// Force CPACK_PACKAGE_DIRECTORY as absolute path
- cpackProjectDirectory = globalMF.GetDefinition("CPACK_PACKAGE_DIRECTORY");
+ cpackProjectDirectory =
+ globalMF.GetSafeDefinition("CPACK_PACKAGE_DIRECTORY");
cpackProjectDirectory =
cmSystemTools::CollapseFullPath(cpackProjectDirectory);
globalMF.AddDefinition("CPACK_PACKAGE_DIRECTORY", cpackProjectDirectory);
- const char* cpackModulesPath = globalMF.GetDefinition("CPACK_MODULE_PATH");
+ cmProp cpackModulesPath = globalMF.GetDefinition("CPACK_MODULE_PATH");
if (cpackModulesPath) {
- globalMF.AddDefinition("CMAKE_MODULE_PATH", cpackModulesPath);
+ globalMF.AddDefinition("CMAKE_MODULE_PATH", *cpackModulesPath);
}
- const char* genList = globalMF.GetDefinition("CPACK_GENERATOR");
+ cmProp genList = globalMF.GetDefinition("CPACK_GENERATOR");
if (!genList) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"CPack generator not specified" << std::endl);
} else {
- std::vector<std::string> generatorsVector = cmExpandedList(genList);
+ std::vector<std::string> generatorsVector = cmExpandedList(*genList);
for (std::string const& gen : generatorsVector) {
cmMakefile::ScopePushPop raii(&globalMF);
cmMakefile* mf = &globalMF;
@@ -411,32 +413,31 @@ int main(int argc, char const* const* argv)
parsed = 0;
}
if (parsed) {
- const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
+ cmProp projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"Use generator: " << cpackGenerator->GetNameOfClass()
<< std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
- "For project: " << projName << std::endl);
+ "For project: " << *projName << std::endl);
- const char* projVersion =
- mf->GetDefinition("CPACK_PACKAGE_VERSION");
+ cmProp projVersion = mf->GetDefinition("CPACK_PACKAGE_VERSION");
if (!projVersion) {
- const char* projVersionMajor =
+ cmProp projVersionMajor =
mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
- const char* projVersionMinor =
+ cmProp projVersionMinor =
mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
- const char* projVersionPatch =
+ cmProp projVersionPatch =
mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
std::ostringstream ostr;
- ostr << projVersionMajor << "." << projVersionMinor << "."
- << projVersionPatch;
+ ostr << *projVersionMajor << "." << *projVersionMinor << "."
+ << *projVersionPatch;
mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str());
}
int res = cpackGenerator->DoPackage();
if (!res) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
- "Error when generating package: " << projName
+ "Error when generating package: " << *projName
<< std::endl);
return 1;
}