3

I want to created a project that uses cmake as it's build system sn QTCreator

.
├── CMakeLists.txt
├── CMakeLists.txt.user
├── main.cpp
├── notepad.cpp
├── notepad.h
└── notepad.ui

here is my cmake file:-

cmake_minimum_required(VERSION 2.8)
project(Notepad)

set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -std=gnu++14")

find_package(Qt5Widgets REQUIRED)

set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)

add_executable(${PROJECT_NAME} main.cpp notepad.cpp)
target_link_libraries(Notepad Qt5::Widgets)

When I try to build it I get following error:-

AutoUic subprocess error
------------------------
uic failed for
  "/home/jucyref/Development/C++/Test/notepad/notepad.ui"
included by
  "/home/jucyref/Development/C++/Test/notepad/notepad.cpp"

Command
-------
/usr/bin/uic -o /home/jucyref/Development/C++/Test/build-notepad-C_C-Default/Notepad_autogen/include/ui_notepad.h /home/jucyref/Development/C++/Test/notepad/notepad.ui

Output
------
File '/home/jucyref/Development/C++/Test/notepad/notepad.ui' is not valid

.QtCreator's Design mode.it is disabled by default .what should I do. I am not very familiar with cmake and qt

  • 1
    According to the error message the problem is that your .ui file is not formed correctly, you could share your .ui file. I have created a similar project and your CMakeLists.txt works correctly. – eyllanesc Apr 26 '18 at 06:41

1 Answers1

1

You are missing UI headers in add_executable

more details on https://wiki.qt.io/Using_CMake_build_system

set ( SOURCES
..cpp
)

set ( MOC_HEADERS
 ..h
)

set ( UIS
 notepad.ui
)

set ( RESOURCES
 ..qrc
)
QT5_WRAP_UI( UI_HEADERS ${UIS} )

add_executable( PROJECT_NAME ${SOURCES} ${MOC_SRCS} ${RES_SOURCES} ${UI_HEADERS} )
Mandar
  • 1,006
  • 11
  • 28