mirror of
https://github.com/reactos/CMake.git
synced 2024-12-02 16:46:36 +00:00
Merge branch 'backport-autogen-autouic-lookup' into autogen-autouic-lookup
This commit is contained in:
commit
6c5e03d6d4
@ -70,7 +70,8 @@ be included by the user in the C++ implementation file with a preprocessor
|
||||
Included ``moc_*.cpp`` and ``*.moc`` files will be generated in the
|
||||
``<AUTOGEN_BUILD_DIR>/include`` directory which is
|
||||
automatically added to the target's :prop_tgt:`INCLUDE_DIRECTORIES`.
|
||||
(This differs from CMake 3.7 and below; see their documentation for details.)
|
||||
|
||||
* This differs from CMake 3.7 and below; see their documentation for details.
|
||||
|
||||
* For multi configuration generators, the include directory is
|
||||
``<AUTOGEN_BUILD_DIR>/include_<CONFIG>``.
|
||||
@ -110,15 +111,23 @@ inspects the C++ files in the target to determine if they require ``uic`` to
|
||||
be run, and to create rules to execute ``uic`` at the appropriate time.
|
||||
|
||||
If a preprocessor ``#include`` directive is found which matches
|
||||
``ui_<basename>.h``, and a ``<basename>.ui`` file exists, then ``uic`` will
|
||||
be executed to generate the appropriate file. The ``<basename>.ui`` file is
|
||||
searched for first in the vicinity of including file and afterwards in the
|
||||
optional :prop_tgt:`AUTOUIC_SEARCH_PATHS` of the target.
|
||||
``<path>ui_<basename>.h``, and a ``<basename>.ui`` file exists,
|
||||
then ``uic`` will be executed to generate the appropriate file.
|
||||
The ``<basename>.ui`` file is searched for in the following places
|
||||
|
||||
1. ``<source_dir>/<basename>.ui``
|
||||
2. ``<source_dir>/<path><basename>.ui``
|
||||
3. ``<AUTOUIC_SEARCH_PATHS>/<basename>.ui``
|
||||
4. ``<AUTOUIC_SEARCH_PATHS>/<path><basename>.ui``
|
||||
|
||||
where ``<source_dir>`` is the directory of the C++ file and
|
||||
:prop_tgt:`AUTOUIC_SEARCH_PATHS` is a list of additional search paths.
|
||||
|
||||
The generated generated ``ui_*.h`` files are placed in the
|
||||
``<AUTOGEN_BUILD_DIR>/include`` directory which is
|
||||
automatically added to the target's :prop_tgt:`INCLUDE_DIRECTORIES`.
|
||||
(This differs from CMake 3.7 and below; see their documentation for details.)
|
||||
|
||||
* This differs from CMake 3.7 and below; see their documentation for details.
|
||||
|
||||
* For multi configuration generators, the include directory is
|
||||
``<AUTOGEN_BUILD_DIR>/include_<CONFIG>``.
|
||||
|
@ -1454,31 +1454,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);
|
||||
success = true;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Search in include directories
|
||||
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;
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
// Log error
|
||||
if (!success) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1508,16 +1539,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;
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +112,8 @@ private:
|
||||
|
||||
// -- Uic file generation
|
||||
bool UicFindIncludedFile(std::string& absFile, const std::string& sourceFile,
|
||||
const std::string& includeString);
|
||||
const std::string& searchPath,
|
||||
const std::string& searchFile);
|
||||
bool UicGenerateAll(
|
||||
const std::map<std::string, std::vector<std::string> >& includedUis);
|
||||
bool UicGenerateFile(const std::string& realName,
|
||||
|
24
Tests/QtAutogen/uicInclude/PageC2.ui
Normal file
24
Tests/QtAutogen/uicInclude/PageC2.ui
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PageC2</class>
|
||||
<widget class="QWidget" name="PageC2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTreeView" name="treeView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
24
Tests/QtAutogen/uicInclude/dirB/PageB2.ui
Normal file
24
Tests/QtAutogen/uicInclude/dirB/PageB2.ui
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PageB2</class>
|
||||
<widget class="QWidget" name="PageB2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTreeView" name="treeView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
24
Tests/QtAutogen/uicInclude/dirB/subB/PageBsub.ui
Normal file
24
Tests/QtAutogen/uicInclude/dirB/subB/PageBsub.ui
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PageBsub</class>
|
||||
<widget class="QWidget" name="PageBsub">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTreeView" name="treeView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -6,5 +6,13 @@ int main(int argv, char** args)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "sub/ui_PageB.h"
|
||||
// .ui files in CMAKE_AUTOUIC_SEARCH_PATHS
|
||||
#include "ui_PageA.h"
|
||||
// .ui files in AUTOUIC_SEARCH_PATHS
|
||||
#include "sub/gen/deep/ui_PageB2.h"
|
||||
#include "subB/ui_PageBsub.h"
|
||||
#include "ui_PageB.h"
|
||||
// .ui files in source's vicinity
|
||||
#include "sub/gen/deep/ui_PageC2.h"
|
||||
#include "subC/ui_PageCsub.h"
|
||||
#include "ui_PageC.h"
|
||||
|
24
Tests/QtAutogen/uicInclude/subC/PageCsub.ui
Normal file
24
Tests/QtAutogen/uicInclude/subC/PageCsub.ui
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PageCsub</class>
|
||||
<widget class="QWidget" name="PageCsub">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTreeView" name="treeView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue
Block a user