summaryrefslogtreecommitdiffstats
path: root/Source/cmExportFileGenerator.cxx
diff options
context:
space:
mode:
authorPavel Solodovnikov <hellyeahdominate@gmail.com>2018-01-31 15:20:02 (GMT)
committerPavel Solodovnikov <hellyeahdominate@gmail.com>2018-01-31 15:23:03 (GMT)
commit653b894683abe63233cb8679b34ea39d9017e317 (patch)
tree200e5066b754d8ddfdc7beb86c4db179aa2e69d0 /Source/cmExportFileGenerator.cxx
parent4499cc8bb65e217e1cb2959452ed391af82e757b (diff)
downloadCMake-653b894683abe63233cb8679b34ea39d9017e317.zip
CMake-653b894683abe63233cb8679b34ea39d9017e317.tar.gz
CMake-653b894683abe63233cb8679b34ea39d9017e317.tar.bz2
Reduce raw string pointers usage.
* Change some functions to take `std::string` instead of `const char*` in the following classes: `cmMakeFile`, `cmake`, `cmCoreTryCompile`, `cmSystemTools`, `cmState`, `cmLocalGenerator` and a few others. * Greatly reduce using of `const char*` overloads for `cmSystemTools::MakeDirectory` and `cmSystemTools::RelativePath`. * Remove many redundant `c_str()` conversions throughout the code.
Diffstat (limited to 'Source/cmExportFileGenerator.cxx')
-rw-r--r--Source/cmExportFileGenerator.cxx22
1 files changed, 12 insertions, 10 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 7985d0f..434abdc 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -183,7 +183,7 @@ bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty(
return false;
}
-static bool isSubDirectory(const char* a, const char* b)
+static bool isSubDirectory(std::string const& a, std::string const& b)
{
return (cmSystemTools::ComparePath(a, b) ||
cmSystemTools::IsSubDirectory(a, b));
@@ -195,13 +195,15 @@ static bool checkInterfaceDirs(const std::string& prepro,
{
const char* installDir =
target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
- const char* topSourceDir = target->GetLocalGenerator()->GetSourceDirectory();
- const char* topBinaryDir = target->GetLocalGenerator()->GetBinaryDirectory();
+ std::string const& topSourceDir =
+ target->GetLocalGenerator()->GetSourceDirectory();
+ std::string const& topBinaryDir =
+ target->GetLocalGenerator()->GetBinaryDirectory();
std::vector<std::string> parts;
cmGeneratorExpression::Split(prepro, parts);
- const bool inSourceBuild = strcmp(topSourceDir, topBinaryDir) == 0;
+ const bool inSourceBuild = topSourceDir == topBinaryDir;
bool hadFatalError = false;
@@ -231,10 +233,10 @@ static bool checkInterfaceDirs(const std::string& prepro,
hadFatalError = true;
}
}
- if (cmHasLiteralPrefix(li.c_str(), "${_IMPORT_PREFIX}")) {
+ if (cmHasLiteralPrefix(li, "${_IMPORT_PREFIX}")) {
continue;
}
- if (!cmSystemTools::FileIsFullPath(li.c_str())) {
+ if (!cmSystemTools::FileIsFullPath(li)) {
/* clang-format off */
e << "Target \"" << target->GetName() << "\" " << prop <<
" property contains relative path:\n"
@@ -242,9 +244,9 @@ static bool checkInterfaceDirs(const std::string& prepro,
/* clang-format on */
target->GetLocalGenerator()->IssueMessage(messageType, e.str());
}
- bool inBinary = isSubDirectory(li.c_str(), topBinaryDir);
- bool inSource = isSubDirectory(li.c_str(), topSourceDir);
- if (isSubDirectory(li.c_str(), installDir)) {
+ bool inBinary = isSubDirectory(li, topBinaryDir);
+ bool inSource = isSubDirectory(li, topSourceDir);
+ if (isSubDirectory(li, installDir)) {
// The include directory is inside the install tree. If the
// install tree is not inside the source tree or build tree then
// fall through to the checks below that the include directory is not
@@ -317,7 +319,7 @@ static void prefixItems(std::string& exportDirs)
for (std::string const& e : entries) {
exportDirs += sep;
sep = ";";
- if (!cmSystemTools::FileIsFullPath(e.c_str()) &&
+ if (!cmSystemTools::FileIsFullPath(e) &&
e.find("${_IMPORT_PREFIX}") == std::string::npos) {
exportDirs += "${_IMPORT_PREFIX}/";
}