0

I have a file who look like this :

    ...

    #ifdef IS_COMPILE_FOR_SPECIAL_TARGET
        #include "ui_myPage_special.h"
    #else
        #include "ui_myPage.h"
    #endif

The project use AutoUIC to include ui_ files. But since AutoUIC is called before the prepocessor, it ignore my #ifdef statement and try to replace the ui_myPage_special.h despite the .ui don't exist in this project.

The error message :

AutoUic error
-------------
"SRC:/path/to/mySource.cpp"
includes the uic file "ui_myPage_special.h",
but the user interface file "myPage_special.ui"
could not be found in the following directories
...

A solution I looked for was if AutoUIC can, in case it didn't find file, replace the #include by a #error or just leave it as is. So it's the preprocessor who will raise the error, and not AutoUIC.

I tried to find if an autouic-option like this exist but I didn't find this one in the CMake documentation.

iElden
  • 1,272
  • 1
  • 13
  • 26
  • Then mark the source file with [SKIP_AUTOUIC](https://cmake.org/cmake/help/latest/prop_sf/SKIP_AUTOUIC.html#prop_sf:SKIP_AUTOUIC) and run uic by yourself with [qt_wrap_ui()](https://cmake.org/cmake/help/latest/command/qt_wrap_ui.html) – chehrlic Apr 28 '23 at 13:32
  • Thank you but I have a lot of source file and a lot of project. That why I am searching a solution like a CMake global option rather than a "file by file" solution. – iElden Apr 28 '23 at 14:08
  • qt_wrap_ui() takes a list of ui files... – chehrlic Apr 28 '23 at 15:51

0 Answers0