qtcmakeuic

cmake 2.8.12.2 AUTOUIC not working: bug or missing feature?


I'm building a Qt project with CMake. With cmake-3.8.2 on macOS or Windows everything ok. On Ubuntu 14, where I have cmake-2.8.12.2, moc is run, but uic is not run. In CMakeLists.txt I have:

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)

and the .ui file is not specified anywhere (but has the same of a class, so I have SDFDialog.h, SDFDialog.cpp, SDFDialog.ui)

On Ubuntu 14 with cmake-2.8.12.2 this is the output:

$ cmake --build .
Scanning dependencies of target v_repExtSDF_automoc
[  4%] Automoc for target v_repExtSDF
Generating moc_SDFDialog.cpp
Generating moc_UIFunctions.cpp
Generating moc_UIProxy.cpp
[  4%] Built target v_repExtSDF_automoc
Scanning dependencies of target v_repExtSDF
[  8%] Building CXX object CMakeFiles/v_repExtSDF.dir/ImportOptions.cpp.o
[ 12%] Building CXX object CMakeFiles/v_repExtSDF.dir/SDFDialog.cpp.o
/home/user/Development/V-REP_PRO_EDU_V3_4_0_64_Linux.rev9/programming/v_repExtSDF/SDFDialog.cpp:4:26: fatal error: ui_SDFDialog.h: No such file or directory
 #include "ui_SDFDialog.h"
                          ^
compilation terminated.
make[2]: *** [CMakeFiles/v_repExtSDF.dir/SDFDialog.cpp.o] Error 1
make[1]: *** [CMakeFiles/v_repExtSDF.dir/all] Error 2
make: *** [all] Error 2

while on macOS with cmake-3.8.2 uic is correctly run:

$ cmake --build .
Scanning dependencies of target v_repExtSDF_autogen
[  4%] Automatic MOC and UIC for target v_repExtSDF
Generating MOC source v_repExtSDF_autogen/EWIEGA46WW/moc_SDFDialog.cpp
Generating MOC source v_repExtSDF_autogen/EWIEGA46WW/moc_UIFunctions.cpp
Generating MOC source v_repExtSDF_autogen/EWIEGA46WW/moc_UIProxy.cpp
Generating MOC compilation v_repExtSDF_autogen/moc_compilation.cpp
Generating UIC header v_repExtSDF_autogen/include/ui_SDFDialog.h
[  4%] Built target v_repExtSDF_autogen
...

Is this a bug or missing feature? In case it is a missing feature, what's the minimum required cmake version ? Is there some workaround to make uic run also on cmake-2.8.12.2 without changing the CMakeLists.txt too much?


Solution

  • thanks to the info given by @vre and @Antwane, I added this workaround to my CMakeLists.txt and now it supports CMake 2.8 too:

    if(${CMAKE_VERSION} VERSION_LESS 3.0)
        qt5_wrap_ui(FORMS SDFDialog.ui)
        add_custom_target(uic_cmake28_compat ALL DEPENDS ${FORMS})
    endif()
    

    I'll eventually get rid of this workaround when Ubuntu 14.04 goes end of life.