summaryrefslogtreecommitdiff
path: root/Source/cmQtAutoGenerators.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2017-08-15 12:17:37 +0200
committerSebastian Holtermann <sebholt@xwmw.org>2017-08-15 12:17:37 +0200
commit02e6c5481396a841a80e9546c223e7edc041a668 (patch)
tree003c6f09daa9bb21fbf95e6e9ffe27d7c02a5064 /Source/cmQtAutoGenerators.cxx
parentfca4423786ba2c4a5ab0ec6c1a1cbac8cd8600b4 (diff)
downloadcmake-02e6c5481396a841a80e9546c223e7edc041a668.tar.gz
Autogen: Restore AUTOUIC lookup paths from 3.8.2
When encountering an `#include "<PATH>ui_<BASE>.h"` statement, search for `<BASE>.ui` in - <SOURCE_DIR>/<BASE>.ui - <SOURCE_DIR>/<PATH><BASE>.ui - <AUTOUIC_SEARCH_PATH>/<BASE>.ui - <AUTOUIC_SEARCH_PATH>/<PATH><BASE>.ui In CMake 3.8.2 the lookup list was - <SOURCE_DIR>/<BASE>.ui In CMake 3.9.[01] the lookup list was - <SOURCE_DIR>/<PATH><BASE.ui> - <AUTOUIC_SEARCH_PATH>/<PATH><BASE>.ui Closes #17168
Diffstat (limited to 'Source/cmQtAutoGenerators.cxx')
-rw-r--r--Source/cmQtAutoGenerators.cxx69
1 files changed, 49 insertions, 20 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index c79f66da5b..d12d96dcbb 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -1446,31 +1446,62 @@ bool cmQtAutoGenerators::MocGenerateFile(
bool cmQtAutoGenerators::UicFindIncludedFile(std::string& absFile,
const std::string& sourceFile,
- const std::string& includeString)
+ const std::string& searchPath,
+ const std::string& searchFile)
{
bool success = false;
- // Search in vicinity of the source
+ std::vector<std::string> testFiles;
+ // Collect search paths list
{
- std::string testPath = SubDirPrefix(sourceFile);
- testPath += includeString;
- if (cmsys::SystemTools::FileExists(testPath.c_str())) {
- absFile = cmsys::SystemTools::GetRealPath(testPath);
+ const std::string searchFileFull = searchPath + searchFile;
+ // Vicinity of the source
+ {
+ const std::string sourcePath = SubDirPrefix(sourceFile);
+ testFiles.push_back(sourcePath + searchFile);
+ if (!searchPath.empty()) {
+ testFiles.push_back(sourcePath + searchFileFull);
+ }
+ }
+ // AUTOUIC search paths
+ if (!this->UicSearchPaths.empty()) {
+ for (std::vector<std::string>::const_iterator iit =
+ this->UicSearchPaths.begin();
+ iit != this->UicSearchPaths.end(); ++iit) {
+ testFiles.push_back(*iit + "/" + searchFile);
+ }
+ if (!searchPath.empty()) {
+ for (std::vector<std::string>::const_iterator iit =
+ this->UicSearchPaths.begin();
+ iit != this->UicSearchPaths.end(); ++iit) {
+ testFiles.push_back(*iit + "/" + searchFileFull);
+ }
+ }
+ }
+ }
+
+ // Search for the .ui file!
+ for (std::vector<std::string>::const_iterator iit = testFiles.begin();
+ iit != testFiles.end(); ++iit) {
+ const std::string& testFile = *iit;
+ if (cmsys::SystemTools::FileExists(testFile.c_str())) {
+ absFile = cmsys::SystemTools::GetRealPath(testFile);
success = true;
+ break;
}
}
- // Search in include directories
+
+ // Log error
if (!success) {
- for (std::vector<std::string>::const_iterator iit =
- this->UicSearchPaths.begin();
- iit != this->UicSearchPaths.end(); ++iit) {
- const std::string fullPath = ((*iit) + '/' + includeString);
- if (cmsys::SystemTools::FileExists(fullPath.c_str())) {
- absFile = cmsys::SystemTools::GetRealPath(fullPath);
- success = true;
- break;
- }
+ std::ostringstream ost;
+ ost << "AutoUic: Error: " << Quoted(sourceFile) << "\n";
+ ost << "Could not find " << Quoted(searchFile) << " in\n";
+ for (std::vector<std::string>::const_iterator iit = testFiles.begin();
+ iit != testFiles.end(); ++iit) {
+ ost << " " << Quoted(*iit) << "\n";
}
+ this->LogError(ost.str());
}
+
return success;
}
@@ -1500,16 +1531,14 @@ bool cmQtAutoGenerators::UicGenerateAll(
const std::string uiBasePath = SubDirPrefix(*uit);
const std::string uiBaseName =
cmsys::SystemTools::GetFilenameWithoutLastExtension(*uit).substr(3);
- const std::string searchFileName = uiBasePath + uiBaseName + ".ui";
+ const std::string uiFileName = uiBaseName + ".ui";
std::string uiInputFile;
- if (UicFindIncludedFile(uiInputFile, source, searchFileName)) {
+ if (UicFindIncludedFile(uiInputFile, source, uiBasePath, uiFileName)) {
std::string uiOutputFile = uiBasePath + "ui_" + uiBaseName + ".h";
cmSystemTools::ReplaceString(uiOutputFile, "..", "__");
uiGenMap[uiInputFile] = uiOutputFile;
testMap[uiInputFile] = uiOutputFile;
} else {
- this->LogError("AutoUic: Error: " + Quoted(sit->first) +
- "\nCould not find " + Quoted(searchFileName));
return false;
}
}