diff options
author | Brad King <brad.king@kitware.com> | 2013-01-15 19:43:05 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2013-01-15 19:43:05 (GMT) |
commit | 3a7d1ce3ff0ea0565d463a341f42acd6bed8a6c4 (patch) | |
tree | 8eb91157276663e3b816a5f5ed47afa12e6ee5a6 /Source | |
parent | 33d4e0db3fbe9441a227052c5fea5bc1d57af6cc (diff) | |
parent | 1d74ba21f6ee70936191c94448c88fd10eb1e81c (diff) | |
download | CMake-3a7d1ce3ff0ea0565d463a341f42acd6bed8a6c4.zip CMake-3a7d1ce3ff0ea0565d463a341f42acd6bed8a6c4.tar.gz CMake-3a7d1ce3ff0ea0565d463a341f42acd6bed8a6c4.tar.bz2 |
Merge topic 'test-export-iface-genex'
1d74ba2 Test evaluation target via export for generator expressions
522bdac Export the INTERFACE_PIC property.
4ee872c Make the BUILD_INTERFACE of export()ed targets work.
1d47cd9 Add a test for the interfaces in targets exported from the build tree.
6c828f9 Move the exported check for file existence.
cfd4f0a Move the exported check for dependencies of targets
d8fe1fc Only generate one check per missing target.
f623d37 Don't write a comment in the export file without the code.
b279f2b Strip consecutive semicolons when preprocessing genex strings.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmExportBuildFileGenerator.cxx | 15 | ||||
-rw-r--r-- | Source/cmExportBuildFileGenerator.h | 3 | ||||
-rw-r--r-- | Source/cmExportFileGenerator.cxx | 47 | ||||
-rw-r--r-- | Source/cmExportFileGenerator.h | 8 | ||||
-rw-r--r-- | Source/cmExportInstallFileGenerator.cxx | 22 | ||||
-rw-r--r-- | Source/cmExportInstallFileGenerator.h | 6 | ||||
-rw-r--r-- | Source/cmGeneratorExpression.cxx | 36 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 14 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 25 | ||||
-rw-r--r-- | Source/cmTarget.h | 3 |
10 files changed, 131 insertions, 48 deletions
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 29f6743..61e130d 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -62,6 +62,8 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) cmTarget* te = *tei; this->GenerateImportTargetCode(os, te); + te->AppendBuildInterfaceIncludes(); + ImportPropertyMap properties; this->PopulateInterfaceProperty("INTERFACE_INCLUDE_DIRECTORIES", te, @@ -70,20 +72,22 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", te, cmGeneratorExpression::BuildInterface, properties, missingTargets); + this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", + te, properties); this->GenerateInterfaceProperties(te, os, properties); } - this->GenerateMissingTargetsCheckCode(os, missingTargets); - // Generate import file content for each configuration. for(std::vector<std::string>::const_iterator ci = this->Configurations.begin(); ci != this->Configurations.end(); ++ci) { - this->GenerateImportConfig(os, ci->c_str()); + this->GenerateImportConfig(os, ci->c_str(), missingTargets); } + this->GenerateMissingTargetsCheckCode(os, missingTargets); + return true; } @@ -91,7 +95,8 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) void cmExportBuildFileGenerator ::GenerateImportTargetsConfig(std::ostream& os, - const char* config, std::string const& suffix) + const char* config, std::string const& suffix, + std::vector<std::string> &missingTargets) { for(std::vector<cmTarget*>::const_iterator tei = this->Exports->begin(); @@ -104,7 +109,6 @@ cmExportBuildFileGenerator if(!properties.empty()) { // Get the rest of the target details. - std::vector<std::string> missingTargets; this->SetImportDetailProperties(config, suffix, target, properties, missingTargets); this->SetImportLinkInterface(config, suffix, @@ -119,7 +123,6 @@ cmExportBuildFileGenerator // properties); // Generate code in the export file. - this->GenerateMissingTargetsCheckCode(os, missingTargets); this->GenerateImportPropertyCode(os, config, target, properties); } } diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index 726537b..5e1be16 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -44,7 +44,8 @@ protected: virtual bool GenerateMainFile(std::ostream& os); virtual void GenerateImportTargetsConfig(std::ostream& os, const char* config, - std::string const& suffix); + std::string const& suffix, + std::vector<std::string> &missingTargets); virtual void HandleMissingTarget(std::string& link_libs, std::vector<std::string>& missingTargets, cmMakefile* mf, diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 94e24c7..4a7c6f9 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -107,7 +107,8 @@ bool cmExportFileGenerator::GenerateImportFile() //---------------------------------------------------------------------------- void cmExportFileGenerator::GenerateImportConfig(std::ostream& os, - const char* config) + const char* config, + std::vector<std::string> &missingTargets) { // Construct the property configuration suffix. std::string suffix = "_"; @@ -121,7 +122,19 @@ void cmExportFileGenerator::GenerateImportConfig(std::ostream& os, } // Generate the per-config target information. - this->GenerateImportTargetsConfig(os, config, suffix); + this->GenerateImportTargetsConfig(os, config, suffix, missingTargets); +} + +//---------------------------------------------------------------------------- +void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, + cmTarget *target, + ImportPropertyMap &properties) +{ + const char *input = target->GetProperty(propName); + if (input) + { + properties[propName] = input; + } } //---------------------------------------------------------------------------- @@ -665,21 +678,29 @@ cmExportFileGenerator void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os, const std::vector<std::string>& missingTargets) { + if (missingTargets.empty()) + { + return; + } os << "# Make sure the targets which have been exported in some other \n" "# export set exist.\n"; + std::set<std::string> emitted; for(unsigned int i=0; i<missingTargets.size(); ++i) { - os << "IF(NOT TARGET \"" << missingTargets[i] << "\" )\n" - << " IF(CMAKE_FIND_PACKAGE_NAME)\n" - << " SET( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)\n" - << " SET( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE " - << "\"Required imported target \\\"" << missingTargets[i] - << "\\\" not found ! \")\n" - << " ELSE()\n" - << " MESSAGE(FATAL_ERROR \"Required imported target \\\"" - << missingTargets[i] << "\\\" not found ! \")\n" - << " ENDIF()\n" - << "ENDIF()\n"; + if (emitted.insert(missingTargets[i]).second) + { + os << "IF(NOT TARGET \"" << missingTargets[i] << "\" )\n" + << " IF(CMAKE_FIND_PACKAGE_NAME)\n" + << " SET( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)\n" + << " SET( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE " + << "\"Required imported target \\\"" << missingTargets[i] + << "\\\" not found ! \")\n" + << " ELSE()\n" + << " MESSAGE(FATAL_ERROR \"Required imported target \\\"" + << missingTargets[i] << "\\\" not found ! \")\n" + << " ENDIF()\n" + << "ENDIF()\n"; + } } os << "\n"; } diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 4d97a63..eb3f3c3 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -47,7 +47,8 @@ protected: // Generate per-configuration target information to the given output // stream. - void GenerateImportConfig(std::ostream& os, const char* config); + void GenerateImportConfig(std::ostream& os, const char* config, + std::vector<std::string> &missingTargets); // Methods to implement export file code generation. void GenerateImportHeaderCode(std::ostream& os, const char* config = 0); @@ -85,7 +86,8 @@ protected: /** Each subclass knows where the target files are located. */ virtual void GenerateImportTargetsConfig(std::ostream& os, const char* config, - std::string const& suffix) = 0; + std::string const& suffix, + std::vector<std::string> &missingTargets) = 0; /** Each subclass knows how to deal with a target that is missing from an * export set. */ @@ -99,6 +101,8 @@ protected: cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, std::vector<std::string> &missingTargets); + void PopulateInterfaceProperty(const char *propName, cmTarget *target, + ImportPropertyMap &properties); void GenerateInterfaceProperties(cmTarget *target, std::ostream& os, const ImportPropertyMap &properties); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 68881a1..965f63d 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -89,11 +89,12 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) te, cmGeneratorExpression::InstallInterface, properties, missingTargets); + this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", + te, properties); this->GenerateInterfaceProperties(te, os, properties); } - this->GenerateMissingTargetsCheckCode(os, missingTargets); // Now load per-configuration properties for them. os << "# Load information for each installed configuration.\n" @@ -105,23 +106,29 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) << "ENDFOREACH(f)\n" << "\n"; + this->GenerateImportedFileCheckLoop(os); + // Generate an import file for each configuration. bool result = true; for(std::vector<std::string>::const_iterator ci = this->Configurations.begin(); ci != this->Configurations.end(); ++ci) { - if(!this->GenerateImportFileConfig(ci->c_str())) + if(!this->GenerateImportFileConfig(ci->c_str(), missingTargets)) { result = false; } } + + this->GenerateMissingTargetsCheckCode(os, missingTargets); + return result; } //---------------------------------------------------------------------------- bool -cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config) +cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config, + std::vector<std::string> &missingTargets) { // Skip configurations not enabled for this export. if(!this->IEGen->InstallsForConfig(config)) @@ -161,7 +168,7 @@ cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config) this->GenerateImportHeaderCode(os, config); // Generate the per-config target information. - this->GenerateImportConfig(os, config); + this->GenerateImportConfig(os, config, missingTargets); // End with the import file footer. this->GenerateImportFooterCode(os); @@ -176,7 +183,8 @@ cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config) void cmExportInstallFileGenerator ::GenerateImportTargetsConfig(std::ostream& os, - const char* config, std::string const& suffix) + const char* config, std::string const& suffix, + std::vector<std::string> &missingTargets) { // Add code to compute the installation prefix relative to the // import file location. @@ -225,7 +233,6 @@ cmExportInstallFileGenerator if(!properties.empty()) { // Get the rest of the target details. - std::vector<std::string> missingTargets; this->SetImportDetailProperties(config, suffix, te->Target, properties, missingTargets); @@ -240,15 +247,12 @@ cmExportInstallFileGenerator // properties); // Generate code in the export file. - this->GenerateMissingTargetsCheckCode(os, missingTargets); this->GenerateImportPropertyCode(os, config, te->Target, properties); this->GenerateImportedFileChecksCode(os, te->Target, properties, importedLocations); } } - this->GenerateImportedFileCheckLoop(os); - // Cleanup the import prefix variable. if(!this->ImportPrefix.empty()) { diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index e719ecc..e187749 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -56,7 +56,8 @@ protected: virtual bool GenerateMainFile(std::ostream& os); virtual void GenerateImportTargetsConfig(std::ostream& os, const char* config, - std::string const& suffix); + std::string const& suffix, + std::vector<std::string> &missingTargets); virtual void HandleMissingTarget(std::string& link_libs, std::vector<std::string>& missingTargets, cmMakefile* mf, @@ -72,7 +73,8 @@ protected: /** Generate a per-configuration file for the targets. */ - bool GenerateImportFileConfig(const char* config); + bool GenerateImportFileConfig(const char* config, + std::vector<std::string> &missingTargets); /** Fill in properties indicating installed file locations. */ void SetImportLocationProperty(const char* config, diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index d306dee..78ae8f2 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -148,6 +148,38 @@ cmCompiledGeneratorExpression::~cmCompiledGeneratorExpression() } //---------------------------------------------------------------------------- +static std::string stripEmptyListElements(const std::string &input) +{ + std::string result; + + const char *c = input.c_str(); + bool skipSemiColons = true; + for ( ; *c; ++c) + { + if(c[0] == ';') + { + if(skipSemiColons) + { + continue; + } + skipSemiColons = true; + } + else + { + skipSemiColons = false; + } + result += *c; + } + + if (!result.empty() && *(result.end() - 1) == ';') + { + result.resize(result.size() - 1); + } + + return result; +} + +//---------------------------------------------------------------------------- static std::string stripAllGeneratorExpressions(const std::string &input) { std::string result; @@ -186,7 +218,7 @@ static std::string stripAllGeneratorExpressions(const std::string &input) lastPos = pos; } result += input.substr(lastPos); - return result; + return stripEmptyListElements(result); } //---------------------------------------------------------------------------- @@ -247,7 +279,7 @@ static std::string stripExportInterface(const std::string &input, } result += input.substr(lastPos); - return result; + return stripEmptyListElements(result); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index d030aa7..d2baf53 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -941,19 +941,7 @@ void cmGlobalGenerator::Generate() for ( tit = targets->begin(); tit != targets->end(); ++ tit ) { - if (mf->IsOn("CMAKE_BUILD_INTERFACE_INCLUDES")) - { - const char *binDir = mf->GetStartOutputDirectory(); - const char *srcDir = mf->GetStartDirectory(); - const std::string dirs = std::string(binDir ? binDir : "") - + std::string(binDir ? ";" : "") - + std::string(srcDir ? srcDir : ""); - if (!dirs.empty()) - { - tit->second.AppendProperty("INTERFACE_INCLUDE_DIRECTORIES", - ("$<BUILD_INTERFACE:" + dirs + ">").c_str()); - } - } + tit->second.AppendBuildInterfaceIncludes(); } } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 6f68140..815da40 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -150,6 +150,7 @@ cmTarget::cmTarget() this->DLLPlatform = false; this->IsApple = false; this->IsImportedTarget = false; + this->BuildInterfaceIncludesAppended = false; } //---------------------------------------------------------------------------- @@ -2681,6 +2682,30 @@ void cmTarget::AppendProperty(const char* prop, const char* value, } //---------------------------------------------------------------------------- +void cmTarget::AppendBuildInterfaceIncludes() +{ + if (this->BuildInterfaceIncludesAppended) + { + return; + } + this->BuildInterfaceIncludesAppended = true; + + if (this->Makefile->IsOn("CMAKE_BUILD_INTERFACE_INCLUDES")) + { + const char *binDir = this->Makefile->GetStartOutputDirectory(); + const char *srcDir = this->Makefile->GetStartDirectory(); + const std::string dirs = std::string(binDir ? binDir : "") + + std::string(binDir ? ";" : "") + + std::string(srcDir ? srcDir : ""); + if (!dirs.empty()) + { + this->AppendProperty("INTERFACE_INCLUDE_DIRECTORIES", + ("$<BUILD_INTERFACE:" + dirs + ">").c_str()); + } + } +} + +//---------------------------------------------------------------------------- void cmTarget::InsertInclude(const cmMakefileIncludeDirectoriesEntry &entry, bool before) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 0963c5c..69a00c1 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -490,6 +490,8 @@ public: void InsertInclude(const cmMakefileIncludeDirectoriesEntry &entry, bool before = false); + void AppendBuildInterfaceIncludes(); + void GetLinkDependentTargetsForProperty(const std::string &p, std::set<std::string> &targets); bool IsNullImpliedByLinkLibraries(const std::string &p); @@ -611,6 +613,7 @@ private: mutable std::map<cmStdString, std::set<std::string> > LinkDependentProperties; mutable std::set<std::string> LinkImplicitNullProperties; + bool BuildInterfaceIncludesAppended; // Cache target output paths for each configuration. struct OutputInfo; |