diff --git Portfile Portfile
index 0ed2653..0c49b15 100644
--- Portfile
+++ Portfile
@@ -2,10 +2,11 @@
 # $Id: Portfile 137092 2015-06-04 20:38:23Z cal@macports.org $
 
 PortSystem          1.0
+PortGroup           cmake 1.0
 PortGroup           github 1.0
 PortGroup           qt5 1.0
 
-github.setup        openconnect openconnect-gui 1.3 v
+github.setup        openconnect openconnect-gui 1.4.1 v
 categories          net
 platforms           darwin
 maintainers         hydroxide.nl:bjorn.ketelaars openmaintainer
@@ -19,20 +20,26 @@ depends_lib-append  port:gnutls \
 
 depends_run         port:vpnc-scripts
 
-checksums           rmd160  2ee0a3bf301b3c9af6bb3b7663875afea6f0a307 \
-                    sha256  7377a5e3de6e5b0764723d66fbd0a1d8b380ddbb5b3862714197a4ba47ee8982
+checksums           rmd160  f531bf977764aeb773657d32c94b0870acf14527 \
+                    sha256  7415a385269866cfeacde2fee7ae8bb029b4de0fcd3260260fc7bc0ed51c8eae
 
-patchfiles          patch-common_h.diff
+patchfiles          patch-CMakeLists_txt.diff \
+                    patch-bundle_qt_conf.diff \
+                    patch-src_CMakeLists_txt.diff \
+                    patch-src_dialog_editdialog_ui.diff \
+                    patch-src_dialog_mainwindow_ui.diff \
+                    patch-src_main_cpp.diff \
+                    patch-src_vpninfo_cpp.diff \
+                    patch-src_vpninfo_h.diff
 
-configure.cmd       ${qt_qmake_cmd}
-configure.pre_args  PREFIX="${prefix}"
+cmake.out_of_source yes
 
 post-patch {
-    reinplace -E "s|@PREFIX@|${prefix}|" ${worksrcpath}/common.h
+    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/CMakeLists.txt
 }
 
 destroot {
-    copy "${worksrcpath}/openconnect-gui.app" ${destroot}${applications_dir}
+    copy "${workpath}/build/bin/openconnect-gui.app" ${destroot}${applications_dir}
 }
 
 livecheck.url       https://github.com/openconnect/openconnect-gui/releases
