This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How to tell CMake to use QT+=network

Tags: None
(comma "," separated)
PhilippM
Registered Member
Posts
2
Karma
0
OS
Hi everyone,

until now I only used qmake, where it is easy to tell that my application needs to link to QtNetwork.so, by just adding the line QT+=network.

Now I want to play with plasmoids, starting with the tutorial provided as a sample project with Kdevelop 4.

This is configured via cmake. It works perfectly, until I start using QHttp. Then I get undefined reference errors when linking. It's obvious that I need to tell cmake that i need QTNetwork.

But I have no idea how to this with Cmake.

This is the (auto-generated) cmakelists.txt
Code: Select all
# Project Needs a name ofcourse
project(plasma-networkplasma)
 
# Find the required Libaries
find_package(KDE4 REQUIRED)
include(KDE4Defaults)
 
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
include_directories(
   ${CMAKE_SOURCE_DIR}
   ${CMAKE_BINARY_DIR}
   ${KDE4_INCLUDES}
   )

# We add our source code here
set(networkplasma_SRCS networkplasma.cpp)
 
# Now make sure all files get to the right place
kde4_add_plugin(plasma_applet_networkplasma ${networkplasma_SRCS})
target_link_libraries(plasma_applet_networkplasma
                      ${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS})
 
install(TARGETS plasma_applet_networkplasma
        DESTINATION ${PLUGIN_INSTALL_DIR})
 
install(FILES plasma-applet-networkplasma.desktop
        DESTINATION ${SERVICES_INSTALL_DIR})



Via google I found set(QT_USE_QTNETWORK TRUE) but I don't know where to insert it and after several tries still get undefined references.

So how to setup this correctly?

Regards,
Phil
pinotree
KDE Developer
Posts
222
Karma
7
OS
Add ${QT_QTNETWORK_LIBRARY} to your target_link_libraries().


Pino Toscano
PhilippM
Registered Member
Posts
2
Karma
0
OS
Funziona. Mille grazie! :)


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]