← Back to team overview

kicad-developers team mailing list archive

wxPython/wxWidgets compatibility check

 

In order to prevent faulty builds in case of wxPython/wxWidgets toolkit
mismatch [1,2] (gtk2 vs gtk3), I added a check in CMakeLists. I verified
it with Windows 7 and Linux, but I would love to hear from OSX users
that I do not break their build.

Cheers,
Orson

1. https://forum.kicad.info/t/9493
2. https://bugs.launchpad.net/kicad/+bug/1746753
>From 012f028b6cb5b83201e6e29f0aa2a51282d7c465 Mon Sep 17 00:00:00 2001
From: Maciej Suminski <maciej.suminski@xxxxxxx>
Date: Sat, 17 Feb 2018 13:29:05 +0100
Subject: [PATCH] CMakeLists: compare wxWidgets and wxPython toolkits

Having wxWidgets and wxPython build using different toolkits leads
to an unusable build. KiCad executables are linked against wxWidgets
shared libraries, which will be in conflict with wxPython ones that
are loaded at runtime. We cannot easily solve it, so at least warn
the users about expected problems.

More information:
https://forum.kicad.info/t/9493
https://bugs.launchpad.net/kicad/+bug/1746753
---
 CMakeLists.txt | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c4d1e62b9..2fd2ef9d9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -690,6 +690,28 @@ if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
 
     #message( STATUS "/ INC_AFTER:${INC_AFTER}" )
 
+
+    # Compare wxPython and wxWidgets toolkits
+    set( _py_cmd "import wx; print(wx.version().split(' ')[1])" )
+
+    # Add user specified Python site package path.
+    if( PYTHON_SITE_PACKAGE_PATH )
+        set( _py_cmd
+            "import sys;sys.path.insert(0, \"${PYTHON_SITE_PACKAGE_PATH}\");${_py_cmd}" )
+    endif()
+
+    execute_process( COMMAND ${PYTHON_EXECUTABLE} -c "${_py_cmd}"
+        RESULT_VARIABLE WXPYTHON_TOOLKIT_RESULT
+        OUTPUT_VARIABLE WXPYTHON_TOOLKIT_FOUND
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+
+    if( NOT wxWidgets_TOOLKIT_FOUND STREQUAL WXPYTHON_TOOLKIT_FOUND )
+        message( FATAL_ERROR "\nwxWidgets and wxPython use different toolkits "
+            "(${wxWidgets_TOOLKIT_FOUND} vs ${WXPYTHON_TOOLKIT_FOUND}). "
+            "It will result in a broken build." )
+    endif()
+
 endif()
 
 if( APPLE )
-- 
2.15.1


Follow ups