diff options
author | Brad King <brad.king@kitware.com> | 2014-07-31 13:17:35 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-07-31 13:17:35 (GMT) |
commit | 9f575a26fd7019114687104c719b20ef6d26b1fe (patch) | |
tree | 9e17ea0a31309c933c402d82515b43ca13a10133 /Source/cmGeneratorExpressionEvaluator.cxx | |
parent | 202b7d12eb0609f1a2dd7f587c0ed17d45bec1c5 (diff) | |
parent | f86850ef60b7dc008a144722bd0c803289a8ab76 (diff) | |
download | CMake-9f575a26fd7019114687104c719b20ef6d26b1fe.zip CMake-9f575a26fd7019114687104c719b20ef6d26b1fe.tar.gz CMake-9f575a26fd7019114687104c719b20ef6d26b1fe.tar.bz2 |
Merge topic 'pdb-genex'
f86850ef Genex: Implement generator expressions for target PDB files.
028ad318 Genex: Simplify filesytem artifact code
Diffstat (limited to 'Source/cmGeneratorExpressionEvaluator.cxx')
-rw-r--r-- | Source/cmGeneratorExpressionEvaluator.cxx | 125 |
1 files changed, 91 insertions, 34 deletions
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 7a53d65..35a9fcb 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -1523,7 +1523,17 @@ static const struct InstallPrefixNode : public cmGeneratorExpressionNode } installPrefixNode; //---------------------------------------------------------------------------- -template<bool linker, bool soname> +class ArtifactNameTag; +class ArtifactLinkerTag; +class ArtifactSonameTag; +class ArtifactPdbTag; + +class ArtifactPathTag; +class ArtifactDirTag; +class ArtifactNameTag; + +//---------------------------------------------------------------------------- +template<typename ArtifactT> struct TargetFilesystemArtifactResultCreator { static std::string Create(cmTarget* target, @@ -1533,7 +1543,7 @@ struct TargetFilesystemArtifactResultCreator //---------------------------------------------------------------------------- template<> -struct TargetFilesystemArtifactResultCreator<false, true> +struct TargetFilesystemArtifactResultCreator<ArtifactSonameTag> { static std::string Create(cmTarget* target, cmGeneratorExpressionContext *context, @@ -1563,7 +1573,45 @@ struct TargetFilesystemArtifactResultCreator<false, true> //---------------------------------------------------------------------------- template<> -struct TargetFilesystemArtifactResultCreator<true, false> +struct TargetFilesystemArtifactResultCreator<ArtifactPdbTag> +{ + static std::string Create(cmTarget* target, + cmGeneratorExpressionContext *context, + const GeneratorExpressionContent *content) + { + std::string language = target->GetLinkerLanguage(context->Config); + + std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB"; + + if(!context->Makefile->IsOn(pdbSupportVar)) + { + ::reportError(context, content->GetOriginalExpression(), + "TARGET_PDB_FILE is not supported by the target linker."); + return std::string(); + } + + cmTarget::TargetType targetType = target->GetType(); + + if(targetType != cmTarget::SHARED_LIBRARY && + targetType != cmTarget::MODULE_LIBRARY && + targetType != cmTarget::EXECUTABLE) + { + ::reportError(context, content->GetOriginalExpression(), + "TARGET_PDB_FILE is allowed only for " + "targets with linker created artifacts."); + return std::string(); + } + + std::string result = target->GetPDBDirectory(context->Config); + result += "/"; + result += target->GetPDBName(context->Config); + return result; + } +}; + +//---------------------------------------------------------------------------- +template<> +struct TargetFilesystemArtifactResultCreator<ArtifactLinkerTag> { static std::string Create(cmTarget* target, cmGeneratorExpressionContext *context, @@ -1584,7 +1632,7 @@ struct TargetFilesystemArtifactResultCreator<true, false> //---------------------------------------------------------------------------- template<> -struct TargetFilesystemArtifactResultCreator<false, false> +struct TargetFilesystemArtifactResultCreator<ArtifactNameTag> { static std::string Create(cmTarget* target, cmGeneratorExpressionContext *context, @@ -1596,7 +1644,7 @@ struct TargetFilesystemArtifactResultCreator<false, false> //---------------------------------------------------------------------------- -template<bool dirQual, bool nameQual> +template<typename ArtifactT> struct TargetFilesystemArtifactResultGetter { static std::string Get(const std::string &result); @@ -1604,7 +1652,7 @@ struct TargetFilesystemArtifactResultGetter //---------------------------------------------------------------------------- template<> -struct TargetFilesystemArtifactResultGetter<false, true> +struct TargetFilesystemArtifactResultGetter<ArtifactNameTag> { static std::string Get(const std::string &result) { return cmSystemTools::GetFilenameName(result); } @@ -1612,7 +1660,7 @@ struct TargetFilesystemArtifactResultGetter<false, true> //---------------------------------------------------------------------------- template<> -struct TargetFilesystemArtifactResultGetter<true, false> +struct TargetFilesystemArtifactResultGetter<ArtifactDirTag> { static std::string Get(const std::string &result) { return cmSystemTools::GetFilenamePath(result); } @@ -1620,14 +1668,14 @@ struct TargetFilesystemArtifactResultGetter<true, false> //---------------------------------------------------------------------------- template<> -struct TargetFilesystemArtifactResultGetter<false, false> +struct TargetFilesystemArtifactResultGetter<ArtifactPathTag> { static std::string Get(const std::string &result) { return result; } }; //---------------------------------------------------------------------------- -template<bool linker, bool soname, bool dirQual, bool nameQual> +template<typename ArtifactT, typename ComponentT> struct TargetFilesystemArtifact : public cmGeneratorExpressionNode { TargetFilesystemArtifact() {} @@ -1675,7 +1723,7 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode context->AllTargets.insert(target); std::string result = - TargetFilesystemArtifactResultCreator<linker, soname>::Create( + TargetFilesystemArtifactResultCreator<ArtifactT>::Create( target, context, content); @@ -1684,29 +1732,35 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode return std::string(); } return - TargetFilesystemArtifactResultGetter<dirQual, nameQual>::Get(result); + TargetFilesystemArtifactResultGetter<ComponentT>::Get(result); } }; //---------------------------------------------------------------------------- +template<typename ArtifactT> +struct TargetFilesystemArtifactNodeGroup +{ + TargetFilesystemArtifactNodeGroup() + { + } + + TargetFilesystemArtifact<ArtifactT, ArtifactPathTag> File; + TargetFilesystemArtifact<ArtifactT, ArtifactNameTag> FileName; + TargetFilesystemArtifact<ArtifactT, ArtifactDirTag> FileDir; +}; + +//---------------------------------------------------------------------------- static const -TargetFilesystemArtifact<false, false, false, false> targetFileNode; -static const -TargetFilesystemArtifact<true, false, false, false> targetLinkerFileNode; -static const -TargetFilesystemArtifact<false, true, false, false> targetSoNameFileNode; -static const -TargetFilesystemArtifact<false, false, false, true> targetFileNameNode; -static const -TargetFilesystemArtifact<true, false, false, true> targetLinkerFileNameNode; -static const -TargetFilesystemArtifact<false, true, false, true> targetSoNameFileNameNode; +TargetFilesystemArtifactNodeGroup<ArtifactNameTag> targetNodeGroup; + static const -TargetFilesystemArtifact<false, false, true, false> targetFileDirNode; +TargetFilesystemArtifactNodeGroup<ArtifactLinkerTag> targetLinkerNodeGroup; + static const -TargetFilesystemArtifact<true, false, true, false> targetLinkerFileDirNode; +TargetFilesystemArtifactNodeGroup<ArtifactSonameTag> targetSoNameNodeGroup; + static const -TargetFilesystemArtifact<false, true, true, false> targetSoNameFileDirNode; +TargetFilesystemArtifactNodeGroup<ArtifactPdbTag> targetPdbNodeGroup; //---------------------------------------------------------------------------- static const @@ -1732,15 +1786,18 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier) nodeMap["COMPILE_FEATURES"] = &compileFeaturesNode; nodeMap["CONFIGURATION"] = &configurationNode; nodeMap["CONFIG"] = &configurationTestNode; - nodeMap["TARGET_FILE"] = &targetFileNode; - nodeMap["TARGET_LINKER_FILE"] = &targetLinkerFileNode; - nodeMap["TARGET_SONAME_FILE"] = &targetSoNameFileNode; - nodeMap["TARGET_FILE_NAME"] = &targetFileNameNode; - nodeMap["TARGET_LINKER_FILE_NAME"] = &targetLinkerFileNameNode; - nodeMap["TARGET_SONAME_FILE_NAME"] = &targetSoNameFileNameNode; - nodeMap["TARGET_FILE_DIR"] = &targetFileDirNode; - nodeMap["TARGET_LINKER_FILE_DIR"] = &targetLinkerFileDirNode; - nodeMap["TARGET_SONAME_FILE_DIR"] = &targetSoNameFileDirNode; + nodeMap["TARGET_FILE"] = &targetNodeGroup.File; + nodeMap["TARGET_LINKER_FILE"] = &targetLinkerNodeGroup.File; + nodeMap["TARGET_SONAME_FILE"] = &targetSoNameNodeGroup.File; + nodeMap["TARGET_PDB_FILE"] = &targetPdbNodeGroup.File; + nodeMap["TARGET_FILE_NAME"] = &targetNodeGroup.FileName; + nodeMap["TARGET_LINKER_FILE_NAME"] = &targetLinkerNodeGroup.FileName; + nodeMap["TARGET_SONAME_FILE_NAME"] = &targetSoNameNodeGroup.FileName; + nodeMap["TARGET_PDB_FILE_NAME"] = &targetPdbNodeGroup.FileName; + nodeMap["TARGET_FILE_DIR"] = &targetNodeGroup.FileDir; + nodeMap["TARGET_LINKER_FILE_DIR"] = &targetLinkerNodeGroup.FileDir; + nodeMap["TARGET_SONAME_FILE_DIR"] = &targetSoNameNodeGroup.FileDir; + nodeMap["TARGET_PDB_FILE_DIR"] = &targetPdbNodeGroup.FileDir; nodeMap["STREQUAL"] = &strEqualNode; nodeMap["EQUAL"] = &equalNode; nodeMap["LOWER_CASE"] = &lowerCaseNode; |