Solution:
Add resource files in the add_executable()
statement
(not in the add_library()
)
Fa
I'm not sure if this is new or not, but I have figured out a way to add resources to libraries.
In my library's CMakeLists.txt I have the following:
list (APPEND RESOURCES library.qrc)
qt5_add_resources (RCC_SOURCES ${RESOURCES})
...
add_library(library ${RCC_SOURCES} ${SOURCES})
In the library, in one of my "main classes" (for me, this class was the first thing that gets created in the library and the last thing that gets destroyed), I did the following:
class libClass : public QMainWindow {
Q_OBJECT
public:
libClass() : QMainWindow(nullptr, 0) {
Q_INIT_RESOURCE(library);
}
~libClass() {
Q_CLEANUP_RESOURCE(library);
}
};
I think you need to link qrc_resources generated file.
I suppose you know the next info:
http://www.cmake.org/cmake/help/v3.0/manual/cmake-qt.7.html
Where you can see the next line:
add_executable(myexe main.cpp resource_file.qrc)
More info:
http://www.cmake.org/cmake/help/v3.0/prop_tgt/AUTORCC.html