Commit 4cb6ba1b authored by Nicolas Fella's avatar Nicolas Fella
Browse files

[openconnect] Simplify CMake code

Drop support for <3.99 and related handling

Use pkgconfig and its imported target
parent bc73e7b4
......@@ -88,6 +88,9 @@ set_package_properties(KF5Prison PROPERTIES DESCRIPTION "Prison library"
PURPOSE "Needed to create mobile barcodes for WiFi networks"
)
find_package(PkgConfig REQUIRED)
pkg_check_modules(OPENCONNECT IMPORTED_TARGET openconnect>3.99)
if (DISABLE_MODEMMANAGER_SUPPORT)
message(STATUS "Disabling ModemManager support")
set(WITH_MODEMMANAGER_SUPPORT 0)
......
......@@ -3,7 +3,6 @@ include_directories(${CMAKE_SOURCE_DIR}/libs/editor/widgets)
add_subdirectory(fortisslvpn)
add_subdirectory(iodine)
add_subdirectory(l2tp)
add_subdirectory(openconnect)
add_subdirectory(openvpn)
add_subdirectory(openswan)
add_subdirectory(pptp)
......@@ -11,3 +10,7 @@ add_subdirectory(ssh)
add_subdirectory(sstp)
add_subdirectory(strongswan)
add_subdirectory(vpnc)
if(TARGET PkgConfig::OPENCONNECT)
add_subdirectory(openconnect)
endif()
add_definitions(-DTRANSLATION_DOMAIN=\"plasmanetworkmanagement_openconnectui\")
set (MINIMUM_OPENCONNECT_VERSION_REQUIRED "3.99")
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH})
find_package(OpenConnect ${MINIMUM_OPENCONNECT_VERSION_REQUIRED} MODULE)
if (OPENCONNECT_FOUND)
find_package(Qt5Xml ${QT_MIN_VERSION} CONFIG REQUIRED)
if (${OPENCONNECT_VERSION} VERSION_LESS "3.99")
# macro_optional_find_package(OpenSSL)
# macro_log_feature(OpenSSL_FOUND "OpenSSL headers" "Encryption suite" "https://www.openssl.org" FALSE "" "Needed for OpenConnect support in Network Management")
find_package(OpenSSL)
set_package_properties(OpenSSL PROPERTIES
DESCRIPTION "Encryption suite"
URL "https://www.openssl.org"
TYPE OPTIONAL
)
if (OpenSSL_FOUND)
set (MINIMUM_OPENCONNECT_VERSION_REQUIRED "3.03")
set (maybe_OPENSSL_LIBRARIES ${OpenSSL_LIBRARIES})
endif()
endif()
if (${OPENCONNECT_VERSION} VERSION_GREATER ${MINIMUM_OPENCONNECT_VERSION_REQUIRED} OR
${OPENCONNECT_VERSION} VERSION_EQUAL ${MINIMUM_OPENCONNECT_VERSION_REQUIRED})
include_directories(${OPENCONNECT_INCLUDE_DIRS})
set(openconnect_SRCS
../../libs/debug.cpp
openconnectui.cpp
openconnectwidget.cpp
openconnectauth.cpp
openconnectauthworkerthread.cpp
)
ki18n_wrap_ui(openconnect_SRCS openconnectprop.ui openconnectauth.ui openconnecttoken.ui)
add_library(plasmanetworkmanagement_openconnectui ${openconnect_SRCS})
target_link_libraries(plasmanetworkmanagement_openconnectui
plasmanm_internal
plasmanm_editor
${NETWORKMANAGERQT5_LDFLAGS}
KF5::CoreAddons
KF5::I18n
KF5::KIOWidgets
KF5::WidgetsAddons
Qt::Xml
${OPENCONNECT_LIBRARIES}
${maybe_OPENSSL_LIBRARIES}
)
install(TARGETS plasmanetworkmanagement_openconnectui DESTINATION ${KDE_INSTALL_PLUGINDIR})
install(FILES plasmanetworkmanagement_openconnectui.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
install(FILES plasmanetworkmanagement_openconnect_juniperui.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
install(FILES plasmanetworkmanagement_openconnect_globalprotectui.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
install(FILES plasmanetworkmanagement_openconnect_pulseui.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
else()
message("ERROR: OpenConnection version '${OPENCONNECT_VERSION}' does not match minimum required (${MINIMUM_OPENCONNECT_VERSION_REQUIRED})")
message("OpenConnect plugin will not be built")
set(OPENCONNECT_FOUND False)
endif()
else (OPENCONNECT_FOUND)
message("OpenConnect plugin will not be built")
endif (OPENCONNECT_FOUND)
#macro_log_feature(OPENCONNECT_FOUND "OpenConnect headers and library" "Cisco AnyConnect compatible VPN client" "http://www.infradead.org/openconnect.html" FALSE ${MINIMUM_OPENCONNECT_VERSION_REQUIRED} "Needed for OpenConnect support in Plasma NM")
set(openconnect_SRCS
../../libs/debug.cpp
openconnectui.cpp
openconnectwidget.cpp
openconnectauth.cpp
openconnectauthworkerthread.cpp
)
ki18n_wrap_ui(openconnect_SRCS openconnectprop.ui openconnectauth.ui openconnecttoken.ui)
add_library(plasmanetworkmanagement_openconnectui ${openconnect_SRCS})
target_link_libraries(plasmanetworkmanagement_openconnectui
plasmanm_internal
plasmanm_editor
KF5::NetworkManagerQt
KF5::CoreAddons
KF5::I18n
KF5::KIOWidgets
KF5::WidgetsAddons
Qt::Xml
PkgConfig::OPENCONNECT
)
install(TARGETS plasmanetworkmanagement_openconnectui DESTINATION ${KDE_INSTALL_PLUGINDIR})
install(FILES plasmanetworkmanagement_openconnectui.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
install(FILES plasmanetworkmanagement_openconnect_juniperui.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
install(FILES plasmanetworkmanagement_openconnect_globalprotectui.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
install(FILES plasmanetworkmanagement_openconnect_pulseui.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
# - Try to find OpenConnect
# Once done this will define
#
# OPENCONNECT_FOUND - system has OpenConnect
# OPENCONNECT_INCLUDE_DIRS - the OpenConnect include directories
# OPENCONNECT_LIBRARIES - the libraries needed to use OpenConnect
# OPENCONNECT_CFLAGS - Compiler switches required for using OpenConnect
# OPENCONNECT_VERSION - version number of OpenConnect
# SPDX-FileCopyrightText: 2011 Ilia Kats <ilia-kats@gmx.net>
#
# SPDX-License-Identifier: BSD-3-Clause
IF (OPENCONNECT_INCLUDE_DIRS)
# in cache already
SET(OpenConnect_FIND_QUIETLY TRUE)
ENDIF (OPENCONNECT_INCLUDE_DIRS)
IF (NOT WIN32)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
find_package(PkgConfig)
pkg_search_module(OPENCONNECT openconnect)
ENDIF (NOT WIN32)
IF (OPENCONNECT_FOUND)
IF (NOT OpenConnect_FIND_QUIETLY)
MESSAGE(STATUS "Found OpenConnect ${OPENCONNECT_VERSION}: ${OPENCONNECT_LIBRARIES}")
ENDIF (NOT OpenConnect_FIND_QUIETLY)
ELSE (OPENCONNECT_FOUND)
IF (OpenConnect_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could NOT find OpenConnect, check FindPkgConfig output above!")
ENDIF (OpenConnect_FIND_REQUIRED)
ENDIF (OPENCONNECT_FOUND)
MARK_AS_ADVANCED(OPENCONNECT_INCLUDE_DIRS OPENCONNECT_LIBRARIES OPENCONNECT_STATIC_LIBRARIES)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment