diff options
author | Gregor Jasny <gjasny@googlemail.com> | 2016-08-30 18:55:37 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-10-17 14:06:18 (GMT) |
commit | 3b6f1587bed536e3d31e6665aff35aa27f5e79bc (patch) | |
tree | 5d53fe3704701d69e84bb13205cde5fcf3bdab5b /Source | |
parent | 5ebba228823ffc96e82f4b6cc1103c2f2ed8cfa7 (diff) | |
download | CMake-3b6f1587bed536e3d31e6665aff35aa27f5e79bc.zip CMake-3b6f1587bed536e3d31e6665aff35aa27f5e79bc.tar.gz CMake-3b6f1587bed536e3d31e6665aff35aa27f5e79bc.tar.bz2 |
Factor IDE folder name retrieval out into helper method
Add a `cmGeneratorTarget::GetEffectiveFolderName` helper to abstract
lookup of the `FOLDER` property in combination with checking for
generator support of folders.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 16 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 3 | ||||
-rw-r--r-- | Source/cmGhsMultiTargetGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.h | 3 | ||||
-rw-r--r-- | Source/cmGlobalGhsMultiGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio7Generator.cxx | 4 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 4 |
8 files changed, 28 insertions, 14 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 7eb0ebf..f11149a 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1767,6 +1767,22 @@ std::string cmGeneratorTarget::GetMacContentDirectory( return fpath; } +std::string cmGeneratorTarget::GetEffectiveFolderName() const +{ + std::string effectiveFolder; + + if (!this->GlobalGenerator->UseFolderProperty()) { + return effectiveFolder; + } + + const char* targetFolder = this->GetProperty("FOLDER"); + if (targetFolder) { + effectiveFolder += targetFolder; + } + + return effectiveFolder; +} + cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 68ffd5c..9382726 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -220,6 +220,9 @@ public: std::string GetMacContentDirectory(const std::string& config = CM_NULLPTR, bool implib = false) const; + /** @return folder prefix for IDEs. */ + std::string GetEffectiveFolderName() const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 5fbaea4..3154f8d 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -44,9 +44,7 @@ cmGhsMultiTargetGenerator::~cmGhsMultiTargetGenerator() std::string cmGhsMultiTargetGenerator::GetRelBuildFilePath( const cmGeneratorTarget* target) { - std::string output; - char const* folderProp = target->GetProperty("FOLDER"); - output = NULL == folderProp ? "" : folderProp; + std::string output = target->GetEffectiveFolderName(); cmSystemTools::ConvertToUnixSlashes(output); if (!output.empty()) { output += "/"; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 1aa6af1..7d0c2da 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2377,7 +2377,7 @@ const char* cmGlobalGenerator::GetPredefinedTargetsFolder() return "CMakePredefinedTargets"; } -bool cmGlobalGenerator::UseFolderProperty() +bool cmGlobalGenerator::UseFolderProperty() const { const char* prop = this->GetCMakeInstance()->GetState()->GetGlobalProperty("USE_FOLDERS"); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 38eaa76..c3498e0 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -334,6 +334,8 @@ public: i.e. "Can I build Debug and Release in the same tree?" */ virtual bool IsMultiConfig() const { return false; } + virtual bool UseFolderProperty() const; + std::string GetSharedLibFlagsForLanguage(std::string const& lang) const; /** Generate an <output>.rule file path for a given command output. */ @@ -463,7 +465,6 @@ protected: std::string const& name) const; const char* GetPredefinedTargetsFolder(); - virtual bool UseFolderProperty(); private: #if defined(CMAKE_BUILD_WITH_CMAKE) diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 0eac338..d4ae677 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -439,11 +439,7 @@ void cmGlobalGhsMultiGenerator::UpdateBuildFiles( tgtsI != tgts.end(); ++tgtsI) { const cmGeneratorTarget* tgt = *tgtsI; if (IsTgtForBuild(tgt)) { - char const* rawFolderName = tgt->GetProperty("FOLDER"); - if (NULL == rawFolderName) { - rawFolderName = ""; - } - std::string folderName(rawFolderName); + std::string folderName = tgt->GetEffectiveFolderName(); if (this->TargetFolderBuildStreams.end() == this->TargetFolderBuildStreams.find(folderName)) { this->AddFilesUpToPath( diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 3637fed..0287def 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -409,8 +409,8 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( // Create "solution folder" information from FOLDER target property // if (written && this->UseFolderProperty()) { - const char* targetFolder = target->GetProperty("FOLDER"); - if (targetFolder) { + const std::string targetFolder = target->GetEffectiveFolderName(); + if (!targetFolder.empty()) { std::vector<cmsys::String> tokens = cmSystemTools::SplitString(targetFolder, '/', false); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 0ddfc9a..7b1afa5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2723,8 +2723,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateOrGetPBXGroup( { std::string s; std::string target; - const char* targetFolder = gtgt->GetProperty("FOLDER"); - if (targetFolder) { + const std::string targetFolder = gtgt->GetEffectiveFolderName(); + if (!targetFolder.empty()) { target = targetFolder; target += "/"; } |