Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. CMake QT5_WRAP_UI issue
QtWS25 Last Chance

CMake QT5_WRAP_UI issue

Scheduled Pinned Locked Moved Solved General and Desktop
qtcreator 4.2.1windowscmake 3.8.2qt 5.8
5 Posts 3 Posters 5.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    enmaniac
    wrote on last edited by
    #1

    Hi all,

    I am trying to make a transition from QMake based build system to CMake one.
    So far everything worked quite okish but I run onto the problem I am unable to solve.

    I do have UI file which I need to be processed and appropriate header file generated. This is usually done by UIC.exe and its kind of automatic in QMake.

    Now I am having a CMakeLists.txt file as follows (more or less, I have simplified it):

    cmake_minimum_required (VERSION 2.8.11)
    
    project (WorkspacePlugin)
    
    set(CMAKE_AUTOMOC ON)
    
    set (SOURCES
      Implementation/AddConfigurationWindow.cpp
    )
    
    set (HEADERS
      Interaface/AddConfigurationWindow.h
    )
    
    set (UIS
      Forms/AddConfiguration.ui
    )
    
    QT5_WRAP_UI(FORMS_HEADERS ${UIS})
    
    find_package (Qt5Core)
    find_package (Qt5Gui)
    find_package (Qt5Widgets)
    
    add_library (${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS} ${FORMS_HEADERS})
    
    target_link_libraries (${PROJECT_NAME} CorePlugin Qt5::Core Qt5::Gui Qt5::Widgets)
    

    Now, while building the project I do get the following error:

    [ 92%] Generating ui_AddConfiguration.h
    	cd D:\Projects\CPP\Builds\EGETools-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug\EditorPlugins\WorkspacePlugin
    	o D:/Projects/CPP/Builds/EGETools-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug/EditorPlugins/WorkspacePlugin/ui_AddConfiguration.h D:/Projects/CPP/EGETools/EditorPlugins/WorkspacePlugin/Implementation/AddConfiguration.ui
    'o' is not recognized as an internal or external command,
    operable program or batch file.
    

    I have looked into generated make file and I have found the following rule generated for it:

    EditorPlugins\WorkspacePlugin\ui_AddConfiguration.h: D:\Projects\CPP\EGETools\EditorPlugins\WorkspacePlugin\Implementation\AddConfiguration.ui
    	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue --bold --progress-dir=D:\Projects\CPP\Builds\EGETools-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug\CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Generating ui_AddConfiguration.h"
    	cd D:\Projects\CPP\Builds\EGETools-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug\EditorPlugins\WorkspacePlugin
    	-o D:/Projects/CPP/Builds/EGETools-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug/EditorPlugins/WorkspacePlugin/ui_AddConfiguration.h D:/Projects/CPP/EGETools/EditorPlugins/WorkspacePlugin/Implementation/AddConfiguration.ui
    	cd D:\Projects\CPP\Builds\EGETools-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug
    

    It can be seen that in that rule '-o' is used rather than plain 'o'. Though I am not sure if that even means anything.

    Does anyone happen to know what the problem is here and how to solve it ?

    Thanks in advance

    PS my environment is: Windows 10 x64, QtCreator 4.2.1, Qt 5.8.0, CMake 3.8.2

    Cheers!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Since you have a recent version of CMake, there's also CMAKE_AUTOUIC that should make your life easier but you will have to change the minimum cmake requirement.

      See this Wiki entry for more details.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      E 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        Since you have a recent version of CMake, there's also CMAKE_AUTOUIC that should make your life easier but you will have to change the minimum cmake requirement.

        See this Wiki entry for more details.

        E Offline
        E Offline
        enmaniac
        wrote on last edited by
        #3

        @SGaist Yes indeed there is. And that one seems to be working fine. However, it requires UI file to be next to the ones which do include generated headers (implementation files in my case). I do want to keep them separately from the source files.

        Cheers!

        1 Reply Last reply
        0
        • E Offline
          E Offline
          enmaniac
          wrote on last edited by
          #4

          Ok. I have found the issue.

          Since QT5_WRAP_UI macro is delivered as part of Qt5Widget packacge it is necessery to make a call to find_package (Qt5Widget) before issuing QT5_WRAP_UI call.

          Ehh :D

          Cheers!

          1 Reply Last reply
          1
          • B Offline
            B Offline
            breakthru
            wrote on last edited by
            #5

            I'm having the exact same problem and I resorted to a ugly hack of calling

            SET(Qt5Widgets_UIC_EXECUTABLE "uic")
            

            before calling QT5_WRAP_UI

            I don't know why but the value of Qt5Widgets_UIC_EXECUTABLE comes up as empty string (or unset)

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved