Veaceslav
Veaceslav

Reputation: 181

CMAKE: Include files not found with OBJECT

I have now a working CMake project which use Qt5 includes. Several parts of the project are compiled using

add_library(myLib STATIC ${lib_src})

I'm trying to make use of the OBJECT now, so I changed to

add_library(myLib OBJECT ${lib_src})

but, when compiling, I get the following error:

QObject, no such file or directory <- is not able to find qt includes

Can somebody tell me how can I fix my project to use OBJECT?

P.S. extra details: the project is hosted here: the main CMake which make the executable is in the app folder.

baloowrap lib is linked here in digikamgui, then digikamgui is linked into digikam executable and the OBJECT that I want to create is in utilities/baloo which contains the following:

set(baloowrap_SRCS baloowrap.cpp)
add_library(baloowrap STATIC ${baloowrap_SRCS})
target_link_libraries(baloowrap KF5::FileMetaData KF5::I18n)

Upvotes: 1

Views: 4514

Answers (1)

Veaceslav
Veaceslav

Reputation: 181

In my particular case, the include directories were automatically generated by CMake when I used target_link_libraries(Qt5::Core).

When you use OBJECT, you can't link anything and the sources fail to find the relevant includes...

http://doc.qt.io/qt-5/cmake-manual.html

you can solve the QObject problem by adding:

include_directories(${Qt5Widgets_INCLUDE_DIRS})

Upvotes: 3

Related Questions