Seamus
Seamus

Reputation: 43

Combination cmake 2.8.11.2 with qt 5.1 won't create ui_xxx.h files

I recently started using cmake to manage my qt projects, mainly to be able to easily switch between Visual Studio 2012 and xcode.

Now I'm facing a strange problem (strange because I'm pretty sure this worked already).

The problem is that cmake (cmake-gui to be precise) does not create ui_xxx.h files (anymore?). I already searched the internet for a solution, but it seems I'm the only person with that issue ;)

For simplicity reasons and to eliminate my individual mistakes or stupidity I also tried the very basic setup found here:

https://github.com/euler0/mini-cmake-qt/blob/master/CMakeLists.txt

But still - no ui_xxx.h.

I tested this on two different (Windows 7 64-bit) machines with the same result.

As I already described in the subject of this post, I'm using cmake version 2.8.11.2 and qt 5.1. I set the environment variable QTDIR to "c:\Qt\Qt5.1.0\5.1.0\msvc2010\" and added "%QTDIR%\bin" to PATH.

With the CMakeLists.txt file used in the link above the only warnings I get are that "Policy CMP0020 is not set" which can easily be turned off by adding "cmake_policy(SET CMP0020 OLD)" to the file.

What am I missing?

Upvotes: 1

Views: 1825

Answers (1)

Seamus
Seamus

Reputation: 43

Does really no one else have this problem?

I tried to further debug the issue, so I modified Qt5WidgetsMacros.cmake to output every variable it uses. My Qt5WidgetsMacros.cmake now looks like this:

function(PRINT_LIST caption items)
    set(i 1)
    foreach (item ${items})
        message(${caption} " " ${i} ": " ${item})
        math(EXPR i "${i}+1")
    endforeach()
endfunction()

# qt5_wrap_ui(outfiles inputfile ... )

function(QT5_WRAP_UI outfiles )
    set(options)
    set(oneValueArgs)
    set(multiValueArgs OPTIONS)

    cmake_parse_arguments(_WRAP_UI "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

    set(ui_files ${_WRAP_UI_UNPARSED_ARGUMENTS})
    set(ui_options ${_WRAP_UI_OPTIONS})

    PRINT_LIST("Option" "${options}")
    PRINT_LIST("oneValueArg" "${oneValueArgs}")
    PRINT_LIST("multiValueArg" "${multiValueArgs}")
    PRINT_LIST("ARGN" "${ARGN}")
    PRINT_LIST("UI file" "${ui_files}")
    PRINT_LIST("UI option" "${ui_options}")

    foreach(it ${ui_files})
        get_filename_component(outfile ${it} NAME_WE)
        message("outfile: " ${outfile})
        get_filename_component(infile ${it} ABSOLUTE)
        message("infile: " ${infile})
        set(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
        message("outfile: " ${outfile})
        message("Qt5Widgets_UIC_EXECUTABLE: " ${Qt5Widgets_UIC_EXECUTABLE})
        add_custom_command(OUTPUT ${outfile}
            COMMAND ${Qt5Widgets_UIC_EXECUTABLE}
            ARGS ${ui_options} -o ${outfile} ${infile}
            MAIN_DEPENDENCY ${infile} VERBATIM)
        list(APPEND ${outfiles} ${outfile})
    endforeach()

    PRINT_LIST("Outfile" "${outfiles}")
    set(${outfiles} ${${outfiles}} PARENT_SCOPE)
    PRINT_LIST("Outfile" "${outfiles}")
endfunction()

The output with the CMakeLists.txt file from the link in my original post - https://github.com/euler0/mini-cmake-qt/blob/master/CMakeLists.txt - is:

multiValueArg 1: OPTIONS
ARGN 1: ./ui/mainwindow.ui
UI file 1: ./ui/mainwindow.ui
outfile: mainwindow
infile: C:/t/test/ui/mainwindow.ui
outfile: C:/t/test/out/ui_mainwindow.h
Qt5Widgets_UIC_EXECUTABLE: Qt5::uic
Outfile 1: UI_HEADERS
Outfile 1: UI_HEADERS

Looks good I'd say, but still: no ui_mainwindow.h

For the sake of completeness, here are my qt-settings:

QT_SYSROOT:
QT_INSTALL_PREFIX:C:\Qt\Qt5.1.0\\5.1.0\msvc2012
QT_INSTALL_ARCHDATA:C:\Qt\Qt5.1.0\\5.1.0\msvc2012
QT_INSTALL_DATA:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\
QT_INSTALL_DOCS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\doc
QT_INSTALL_HEADERS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\include
QT_INSTALL_LIBS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\lib
QT_INSTALL_LIBEXECS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\libexec
QT_INSTALL_BINS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\bin
QT_INSTALL_TESTS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\tests
QT_INSTALL_PLUGINS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\plugins
QT_INSTALL_IMPORTS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\imports
QT_INSTALL_QML:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\qml
QT_INSTALL_TRANSLATIONS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\translations
QT_INSTALL_CONFIGURATION:
QT_INSTALL_EXAMPLES:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\examples
QT_INSTALL_DEMOS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\examples
QT_HOST_PREFIX:C:\Qt\Qt5.1.0\\5.1.0\msvc2012
QT_HOST_DATA:C:\Qt\Qt5.1.0\\5.1.0\msvc2012
QT_HOST_BINS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\bin
QT_HOST_LIBS:C:\Qt\Qt5.1.0\\5.1.0\msvc2012\lib
QMAKE_SPEC:win32-msvc2012
QMAKE_XSPEC:win32-msvc2012
QMAKE_VERSION:3.0
QT_VERSION:5.1.0

Any ideas?

Upvotes: 1

Related Questions