← Back to team overview

kicad-developers team mailing list archive

[PATCH] Fixes for Visual Studio / vcpkg build

 

Hi all,

I got a build working using Visual Studio 2019 and vcpkg.
Attached are three patches I needed to make so far.
I'd appreciate some double-checking on these since cmake and wxwidgets can
be a bit perilous.

Thanks,
-Jon
From 87674cb5a87b4d77683248b65994ef625f8a7c47 Mon Sep 17 00:00:00 2001
From: Jon Evans <evans@xxxxxxxxxxxx>
Date: Sun, 24 Nov 2019 12:30:29 -0500
Subject: [PATCH 1/3] Use wxArrayString instead of vector<wxString> in
 BUS_ALIAS

Fixes linker errors on Windows/VC
See: https://trac.wxwidgets.org/ticket/10884
---
 eeschema/bus_alias.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/eeschema/bus_alias.h b/eeschema/bus_alias.h
index 43073277f..b1e534007 100644
--- a/eeschema/bus_alias.h
+++ b/eeschema/bus_alias.h
@@ -22,8 +22,8 @@
 #define _BUS_ALIAS_H
 
 #include <memory>
-#include <vector>
 #include <wx/string.h>
+#include <wx/arrstr.h>
 
 
 class SCH_SCREEN;
@@ -66,7 +66,7 @@ public:
         return m_members.size();
     }
 
-    std::vector< wxString >& Members()
+    wxArrayString& Members()
     {
         return m_members;
     }
@@ -87,7 +87,7 @@ protected:
 
     wxString m_name;
 