diff --git files/patch-CMakeLists_txt.diff files/patch-CMakeLists_txt.diff
new file mode 100644
index 0000000..d18599d
--- /dev/null
+++ files/patch-CMakeLists_txt.diff
@@ -0,0 +1,55 @@
+--- CMakeLists.txt.orig	2016-10-05 18:39:23.000000000 +0200
++++ CMakeLists.txt	2016-10-05 18:41:33.000000000 +0200
+@@ -1,4 +1,15 @@
+ cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
++
++if(APPLE)
++	if(NOT CMAKE_OSX_SYSROOT)
++		set(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk" CACHE STRING "" FORCE)
++	endif()
++
++	if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
++		set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "" FORCE)
++	endif()
++endif()
++
+ project(openconnect-gui
+     VERSION 1.4.1
+     LANGUAGES CXX
+@@ -18,7 +29,7 @@ if(WIN32 AND MINGW)
+ 
+     set(DEFAULT_VPNC_SCRIPT "vpnc-script.js")
+ else(APPLE)
+-    set(DEFAULT_VPNC_SCRIPT "../Resources/vpnc-script")
++    set(DEFAULT_VPNC_SCRIPT "@PREFIX@/etc/vpnc-scripts/vpnc-script")
+ else()
+     set(DEFAULT_VPNC_SCRIPT "/etc/vpnc/vpnc-script")
+ endif()
+@@ -48,6 +59,9 @@ find_package(Qt5 5.6 REQUIRED COMPONENTS
+ if(WIN32 AND MINGW)
+     get_target_property(_qwindows_dll Qt5::QWindowsIntegrationPlugin LOCATION)
+ endif()
++if(APPLE)
++    get_target_property(_qcocoa_dylib Qt5::QCocoaIntegrationPlugin LOCATION)
++endif()
+ 
+ include(clang-format)
+ 
+@@ -66,6 +80,17 @@ else()
+     find_package(OpenConnect REQUIRED)
+     link_directories(${OPENCONNECT_LIBRARY_DIRS})
+     include_directories(SYSTEM ${OPENCONNECT_INCLUDE_DIRS})
++
++    find_library(SECURITY_LIBRARY Security REQUIRED)
++    if(SECURITY_LIBRARY)
++        message(STATUS "Framework 'Security' found at ${SECURITY_LIBRARY}")
++
++        link_directories(${SECURITY_LIBRARY_DIRS})
++        include_directories(SYSTEM ${SECURITY_LIBRARY_INCLUDE_DIRS})
++    else()
++        message(FATAL_ERROR "Framework 'Security' not found!")
++    endif()
++    mark_as_advanced(SECURITY_LIBRARY)
+ endif()
+ 
+ add_subdirectory(src)
diff --git files/patch-bundle_qt_conf.diff files/patch-bundle_qt_conf.diff
new file mode 100644
index 0000000..a9f7547
--- /dev/null
+++ files/patch-bundle_qt_conf.diff
@@ -0,0 +1,5 @@
+--- /dev/null
++++ bundle/qt.conf
+@@ -0,0 +1,2 @@
++[Paths]
++Plugins = PlugIns
diff --git files/patch-common_h.diff files/patch-common_h.diff
deleted file mode 100644
index e830704..0000000
--- files/patch-common_h.diff
+++ /dev/null
@@ -1,20 +0,0 @@
---- common.h.orig	2016-07-12 20:00:11.000000000 +0200
-+++ common.h	2016-07-12 19:58:32.000000000 +0200
-@@ -25,7 +25,7 @@
- 
- #define VERSION "1.3"
- #define APP_NAME "openconnect-gui"
--#define APP_STRING APP_NAME" "VERSION
-+#define APP_STRING APP_NAME " " VERSION
- 
- #define toAscii toLatin1
- 
-@@ -54,7 +54,7 @@
- #include <fcntl.h>
- #include <errno.h>
- #define ms_sleep(x) usleep(1000*x)
--#define DEFAULT_VPNC_SCRIPT "/etc/vpnc/vpnc-script"
-+#define DEFAULT_VPNC_SCRIPT "@PREFIX@/etc/vpnc-scripts/vpnc-script"
- #define INVALID_SOCKET -1
- #define SOCKET int
- #define closesocket close
diff --git files/patch-src_CMakeLists_txt.diff files/patch-src_CMakeLists_txt.diff
new file mode 100644
index 0000000..ab8cd67
--- /dev/null
+++ files/patch-src_CMakeLists_txt.diff
@@ -0,0 +1,77 @@
+--- src/CMakeLists.txt
++++ src/CMakeLists.txt
+@@ -96,8 +96,8 @@ if(APPLE)
+         MACOSX_BUNDLE_GUI_IDENTIFIER "io.github.openconnect.openconnect-gui"
+         MACOSX_BUNDLE_ICON_FILE "mono_lock.icns"
+         MACOSX_BUNDLE_INFO_STRING ${PRODUCT_NAME_LONG}
+-        MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION}
+-        MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
++#        MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION}
++#        MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
+     )
+ endif()
+ 
+@@ -129,6 +129,11 @@ if(UNIX)
+         ${OPENCONNECT_LIBRARIES}
+         ${GNUTLS_LIBRARY}
+     )
++    if(APPLE)
++        target_link_libraries (${PROJECT_NAME}
++            ${SECURITY_LIBRARY}
++        )
++    endif()
+ endif()
+ 
+ # install executable
+@@ -139,9 +144,11 @@ install(TARGETS ${PROJECT_NAME}
+ )
+ 
+ # fixup the bundle
+-#get_target_property(QT_LIBRARY_DIR Qt5::Core LOCATION)
+-#get_filename_component(QT_LIBRARY_DIR ${QT_LIBRARY_DIR} PATH)
+-#get_filename_component(QT_LIBRARY_DIR "${QT_LIBRARY_DIR}/.." ABSOLUTE)
++get_target_property(QT_LIBRARY_DIR Qt5::Core LOCATION)
++get_filename_component(QT_LIBRARY_DIR ${QT_LIBRARY_DIR} PATH)
++get_filename_component(QT_LIBRARY_DIR "${QT_LIBRARY_DIR}/.." ABSOLUTE)
++list(APPEND libSearchDirs ${QT_LIBRARY_DIR})
++
+ if(WIN32 AND MINGW)
+     set(APPS "\${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.exe")
+     list(APPEND libSearchDirs ${CMAKE_SOURCE_DIR}/nsis)
+@@ -157,13 +164,34 @@ if(WIN32 AND MINGW)
+ 		DESTINATION .
+ 		COMPONENT App
+ 	)
+-else()
++
++	set(additionalLib ${_qwindows_dll})
++elseif(APPLE)
+     set(APPS "\${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app")
+     list(APPEND libSearchDirs "")
++
++	# Qt Platform Plugin
++	install(FILES
++		${_qcocoa_dylib}
++		DESTINATION ${PROJECT_NAME}.app/Contents/PlugIns/platforms
++		COMPONENT App
++	)
++	install(FILES
++		${CMAKE_SOURCE_DIR}/bundle/qt.conf
++		DESTINATION ${PROJECT_NAME}.app/Contents/Resources
++		COMPONENT App
++	)
++
++	set(additionalLib \${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app/Contents/PlugIns/platforms/libqcocoa.dylib)
++else()
++	message(FATAL_ERROR "XXX: only mingw and apple build supported yet")
+ endif()
+-set(additionalLib ${_qwindows_dll})
++
+ install(CODE "
+     include(BundleUtilities)
++	if(APPLE)
++		set(BU_CHMOD_BUNDLE_ITEMS on)
++	endif()
+     fixup_bundle(\"${APPS}\" \"${additionalLib}\" \"${libSearchDirs}\")
+     " DESTINATION . COMPONENT App
+ )
diff --git files/patch-src_dialog_editdialog_ui.diff files/patch-src_dialog_editdialog_ui.diff
new file mode 100644
index 0000000..d814125
--- /dev/null
+++ files/patch-src_dialog_editdialog_ui.diff
@@ -0,0 +1,32 @@
+--- src/dialog/editdialog.ui
++++ src/dialog/editdialog.ui
+@@ -16,6 +16,9 @@
+   <layout class="QVBoxLayout" name="verticalLayout">
+    <item>
+     <layout class="QFormLayout" name="settingsProfileLayout">
++     <property name="fieldGrowthPolicy">
++      <enum>QFormLayout::ExpandingFieldsGrow</enum>
++     </property>
+      <item row="0" column="0">
+       <widget class="QLabel" name="nameLabel">
+        <property name="text">
+@@ -278,6 +281,9 @@
+       <layout class="QVBoxLayout" name="verticalLayout_2">
+        <item>
+         <layout class="QFormLayout" name="formLayout_2">
++         <property name="fieldGrowthPolicy">
++          <enum>QFormLayout::ExpandingFieldsGrow</enum>
++         </property>
+          <item row="1" column="0">
+           <widget class="QLabel" name="userCertificateLabel">
+            <property name="text">
+@@ -409,6 +415,9 @@
+      <layout class="QVBoxLayout" name="verticalLayout_3">
+       <item>
+        <layout class="QFormLayout" name="formLayout_3">
++        <property name="fieldGrowthPolicy">
++         <enum>QFormLayout::ExpandingFieldsGrow</enum>
++        </property>
+         <item row="0" column="0">
+          <widget class="QLabel" name="reconnectTimeoutLabel">
+           <property name="text">
diff --git files/patch-src_dialog_mainwindow_ui.diff files/patch-src_dialog_mainwindow_ui.diff
new file mode 100644
index 0000000..68c4e19
--- /dev/null
+++ files/patch-src_dialog_mainwindow_ui.diff
@@ -0,0 +1,142 @@
+--- src/dialog/mainwindow.ui
++++ src/dialog/mainwindow.ui
+@@ -171,21 +171,21 @@
+        <layout class="QVBoxLayout" name="verticalLayout_3">
+         <item>
+          <layout class="QFormLayout" name="formLayout">
++          <property name="fieldGrowthPolicy">
++           <enum>QFormLayout::ExpandingFieldsGrow</enum>
++          </property>
++          <property name="formAlignment">
++           <set>Qt::AlignJustify|Qt::AlignTop</set>
++          </property>
+           <item row="0" column="0">
+            <widget class="QLabel" name="ipV4LabelText">
+             <property name="text">
+              <string>IPv4:</string>
+             </property>
+-            <property name="alignment">
+-             <set>Qt::AlignCenter</set>
+-            </property>
+            </widget>
+           </item>
+           <item row="0" column="1">
+            <widget class="QLabel" name="ipV4Label">
+-            <property name="text">
+-             <string/>
+-            </property>
+             <property name="alignment">
+              <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+             </property>
+@@ -206,9 +206,6 @@
+           </item>
+           <item row="1" column="1">
+            <widget class="QLabel" name="ipV6Label">
+-            <property name="text">
+-             <string/>
+-            </property>
+             <property name="alignment">
+              <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+             </property>
+@@ -225,16 +222,10 @@
+             <property name="text">
+              <string>DNS:</string>
+             </property>
+-            <property name="alignment">
+-             <set>Qt::AlignCenter</set>
+-            </property>
+            </widget>
+           </item>
+           <item row="2" column="1">
+            <widget class="QLabel" name="dnsLabel">
+-            <property name="text">
+-             <string/>
+-            </property>
+             <property name="alignment">
+              <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+             </property>
+@@ -255,9 +246,6 @@
+           </item>
+           <item row="3" column="1">
+            <widget class="QLabel" name="cipherCSTPLabel">
+-            <property name="text">
+-             <string/>
+-            </property>
+             <property name="alignment">
+              <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+             </property>
+@@ -272,40 +260,27 @@
+           </item>
+           <item row="4" column="1">
+            <widget class="QLabel" name="cipherDTLSLabel">
+-            <property name="text">
+-             <string/>
+-            </property>
+             <property name="alignment">
+              <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+             </property>
+            </widget>
+           </item>
+-         </layout>
+-        </item>
+-        <item>
+-         <widget class="Line" name="line">
+-          <property name="orientation">
+-           <enum>Qt::Horizontal</enum>
+-          </property>
+-         </widget>
+-        </item>
+-        <item>
+-         <layout class="QFormLayout" name="formLayout_2">
+-          <item row="0" column="0">
+-           <widget class="QLabel" name="uploadLaberText">
++          <item row="5" column="0">
++           <widget class="QLabel" name="downloadLabelText">
+             <property name="text">
+-             <string>Upload:</string>
+-            </property>
+-            <property name="alignment">
+-             <set>Qt::AlignCenter</set>
++             <string>Download:</string>
+             </property>
+            </widget>
+           </item>
+-          <item row="0" column="1">
+-           <widget class="QLabel" name="uploadLabel">
++          <item row="6" column="0">
++           <widget class="QLabel" name="uploadLaberText">
+             <property name="text">
+-             <string/>
++             <string>Upload:</string>
+             </property>
++           </widget>
++          </item>
++          <item row="5" column="1">
++           <widget class="QLabel" name="downloadLabel">
+             <property name="alignment">
+              <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+             </property>
+@@ -317,21 +292,8 @@
+             </property>
+            </widget>
+           </item>
+-          <item row="1" column="0">
+-           <widget class="QLabel" name="downloadLabelText">
+-            <property name="text">
+-             <string>Download:</string>
+-            </property>
+-            <property name="alignment">
+-             <set>Qt::AlignCenter</set>
+-            </property>
+-           </widget>
+-          </item>
+-          <item row="1" column="1">
+-           <widget class="QLabel" name="downloadLabel">
+-            <property name="text">
+-             <string/>
+-            </property>
++          <item row="6" column="1">
++           <widget class="QLabel" name="uploadLabel">
+             <property name="alignment">
+              <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+             </property>
diff --git files/patch-src_main_cpp.diff files/patch-src_main_cpp.diff
new file mode 100644
index 0000000..e07abf0
--- /dev/null
+++ files/patch-src_main_cpp.diff
@@ -0,0 +1,103 @@
+--- src/main.cpp
++++ src/main.cpp
+@@ -37,10 +37,14 @@ extern "C" {
+ #include <QSettings>
+ #endif
+ 
++#ifdef __MACH__
++#include <mach-o/dyld.h>
++#include <Security/Security.h>
++#endif
++
+ #include <csignal>
+ #include <cstdio>
+ 
+-#ifdef PROJ_GNUTLS_DEBUG
+ static QStringList* logger = nullptr;
+ 
+ static void log_func(int level, const char* str)
+@@ -50,6 +54,42 @@ static void log_func(int level, const char* str)
+         logger->append(s.trimmed());
+     }
+ }
++
++#ifdef __MACH__
++bool relaunch_as_root()
++{
++    QMessageBox msgBox;
++    char appPath[2048];
++    uint32_t size = sizeof(appPath);
++    AuthorizationRef authRef;
++    OSStatus status;
++
++    /* Get the path of the current program */
++    if (_NSGetExecutablePath(appPath, &size) != 0) {
++        msgBox.setText(QObject::tr
++            ("Could not get program path to elevate privileges."));
++        return false;
++    }
++
++    status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment,
++        kAuthorizationFlagDefaults, &authRef);
++
++    if (status != errAuthorizationSuccess) {
++        msgBox.setText(QObject::tr
++            ("Failed to create authorization reference."));
++        return false;
++    }
++    status = AuthorizationExecuteWithPrivileges(authRef, appPath,
++        kAuthorizationFlagDefaults, NULL, NULL);
++    AuthorizationFree(authRef, kAuthorizationFlagDestroyRights);
++
++    if (status == errAuthorizationSuccess) {
++        /* We've successfully re-launched with root privs. */
++        return true;
++    }
++
++    return false;
++}
+ #endif
+ 
+ int pin_callback(void* userdata, int attempt, const char* token_url,
+@@ -89,6 +129,10 @@ int main(int argc, char* argv[])
+     QSettings::setDefaultFormat(QSettings::IniFormat);
+ #endif
+ 
++#ifdef __MACH__
++    /* Re-launching with root privs on OS X needs Qt to allow setsuid */
++    QApplication::setSetuidAllowed(true);
++#endif
+     QApplication app(argc, argv);
+     app.setQuitOnLastWindowClosed(false);
+     app.setApplicationName(appDescription);
+@@ -97,10 +141,14 @@ int main(int argc, char* argv[])
+     app.setOrganizationName(appOrganizationName);
+     app.setOrganizationDomain(appOrganizationDomain);
+ 
+-#if !defined(_WIN32) && !defined(PROJ_GNUTLS_DEBUG)
+-    if (getuid() != 0) {
+-        QMessageBox msgBox;
++#ifdef __MACH__
++    if (geteuid() != 0) {
++        if (relaunch_as_root()) {
++            /* We have re-launched with root privs. Exit this process. */
++            return 0;
++        }
+ 
++        QMessageBox msgBox;
+         msgBox.setText(QObject::tr("This program requires root privileges to fully function."));
+         msgBox.setInformativeText(QObject::tr("VPN connection establishment would fail."));
+         msgBox.exec();
+@@ -118,10 +166,10 @@ int main(int argc, char* argv[])
+     gnutls_pkcs11_set_pin_function(pin_callback, &mainWindow);
+ #endif
+ 
+-#ifdef PROJ_GNUTLS_DEBUG
+     gnutls_global_set_log_function(log_func);
+-    gnutls_global_set_log_level(3);
+     logger = mainWindow.get_log();
++#ifdef PROJ_GNUTLS_DEBUG
++    gnutls_global_set_log_level(3);
+     log_func(1, "started logging");
+ #endif
+ 
diff --git files/patch-src_vpninfo_cpp.diff files/patch-src_vpninfo_cpp.diff
new file mode 100644
index 0000000..d09ce0f
--- /dev/null
+++ files/patch-src_vpninfo_cpp.diff
@@ -0,0 +1,11 @@
+--- src/vpninfo.cpp
++++ src/vpninfo.cpp
+@@ -423,7 +423,7 @@ int VpnInfo::connect()
+ 
+ #ifdef Q_OS_WIN32
+     const QString osName{"win"};
+-#elif Q_OS_OSX
++#elif defined Q_OS_OSX
+     const QString osName{"mac-intel"};
+ #elif defined Q_OS_LINUX
+     const QString osName = QString("linux%1").arg(QSysInfo::buildCpuArchitecture() == "i386" ? "" : "-64").toStdString().c_str();
diff --git files/patch-src_vpninfo_h.diff files/patch-src_vpninfo_h.diff
new file mode 100644
index 0000000..867003e
--- /dev/null
+++ files/patch-src_vpninfo_h.diff
@@ -0,0 +1,11 @@
+--- src/vpninfo.h
++++ src/vpninfo.h
+@@ -22,6 +22,8 @@
+ #include <QString>
+ #ifdef _WIN32
+ #include <winsock2.h>
++#else
++#include "common.h"
+ #endif
+ #ifdef __linux__
+ #define SOCKET int
