I am preparing cmake build for qt application. where I am using following structure ..
libMyApp which uses
SET(QT5_MODULES Widgets PrintSupport Netw
The order of the entries in the function TARGET_LINK_LIBRARIES()
is important. The libraries with no dependecies shall be mentioned last which are typically some standard libraries or external libraries, in this example the Qt5 Libs.
An example:
Lib_A
depends on Lib_B
and Lib_std
Lib_B
depends on Lib_std
Lib_std
has no dependenciesThen the call of the function shall be the following:
TARGET_LINK_LIBRARIES(
${TARGET_NAME} # Name of the app
"Lib_A"
"Lib_B"
"Lib_std" # Last entries: Std Libs, external Libs, ...
)
In this application I assumed that ${CODE_LIB_FILES}=libMyApp.a
has some dependencies to the Qt5-Libs so it would be plausible to move this entry above the Qt5-Libs.
SET(QT5_MODULES Widgets PrintSupport XmlPatterns)
FIND_PACKAGE(Qt5 REQUIRED COMPONENTS ${QT5_MODULES})
TARGET_LINK_LIBRARIES(
${TARGET_NAME}
${CODE_LIB_FILES} # <<< Moved this entry up
Qt5::Widgets
Qt5::PrintSupport
Qt5::XmlPatterns
)