Qt World Summit: Register Today!

cmake. add_subdirectory shows error "No such file or directory"

  • Hello!
    I want to move from the qmake to the cmake, that will my first experience with the cmake.
    I need to add some subdirectory contains the CMakeLists (similar *.pri using the qmake).


    Inside the internal CMakeLists i added next:

    cmake_minimum_required(VERSION 3.5)
            drcwidget.cpp drcwidget.h

    drcwidget uses QWidget. Finaly i got build error:

    drc/drcwidget.h:4:10: fatal error: QWidget: No such file or directory

    Why doesn't drc/CMakeLists.txt see QWidget included in main CMakeLists.txt?

  • Lifetime Qt Champion

    When you use a Qt library you also have to link against it. See e.g. the documentation for QWidget class - the first table.

Log in to reply