fferri
fferri

Reputation: 18940

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?

Upvotes: 0

Views: 1318

Answers (2)

fferri
fferri

Reputation: 18940

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.

Upvotes: 0

Antwane
Antwane

Reputation: 22598

AUTOMOC feature has been introduced by CMake 2.8.6. AUTOUIC feature has been introduced by CMake 3.0.x.

As a result, on Windows and macOS, you can use them since you have a CMake version including both features. On Ubuntu, your version 2.8.12 doesn't support AUTOUIC so you can't use it.

Source: https://cmake.org/cmake/help/v2.8.12/cmake.html

Since your Ubuntu version is very old, maybe it is a good idea to upgrade to the next LTS (16.04). Or, you could try to install a more recent CMake version:

Upvotes: 1

Related Questions