CMake & QT5 - QT5_WRAP_UI not generating ui header files

后端 未结 3 936
日久生厌
日久生厌 2020-12-17 15:46

I have a simple CMakeLists.txt that looks like this:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(calculator)

FIND_PACKAGE(Qt5Core)
FIND_PACKAGE(Qt5Gui)
FIN         


        
相关标签:
3条回答
  • 2020-12-17 16:17

    I was running in the same issue with cmake 3.2.2. Try using

    SET(CMAKE_AUTOUIC ON)  
    

    if the ui files are not generated. Maybe the default behaviour changed recently?

    0 讨论(0)
  • 2020-12-17 16:22
    1. Use lower-case CMake commands. That has been the sane convention for years.

    2. Why are you using both AUTOMOC and qt5_wrap_cpp? AUTOMOC is designed to replace the macro. http://www.cmake.org/cmake/help/v3.0/manual/cmake-qt.7.html#automoc

    3. If using CMake 2.8.11 or later, then don't use qt5_use_modules. I wrote that as a stop-gap hack until CMake 2.8.11 was released. The target_link_libraries command does what qt5_use_modules does, but better and more-generically. http://doc-snapshot.qt-project.org/qt5-5.3/cmake-manual.html

    4. The library has no sources of its own and is not used. You're clearly 'doing it wrong' here. Move the ${calculator_FORMS_HEADERS} variable usage to the executables sources. Then after addressing point 2, remove the library.

    0 讨论(0)
  • 2020-12-17 16:26

    I have encountered the same issue on Mac OS X. Ui form header file is not generated.

    I have solved my problem by generating manually .h file with QtDesigner. When changes are made on ui form, header file is well generated.

    Note: if I add some others ui forms, headers are generated automatically without needed to generate header file manually for these others ui.

    EDIT: header file is well generated at first build only if it isn't used into cpp code.

    0 讨论(0)
提交回复
热议问题