mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-06 22:30:07 -05:00
Merge topic 'refactor-folder-name-retrieval'
3b6f1587 Factor IDE folder name retrieval out into helper method
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 += "/";
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 += "/";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user