0

I'm porting a legacy C++ + Qt project to CMake and as a first step I do not want to touch the original project tree, so that the CMake project can be a drop-in patch that just extends the original project.

However, the original project tree stores UI files in a dedicated folder that's separated from all the source and header files.

I've tried setting CMAKE_AUTOUIC_SEARCH_PATHS to point to the UI folder, as mentioned in this earlier question, and also pass the list of UI files to qt_wrap_ui. However, none of these tricks had any effect, and I never manage to get the CMake project to generate the ui_ source files.

Does anyone know if there's a way to get cmake to reliably generate source files from Qt's ui stashed in any arbitrary folder within the project tree?

RAM
  • 2,257
  • 2
  • 19
  • 41
  • 1
    a [mre] of what you've tried would be helpful – Alan Birtles Nov 30 '21 at 18:11
  • qt_wrap_ui() will work, no matter where the ui files are. – chehrlic Nov 30 '21 at 18:37
  • We had all `ui_*.h` files in "${sourceDir}/tmp/" and `CMAKE_AUTOMOC` seems to be working fine. Just make sure that the headers are included correctly. We had many cpp files that include ui headers like so: `#include ".\tmp\ui_MyWindow.h"`. CMake is not able to recognize them as ui headers, so you need to correct them (`"tmp/ui_MyWindow.h"`). Also make sure that actual *.ui files live close to cpp using them. – Osyotr Nov 30 '21 at 21:46

0 Answers0