From fad0452c0e25041158a31712560a6b7e0ed747b5 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 21 Feb 2018 17:46:46 +0100 Subject: [PATCH] Fix builds with scripting disabled Fixes: lp:1750853 * https://bugs.launchpad.net/kicad/+bug/1750853 --- CMakeLists.txt | 51 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3144ebaac0..ea998ee314 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -679,6 +679,31 @@ if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES ) set( WXPYTHON_VERSION ${_wxpy_version} CACHE STRING "wxPython version found." ) message( STATUS "wxPython version ${_wxpy_version} found." ) + + + # 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 + ) + + # Check if wxWidgets toolkits match, it is a Linux-only issue + if( UNIX AND NOT APPLE AND 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. Please either install wxPython built using " + "${wxWidgets_TOOLKIT_FOUND} or add '-DKICAD_SCRIPTING_WXPYTHON=OFF' to cmake " + "parameters to disable wxPython support." ) + endif() endif() #message( STATUS "PYTHON_INCLUDE_DIRS:${PYTHON_INCLUDE_DIRS}" ) @@ -689,32 +714,6 @@ if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES ) set( INC_AFTER ${INC_AFTER} ${PYTHON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/scripting ) #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 - ) - - # Check if wxWidgets toolkits match, it is a Linux-only issue - if( UNIX AND NOT APPLE AND 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. Please either install wxPython built using " - "${wxWidgets_TOOLKIT_FOUND} or add '-DKICAD_SCRIPTING_WXPYTHON=OFF' to cmake " - "parameters to disable wxPython support." ) - endif() - endif() if( APPLE )