AUTOUIC: files not located in source directory get incorrect paths in Visual Studio Filter
Consider the following directory layout
/
/src
test.cpp
CMakeLists.txt
/ui
test.ui
Where CMakeLists.txt contains the following:
project(test)
set(CMAKE_AUTOUIC ON)
find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
add_executable(test test.cpp ../ui/test.ui)
target_link_libraries(test Qt5::Widgets)
set_target_properties(test PROPERTIES AUTOUIC_SEARCH_PATHS "../ui")
test.cpp:
#include "ui_test.h"
void main() {}
test.ui:
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>Form</class>
<widget class="QWidget" name="Form" >
<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>
</widget>
<pixmapfunction></pixmapfunction>
<connections/>
</ui>
If you configure this, then you will find that ui_test.h
in the header files of the solution cannot be opened. This is due to a bug in cmQtAutoGenInitializer.cxx
located at lines 950 and 960. Here we should simply use the ui filename directly, but instead we use the relative path from the CMakeLists directory to the ui file directory. Perhaps this is important for some other generator, but for VS this definitely looks like a bug.
Edited by Brad King