From d3b33e55124a0c8a05eb2fdad5d8a99b989515cd Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 21 Jun 2019 12:54:53 -0700 Subject: [PATCH] Can now build the Windows UI via CMake as well --- CMakeLists.txt | 4 +- windows/WinUI/App.config | 2 +- windows/WinUI/CMakeLists.txt | 128 ++++++++++++++++++ windows/WinUI/NetworkMonitor.cs | 2 +- windows/WinUI/Properties/AssemblyInfo.cs | 2 +- .../WinUI/Properties/Resources.Designer.cs | 20 ++- windows/copyutil/CMakeLists.txt | 12 ++ 7 files changed, 161 insertions(+), 9 deletions(-) create mode 100644 windows/WinUI/CMakeLists.txt create mode 100644 windows/copyutil/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 3541353d5..ab9572cad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # CMake build script for ZeroTier One -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 3.8) project (zerotier-one) option(BUILD_CENTRAL_CONTROLLER "Build ZeroTier Central Controller" OFF) @@ -35,6 +35,8 @@ add_subdirectory(osdep) add_subdirectory(service) if(WIN32) + add_subdirectory("windows/WinUI") + add_subdirectory("windows/copyutil") add_definitions(-DNOMINMAX) endif(WIN32) diff --git a/windows/WinUI/App.config b/windows/WinUI/App.config index 8e1564635..88fa4027b 100644 --- a/windows/WinUI/App.config +++ b/windows/WinUI/App.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/windows/WinUI/CMakeLists.txt b/windows/WinUI/CMakeLists.txt new file mode 100644 index 000000000..54cbbc6e1 --- /dev/null +++ b/windows/WinUI/CMakeLists.txt @@ -0,0 +1,128 @@ +cmake_minimum_required(VERSION 3.8) +include(CSharpUtilities) + +project("ZeroTierOneUI" VERSION 1.4.0 LANGUAGES CSharp) + +add_executable( + ${PROJECT_NAME} + app.manifest + App.config + App.xaml + App.xaml.cs + + AboutView.xaml + AboutView.xaml.cs + APIHandler.cs + CentralAPI.cs + CentralLogin.cs + CentralNetwork.cs + CentralServer.cs + CentralToken.cs + CentralUser.cs + ISwitchable.cs + JoinNetworkView.xaml + JoinNetworkView.xaml.cs + NetworkInfoView.xaml + NetworkInfoView.xaml.cs + NetworkListView.xaml + NetworkListView.xaml.cs + NetworkMonitor.cs + NetworkNameGenerator.cs + NetworkRoute.cs + NetworksPage.xaml + NetworksPage.xaml.cs + PeersPage.xaml + PeersPage.xaml.cs + PreferencesView.xaml + PreferencesView.xaml.cs + "Simple Styles.xaml" + ToolbarItem.xaml + ToolbarItem.xaml.cs + ZeroTierNetwork.cs + ZeroTierPeer.cs + ZeroTierPeerPhysicalPath.cs + ZeroTierStatus.cs + + packages.config + + "Properties/AssemblyInfo.cs" + "Properties/Resources.Designer.cs" + "Properties/Resources.resx" + "Properties/Settings.Designer.cs" + "Properties/Settings.settings" + + "Resources/ZeroTierIcon.ico" + ZeroTierIcon.ico +) + +csharp_set_designer_cs_properties( + "Properties/AssemblyInfo.cs" + "Properties/Resources.Designer.cs" + "Properties/Resources.resx" + "Properties/Settings.Designer.cs" + "Properties/Settings.settings" +) + +csharp_set_xaml_cs_properties( + App.xaml + App.xaml.cs + AboutView.xaml + AboutView.xaml.cs + JoinNetworkView.xaml + JoinNetworkView.xaml.cs + NetworkInfoView.xaml + NetworkInfoView.xaml.cs + NetworkListView.xaml + NetworkListView.xaml.cs + NetworksPage.xaml + NetworksPage.xaml.cs + PeersPage.xaml + PeersPage.xaml.cs + PreferencesView.xaml + PreferencesView.xaml.cs + ToolbarItem.xaml + ToolbarItem.xaml.cs +) + +set_property(SOURCE App.xaml PROPERTY VS_XAML_TYPE "ApplicationDefinition") + +set_property(SOURCE ZeroTierIcon.ico PROPERTY VS_TOOL_OVERRIDE "Resource") + +set_target_properties(${PROJECT_NAME} PROPERTIES + VS_GLOBAL_ROOTNAMESPACE "WinUI" + VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.5.2" + WIN32_EXECUTABLE TRUE + ) + +set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCES + "Microsoft.CSharp" + "PresentationCore" + "PresentationFramework" + "System" + "System.Core" + "System.Data" + "System.Data.DataSetExtensions" + "System.Drawing" + "System.Net.Http" + "System.Xaml" + "System.Xml" + "System.Xml.Linq" + "WindowsBase" + "Newtonsoft.Json" +) + +set(CMAKE_CSharp_FLAGS "/langversion:6") + +target_compile_options(${PROJECT_NAME} PRIVATE "/win32icon:${CMAKE_CURRENT_SOURCE_DIR}/ZeroTierIcon.ico") +set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCE_Hardcodet.Wpf.TaskbarNotification "${CMAKE_CURRENT_BINARY_DIR}/packages/Hardcodet.NotifyIcon.Wpf.1.0.8/lib/net45/Hardcodet.Wpf.TaskbarNotification.dll") + +find_program(NUGET nuget) +add_custom_target(nuget-restore + COMMAND ${NUGET} restore ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.sln +) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/packages.config + ${CMAKE_CURRENT_BINARY_DIR}/packages.config COPYONLY) + +add_dependencies(${PROJECT_NAME} nuget-restore) + \ No newline at end of file diff --git a/windows/WinUI/NetworkMonitor.cs b/windows/WinUI/NetworkMonitor.cs index 927f804c4..b94c07852 100644 --- a/windows/WinUI/NetworkMonitor.cs +++ b/windows/WinUI/NetworkMonitor.cs @@ -58,7 +58,7 @@ namespace WinUI private void loadNetworks() { String dataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\ZeroTier\\One"; - String dataFile = Path.Combine(dataPath, "networks.dat"); + String dataFile = Path.Combine(dataPath, "networksv2.dat"); if (File.Exists(dataFile)) { diff --git a/windows/WinUI/Properties/AssemblyInfo.cs b/windows/WinUI/Properties/AssemblyInfo.cs index 9c7cd1339..a235ac285 100644 --- a/windows/WinUI/Properties/AssemblyInfo.cs +++ b/windows/WinUI/Properties/AssemblyInfo.cs @@ -12,7 +12,7 @@ using System.Windows; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("ZeroTier, Inc")] [assembly: AssemblyProduct("ZeroTier One")] -[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyCopyright("Copyright © 2015-2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/windows/WinUI/Properties/Resources.Designer.cs b/windows/WinUI/Properties/Resources.Designer.cs index 3e5c78aee..7e8b05965 100644 --- a/windows/WinUI/Properties/Resources.Designer.cs +++ b/windows/WinUI/Properties/Resources.Designer.cs @@ -19,10 +19,10 @@ namespace WinUI.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { + public class Resources { private static global::System.Resources.ResourceManager resourceMan; @@ -36,7 +36,7 @@ namespace WinUI.Properties { /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WinUI.Properties.Resources", typeof(Resources).Assembly); @@ -51,7 +51,7 @@ namespace WinUI.Properties { /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + public static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -63,7 +63,17 @@ namespace WinUI.Properties { /// /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). /// - internal static System.Drawing.Icon ZeroTierIcon { + public static System.Drawing.Icon Icon1 { + get { + object obj = ResourceManager.GetObject("Icon1", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// + public static System.Drawing.Icon ZeroTierIcon { get { object obj = ResourceManager.GetObject("ZeroTierIcon", resourceCulture); return ((System.Drawing.Icon)(obj)); diff --git a/windows/copyutil/CMakeLists.txt b/windows/copyutil/CMakeLists.txt new file mode 100644 index 000000000..f5e1215b5 --- /dev/null +++ b/windows/copyutil/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) +include(CSharpUtilities) + +project(copyutil VERSION 1.4.0 LANGUAGES CSharp) + +add_executable( + ${PROJECT_NAME} + App.config + Program.cs + + "Properties/AssemblyInfo.cs" +) \ No newline at end of file