-    std::vector< wxString > m_members;
+    wxArrayString m_members;
 
     /**
      * The bus alias editor dialog can edit aliases from all open sheets.
-- 
2.23.0.windows.1

From 913f66479a59b39e8b9f62c2c7738a5d4fa32c26 Mon Sep 17 00:00:00 2001
From: Jon Evans <evans@xxxxxxxxxxxx>
Date: Sun, 24 Nov 2019 12:31:44 -0500
Subject: [PATCH 2/3] Mark ERC compare operators as const

Not including these is a compile error on MSW/VC
---
 eeschema/erc.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp
index bf876c191..e7b01998a 100644
--- a/eeschema/erc.cpp
+++ b/eeschema/erc.cpp
@@ -664,7 +664,7 @@ void NETLIST_OBJECT_LIST::TestforNonOrphanLabel( unsigned aNetItemRef, unsigned
 // the full text is "sheetpath+label" for local labels and "label" for global labels
 struct compare_labels
 {
-    bool operator() ( const NETLIST_OBJECT* lab1, const NETLIST_OBJECT* lab2 )
+    bool operator() ( const NETLIST_OBJECT* lab1, const NETLIST_OBJECT* lab2 ) const
     {
         wxString str1 = lab1->m_SheetPath.Path() + lab1->m_Label;
         wxString str2 = lab2->m_SheetPath.Path() + lab2->m_Label;
@@ -675,7 +675,7 @@ struct compare_labels
 
 struct compare_label_names
 {
-    bool operator() ( const NETLIST_OBJECT* lab1, const NETLIST_OBJECT* lab2 )
+    bool operator() ( const NETLIST_OBJECT* lab1, const NETLIST_OBJECT* lab2 ) const
     {
         return lab1->m_Label.Cmp( lab2->m_Label ) < 0;
     }
@@ -683,7 +683,7 @@ struct compare_label_names
 
 struct compare_paths
 {
-    bool operator() ( const NETLIST_OBJECT* lab1, const NETLIST_OBJECT* lab2 )
+    bool operator() ( const NETLIST_OBJECT* lab1, const NETLIST_OBJECT* lab2 ) const
     {
         return lab1->m_SheetPath.Path().Cmp( lab2->m_SheetPath.Path() ) < 0;
     }
-- 
2.23.0.windows.1

From 5faf8f7894c2fcb25ce9b1f13db5dc268c425d2b Mon Sep 17 00:00:00 2001
From: Jon Evans <evans@xxxxxxxxxxxx>
Date: Sun, 24 Nov 2019 12:35:32 -0500
Subject: [PATCH 3/3] Update FindwxWidgets.cmake to work under MSW/vcpkg

Taken from: https://github.com/CaeruleusAqua/vcpkg-wx-find/blob/master/FindwxWidgets.cmake
---
 CMakeModules/FindwxWidgets.cmake | 140 +++++++++++++++++++++++--------
 1 file changed, 105 insertions(+), 35 deletions(-)

diff --git a/CMakeModules/FindwxWidgets.cmake b/CMakeModules/FindwxWidgets.cmake
index 6a8dc90e7..8263d2c44 100644
--- a/CMakeModules/FindwxWidgets.cmake
+++ b/CMakeModules/FindwxWidgets.cmake
@@ -509,41 +509,111 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
     else()
       set(WX_LIB_DIR_PREFIX vc)
     endif()
-    if(BUILD_SHARED_LIBS)
-      find_path(wxWidgets_LIB_DIR
-        NAMES
-          msw/wx/setup.h
-          mswd/wx/setup.h
-          mswu/wx/setup.h
-          mswud/wx/setup.h
-          mswuniv/wx/setup.h
-          mswunivd/wx/setup.h
-          mswunivu/wx/setup.h
-          mswunivud/wx/setup.h
-        PATHS
-        ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_dll   # prefer shared
-        ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_lib
-        DOC "Path to wxWidgets libraries"
-        NO_DEFAULT_PATH
-        )
-    else()
-      find_path(wxWidgets_LIB_DIR
-        NAMES
-          msw/wx/setup.h
-          mswd/wx/setup.h
-          mswu/wx/setup.h
-          mswud/wx/setup.h
-          mswuniv/wx/setup.h
-          mswunivd/wx/setup.h
-          mswunivu/wx/setup.h
-          mswunivud/wx/setup.h
-        PATHS
-        ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_lib   # prefer static
-        ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_dll
-        DOC "Path to wxWidgets libraries"
-        NO_DEFAULT_PATH
-        )
-    endif()
+	
+	if(VCPKG_TOOLCHAIN)
+		set(wxWidgets_FOUND TRUE)
+	    find_path(wxWidgets_ROOT_DIR
+			NAMES include/wx/wx.h
+			PATHS
+			ENV wxWidgets_ROOT_DIR
+			DOC "wxWidgets base/installation directory"
+			)
+		if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+			set(wxWidgets_LIB_DIR ${wxWidgets_ROOT_DIR}/debug/lib)
+			set(wxWidgets_CONFIGURATION mswud)
+		else()
+			set(wxWidgets_LIB_DIR ${wxWidgets_ROOT_DIR}/lib)
+			set(wxWidgets_CONFIGURATION mswu)
+		endif()
+
+		set(wxWidgets_BIN_DIR ${wxWidgets_ROOT_DIR}/bin)
+		set(wxWidgets_INCLUDE_DIR ${wxWidgets_ROOT_DIR}/include)
+		file(GLOB DLL ${wxWidgets_BIN_DIR}/wxmsw*.dll)
+		if (DLL)
+			set(wxWidgets_DEFINITIONS WXUSINGDLL)
+			DBG_MSG_V("detected SHARED/DLL tree wxWidgets_LIB_DIR=${wxWidgets_LIB_DIR}")
+		endif ()
+		set(WX_ROOT_DIR ${wxWidgets_ROOT_DIR})
+		set(WX_LIB_DIR ${wxWidgets_LIB_DIR})  # needed by macro
+		set(WX_CONFIGURATION_LIST ${wxWidgets_CONFIGURATION})
+
+		# Set wxWidgets lib setup include directory.
+		if (EXISTS ${wxWidgets_INCLUDE_DIR}/wx/setup.h)
+			set(wxWidgets_INCLUDE_DIRS ${wxWidgets_INCLUDE_DIR})
+		else ()
+			DBG_MSG("wxWidgets_FOUND FALSE because ${wxWidgets_INCLUDE_DIR}/wx/setup.h does not exists.")
+			set(wxWidgets_FOUND FALSE)
+		endif ()
+
+		# Set wxWidgets main include directory.
+		if (EXISTS ${wxWidgets_ROOT_DIR}/include/wx/wx.h)
+			list(APPEND wxWidgets_INCLUDE_DIRS ${wxWidgets_ROOT_DIR}/include)
+		else ()
+			DBG_MSG("wxWidgets_FOUND FALSE because wxWidgets_ROOT_DIR=${wxWidgets_ROOT_DIR} has no ${wxWidgets_ROOT_DIR}/include/wx/wx.h")
+			set(wxWidgets_FOUND FALSE)
+		endif ()
+
+		DBG_MSG_V("WX_CONFIGURATION_LIST=${WX_CONFIGURATION_LIST}")
+
+
+		# Get configuration parameters from the name.
+		WX_GET_NAME_COMPONENTS(${wxWidgets_CONFIGURATION} UNV UCD DBG)
+
+
+		# Find wxWidgets libraries.
+		WX_FIND_LIBS("${UNV}" "${UCD}" "${DBG}")
+		if (WX_USE_REL_AND_DBG)
+			WX_FIND_LIBS("${UNV}" "${UCD}" "d")
+		endif ()
+
+		# Settings for requested libs (i.e., include dir, libraries, etc.).
+		WX_SET_LIBRARIES(wxWidgets_FIND_COMPONENTS "${DBG}")
+
+		# Add necessary definitions for unicode builds
+		if ("${UCD}" STREQUAL "u")
+			list(APPEND wxWidgets_DEFINITIONS UNICODE _UNICODE)
+		endif ()
+
+		# Add necessary definitions for debug builds
+		set(wxWidgets_DEFINITIONS_DEBUG _DEBUG __WXDEBUG__)
+
+	else()
+		if(BUILD_SHARED_LIBS)
+		  find_path(wxWidgets_LIB_DIR
+			NAMES
+			  msw/wx/setup.h
+			  mswd/wx/setup.h
+			  mswu/wx/setup.h
+			  mswud/wx/setup.h
+			  mswuniv/wx/setup.h
+			  mswunivd/wx/setup.h
+			  mswunivu/wx/setup.h
+			  mswunivud/wx/setup.h
+			PATHS
+			${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_dll   # prefer shared
+			${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_lib
+			DOC "Path to wxWidgets libraries"
+			NO_DEFAULT_PATH
+			)
+		else()
+		  find_path(wxWidgets_LIB_DIR
+			NAMES
+			  msw/wx/setup.h
+			  mswd/wx/setup.h
+			  mswu/wx/setup.h
+			  mswud/wx/setup.h
+			  mswuniv/wx/setup.h
+			  mswunivd/wx/setup.h
+			  mswunivu/wx/setup.h
+			  mswunivud/wx/setup.h
+			PATHS
+			${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_lib   # prefer static
+			${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_dll
+			DOC "Path to wxWidgets libraries"
+			NO_DEFAULT_PATH
+			)
+		endif()
+	endif()
 
     # If wxWidgets_LIB_DIR changed, clear all libraries.
     if(NOT WX_LIB_DIR STREQUAL wxWidgets_LIB_DIR)
-- 
2.23.0.windows.1


Follow ups