diff options
author | Brad King <brad.king@kitware.com> | 2013-12-02 17:06:43 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2013-12-02 17:06:43 (GMT) |
commit | 9d51c764f73175664cc18acab755e6a11233656e (patch) | |
tree | 7541f4b0f3c09a3dd3848fec21e4320db56f26b7 /Source/cmExportFileGenerator.cxx | |
parent | 9c56366250b2abbe769ddc256a8c8c1c2c9deb6b (diff) | |
parent | 5838aba1aae5c341941c0779cd947ed0172e3a61 (diff) | |
download | CMake-9d51c764f73175664cc18acab755e6a11233656e.zip CMake-9d51c764f73175664cc18acab755e6a11233656e.tar.gz CMake-9d51c764f73175664cc18acab755e6a11233656e.tar.bz2 |
Merge topic 'export-includes'
5838aba Export: Report error on relative include with genex.
7a3e45b Export: Prefix relative items with genexes in INSTALL_INTERFACE.
f088a32 Export: Process INSTALL_INTERFACE in INCLUDES DESTINATION.
9eedc85 Export: Process relative includes after genex evaluation.
80790f3 Export: Test existing behavior of exporting includes with genexes.
38afc82 target_include_directories: Allow relative path with genex
Diffstat (limited to 'Source/cmExportFileGenerator.cxx')
-rw-r--r-- | Source/cmExportFileGenerator.cxx | 70 |
1 files changed, 55 insertions, 15 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index dc62284..f8b4e28 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -233,26 +233,46 @@ static bool checkInterfaceDirs(const std::string &prepro, const bool inSourceBuild = strcmp(topSourceDir, topBinaryDir) == 0; + bool hadFatalError = false; + for(std::vector<std::string>::iterator li = parts.begin(); li != parts.end(); ++li) { - if (cmGeneratorExpression::Find(*li) != std::string::npos) + size_t genexPos = cmGeneratorExpression::Find(*li); + if (genexPos == 0) { continue; } + cmake::MessageType messageType = cmake::FATAL_ERROR; + cmOStringStream e; + if (genexPos != std::string::npos) + { + switch (target->GetPolicyStatusCMP0041()) + { + case cmPolicies::WARN: + messageType = cmake::WARNING; + e << target->GetMakefile()->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0041) << "\n"; + break; + case cmPolicies::OLD: + continue; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + hadFatalError = true; + break; // Issue fatal message. + } + } if (cmHasLiteralPrefix(li->c_str(), "${_IMPORT_PREFIX}")) { continue; } if (!cmSystemTools::FileIsFullPath(li->c_str())) { - cmOStringStream e; e << "Target \"" << target->GetName() << "\" " "INTERFACE_INCLUDE_DIRECTORIES property contains relative path:\n" " \"" << *li << "\""; - target->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, - e.str().c_str()); - return false; + target->GetMakefile()->IssueMessage(messageType, e.str().c_str()); } if (isSubDirectory(li->c_str(), installDir)) { @@ -260,29 +280,44 @@ static bool checkInterfaceDirs(const std::string &prepro, } if (isSubDirectory(li->c_str(), topBinaryDir)) { - cmOStringStream e; e << "Target \"" << target->GetName() << "\" " "INTERFACE_INCLUDE_DIRECTORIES property contains path:\n" " \"" << *li << "\"\nwhich is prefixed in the build directory."; - target->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, - e.str().c_str()); - return false; + target->GetMakefile()->IssueMessage(messageType, e.str().c_str()); } if (!inSourceBuild) { if (isSubDirectory(li->c_str(), topSourceDir)) { - cmOStringStream e; e << "Target \"" << target->GetName() << "\" " "INTERFACE_INCLUDE_DIRECTORIES property contains path:\n" " \"" << *li << "\"\nwhich is prefixed in the source directory."; - target->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, - e.str().c_str()); - return false; + target->GetMakefile()->IssueMessage(messageType, e.str().c_str()); } } } - return true; + return !hadFatalError; +} + +//---------------------------------------------------------------------------- +static void prefixItems(std::string &exportDirs) +{ + std::vector<std::string> entries; + cmGeneratorExpression::Split(exportDirs, entries); + exportDirs = ""; + const char *sep = ""; + for(std::vector<std::string>::const_iterator ei = entries.begin(); + ei != entries.end(); ++ei) + { + exportDirs += sep; + sep = ";"; + if (!cmSystemTools::FileIsFullPath(ei->c_str()) + && ei->find("${_IMPORT_PREFIX}") == std::string::npos) + { + exportDirs += "${_IMPORT_PREFIX}/"; + } + exportDirs += *ei; + } } //---------------------------------------------------------------------------- @@ -301,7 +336,10 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( cmListFileBacktrace lfbt; cmGeneratorExpression ge(lfbt); - std::string dirs = tei->InterfaceIncludeDirectories; + std::string dirs = cmGeneratorExpression::Preprocess( + tei->InterfaceIncludeDirectories, + preprocessRule, + true); this->ReplaceInstallPrefix(dirs); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs); std::string exportDirs = cge->Evaluate(target->GetMakefile(), 0, @@ -330,6 +368,8 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( return; } + prefixItems(exportDirs); + std::string includes = (input?input:""); const char* sep = input ? ";" : ""; includes += sep + exportDirs; |