Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ endif()
add_subdirectory("dock-network-plugin")
add_subdirectory("dss-network-plugin")
if (BUILD_EXAMPLE)
# add_subdirectory("example")
add_subdirectory("example")
add_subdirectory("dss_example")
add_subdirectory("dock-example")
endif()
Expand Down
116 changes: 29 additions & 87 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,107 +3,49 @@ cmake_minimum_required(VERSION 3.7)
project(example)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_PREFIX_PATH $ENV{Qt5_DIR})
set(CMAKE_PREFIX_PATH $ENV{Qt6_DIR})
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

find_package(DdeControlCenter REQUIRED)
find_package(Qt6 COMPONENTS Core DBus Widgets Network REQUIRED)
find_package(KF6NetworkManagerQt REQUIRED)
find_package(Dtk6 COMPONENTS Widget REQUIRED)
find_package(PkgConfig REQUIRED)

aux_source_directory(../dcc-network-plugin DCCPLUGINDIR)
aux_source_directory(../dcc-network-plugin/window DCCPLUGINWINDOWDIR)
aux_source_directory(../dcc-network-plugin/sections DCCPLUGINSECTIONS)
aux_source_directory(../dcc-network-plugin/sections/vpn DCCPLUGINSECTIONSVPN)
aux_source_directory(../dcc-network-plugin/settings DCCPLUGINSETTINGS)
aux_source_directory(../dcc-network-plugin/settings/vpn DCCPLUGINVPNSETTINGS)
aux_source_directory(../dcc-network-plugin/themes DCCPLUGINTHEMES)

file(GLOB_RECURSE QRCFILE "./example.qrc"
"../dcc-network-plugin/icons/dcc-network-plugin.qrc"
"../dcc-network-plugin/icons/actions/*.svg"
"../dcc-network-plugin/icons/icons/*.svg")

set(COMPILEFILES
./networkhandler.h
./networkhandler.cpp
./moduledatamodel.h
./moduledatamodel.cpp
./main.cpp
./dccplugintestwidget.h
./dccplugintestwidget.cpp)

file(GLOB_RECURSE DCCPLUGINSRCS
"../dcc-network-plugin/*.h"
"../dcc-network-plugin/*.cpp"
"../dcc-network-plugin/icons/*"
)
#message(${DCCPLUGINDIR})
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
ADD_DEFINITIONS(-DSERVICE_CONFIG_DIR="${CMAKE_BINARY_DIR}/share/")
ADD_DEFINITIONS(-DSERVICE_LIB_DIR="${CMAKE_BINARY_DIR}/network-service-plugin/")
else()
ADD_DEFINITIONS(-DSERVICE_CONFIG_DIR="${CMAKE_INSTALL_PREFIX}/share/deepin-service-manager/")
ADD_DEFINITIONS(-DSERVICE_LIB_DIR="${CMAKE_INSTALL_FULL_LIBDIR}/deepin-service-manager/")
endif()

#list(REMOVE_ITEM NETWORKDIR "../dde-network-core/debian")
# 包含example自己的源文件
file(GLOB COMPILEFILES "*.cpp" "*.h" "service/*.cpp" "service/*.h")
file(GLOB_RECURSE QRCFILE "*.qrc")

add_executable(${PROJECT_NAME}
${COMPILEFILES}
${DCCPLUGINSRCS}
${REALIZEDIR}
${QRCFILE})

find_package(Qt5 COMPONENTS Core DBus Concurrent Network REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(KF5NetworkManagerQt REQUIRED)
find_package(DtkWidget REQUIRED)

get_target_property(KF5_QT_INCLUDE_DIRS KF5::NetworkManagerQt INTERFACE_INCLUDE_DIRECTORIES)

foreach(LETTER ${TRY_KF5_LIBRARIES})
if (NOT KF5_QT_LIBRARIES)
get_target_property(KF5_QT_LIBRARIES KF5::NetworkManagerQt ${LETTER})
endif()
endforeach()

if (NOT KF5_QT_LIBRARIES)
find_library(KF5_QT_LIBRARIES libKF5NetworkManagerQt.so)
endif()

set(TRY_KF5_LIBRARIES
IMPORTED_LOCATION_DEBIAN
IMPORTED_LOCATION_NOCONFIG
${QRCFILE}
)

target_include_directories(${PROJECT_NAME} PUBLIC
../dcc-network-plugin
../dcc-network-plugin/window
../dcc-network-plugin/operation
${DdeControlCenter_INCLUDE_DIR}
${DtkWidget_INCLUDE_DIRS}
${Qt5Core_INCLUDE_DIRS}
${Qt5DBus_INCLUDE_DIRS}
${Qt5Widget_INCLUDE_DIRS}
Qt5::Concurrent
${QGSettings_INCLUDE_DIRS}
#${LibNM_INCLUDE_DIRS}
${Qt5Network_INCLUDE_DIRS}
${KF5_QT_INCLUDE_DIRS}
.
./service
../src
Dtk6::Widget
Qt6::DBus
Qt6::Network
Qt6::Widgets
KF6::NetworkManagerQt
${DDE-Network-Core_INCLUDE_DIRS}
)

target_link_libraries(${PROJECT_NAME} PRIVATE
${DdeControlCenter_LIBRARIES}
${DCC_INTERFACE_LIBRARIES}
${DCC_WIDGETS_LIBRARIES}
${DtkWidget_LIBRARIES}
${Qt5Core_LIBRARIES}
${Qt5Widgets_LIBRARIES}
Qt5::Concurrent
#${LibNM_LIBRARIES}
${Qt5DBus_LIBRARIES}
${Qt5Network_LIBRARIES}
${QGSettings_LIBRARIES}
${KF5_QT_LIBRARIES}
${DDE-Network-Core_LIBRARIES}
Dtk6::Widget
Qt6::DBus
Qt6::Network
Qt6::Widgets
KF6::NetworkManagerQt
dde-network-core6
)

add_custom_command(
OUTPUT path.pb.cc path.pb.h
COMMAND protoc
ARGS --cpp_out . ${CMAKE_CURRENT_SOURCE_DIR}/path.proto -I ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS path.proto)
Loading