diff --git a/CMakeLists.txt b/CMakeLists.txt index d6e18c2f90..ee43d9eb98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,28 +100,39 @@ option( KICAD_BUILD_QA_TESTS "Build software Quality assurance unit tests (default ON)" ON ) +option( BUILD_GITHUB_PLUGIN + "Build the GITHUB_PLUGIN for pcbnew." + ON ) + +option( KICAD_SPICE + "Build KiCad with internal Spice simulator." + ON ) + # when option KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES is enabled: # PYTHON_EXECUTABLE can be defined when invoking cmake # ( use -DPYTHON_EXECUTABLE=/python.exe or python2 ) # when not defined by user, the default is python.exe under Windows and python2 for others # python binary file should be in exec path. -# KICAD_SCRIPTING_MODULES requires KICAD_SCRIPTING enable it here if KICAD_SCRIPTING_MODULES is ON -if ( KICAD_SCRIPTING_MODULES AND NOT KICAD_SCRIPTING ) - message(STATUS "Changing KICAD_SCRIPTING to ON as needed by KICAD_SCRIPTING_MODULES") - set ( KICAD_SCRIPTING ON ) +# KICAD_SCRIPTING controls the entire python scripting system. If it is off, no other scripting +# functions are available. +if ( NOT KICAD_SCRIPTING ) + message( STATUS "KICAD_SCRIPTING is OFF: Disabling all python scripting support" ) + set( KICAD_SCRIPTING_MODULES OFF ) + set( KICAD_SCRIPTING_ACTION_MENU OFF ) + set( KICAD_SCRIPTING_PYTHON3 OFF ) + set( KICAD_SCRIPTING_WXPYTHON OFF ) + set( KICAD_SCRIPTING_WXPYTHON_PHOENIX OFF) endif() -# same with KICAD_SCRIPTING_ACTION_MENUS -if ( KICAD_SCRIPTING_ACTION_MENU AND NOT KICAD_SCRIPTING ) - message(STATUS "Changing KICAD_SCRIPTING to ON as needed by KICAD_SCRIPTING_ACTION_MENU") - set ( KICAD_SCRIPTING ON ) +# KICAD_SCRIPTING_WXPYTHON_PHOENIX requires enabling the KICAD_SCRIPTING_WXPYTHON flag +# so that the wxWidgets library is properly versioned +if ( KICAD_SCRIPTING AND NOT KICAD_SCRIPTING_WXPYTHON AND KICAD_SCRIPTING_WXPYTHON_PHOENIX ) + message( STATUS + "KICAD_SCRIPTING_WXPYTHON_PHOENIX has been requested, setting KICAD_SCRIPTING_WXPYTHON to ON") + set( KICAD_SCRIPTING_WXPYTHON ON) endif() -option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." ON ) - -option( KICAD_SPICE "Build KiCad with internal Spice simulator." ON ) - # Global setting: exports are explicit set( CMAKE_CXX_VISIBILITY_PRESET "hidden" ) set( CMAKE_VISIBILITY_INLINES_HIDDEN ON ) @@ -627,8 +638,9 @@ set( INC_AFTER ${CMAKE_BINARY_DIR} ) - +# # Find Python and other scripting resources +# if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES ) # SWIG 3.0 or later require for C++11 support. @@ -686,19 +698,36 @@ if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES ) find_package( PythonLibs 2.6 REQUIRED ) endif() - if( KICAD_SCRIPTING_WXPYTHON ) - find_package( wxPython REQUIRED ) - message( STATUS "Found ${WXPYTHON_FLAVOR} " - "${WXPYTHON_VERSION}/${WXPYTHON_TOOLKIT} " - "(wxWidgets ${WXPYTHON_WXVERSION})" ) - endif() - # Infrequently needed headers go at end of search paths, append to INC_AFTER which # although is used for all components, should be a harmless hit for something like eeschema # so long as unused search paths are at the end like this. set( INC_AFTER ${INC_AFTER} ${PYTHON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/scripting ) endif() +# Find the wxPython installation if requested +if( KICAD_SCRIPTING_WXPYTHON ) + find_package( wxPython REQUIRED ) + + if( KICAD_SCRIPTING_WXPYTHON_PHOENIX AND WXPYTHON_VERSION VERSION_LESS 4.0.0 ) + message( FATAL_ERROR + "Unable to find wxPython Phoenix," + " instead found wxPython Classic ${WXPYTHON_VERSION}" ) + endif() + + # The test VERSION_GREATER_EQUAL is only available in cmake >3.7, so use the max possible + # version for the 3.0 line as the basis of the comparison + if( NOT KICAD_SCRIPTING_WXPYTHON_PHOENIX AND WXPYTHON_VERSION VERSION_GREATER 3.9.999 ) + message( FATAL_ERROR + "Unable to find wxPython Classic," + " instead found wxPython Phoenix ${WXPYTHON_VERSION}" ) + endif() + + message( STATUS "Found ${WXPYTHON_FLAVOR} " + "${WXPYTHON_VERSION}/${WXPYTHON_TOOLKIT} " + "(wxWidgets ${WXPYTHON_WXVERSION})" ) +endif() + + # # Find wxWidgets library, required # diff --git a/Documentation/development/compiling.md b/Documentation/development/compiling.md index 574683e1f4..3b16725f6e 100644 --- a/Documentation/development/compiling.md +++ b/Documentation/development/compiling.md @@ -138,35 +138,40 @@ these options and their default values. ## Scripting Support ## {#scripting_opt} The KICAD_SCRIPTING option is used to enable building the Python scripting support into Pcbnew. -This options is enabled by default. +This options is enabled by default, and will disable all other KICAD_SCRIPTING_* options when +it is disabled. + +## Python 3 Scripting Support ## {#python3} + +The KICAD_SCRIPTING_PYTHON3 option is used to enable using Python 3 for the scripting support +instead of Python 2. This option is disabled by default and only is relevant if +[KICAD_SCRIPTING](#scripting_opt) is enabled. ## Scripting Module Support ## {#scripting_mod_opt} The KICAD_SCRIPTING_MODULES option is used to enable building and installing the Python modules -supplied by KiCad. This option is enabled by default and it will enable -[KICAD_SCRIPTING](#scripting_opt) if disabled. - -## Python 3 Scripting Support ## {#python3} - -The KICAD_SCRIPTING_PYTHON3 option is used to enable building of the Python 3 interface instead -of Python 2. This option is disabled by default. +supplied by KiCad. This option is enabled by default, but will be disabled if +[KICAD_SCRIPTING](#scripting_opt) is disabled. ## wxPython Scripting Support ## {#wxpython_opt} The KICAD_SCRIPTING_WXPYTHON option is used to enable building the wxPython interface into -Pcbnew including the wxPython console. This option is enabled by default. +Pcbnew including the wxPython console. This option is enabled by default, but will be disabled if +[KICAD_SCRIPTING](#scripting_opt) is disabled. ## wxPython Phoenix Scripting Support ## {#wxpython_phoenix} The KICAD_SCRIPTING_WXPYTHON_PHOENIX option is used to enable building the wxPython interface with -the new Phoenix binding instead of the legacy one. This option is disabled by default. +the new Phoenix binding instead of the legacy one. This option is disabled by default, and +enabling it requires [KICAD_SCRIPTING](#scripting_opt) to be enabled. ## Python Scripting Action Menu Support ## {#python_action_menu_opt} The KICAD_SCRIPTING_ACTION_MENU option allows Python scripts to be added directly to the Pcbnew -menu. This option is enabled by default and will enable [KICAD_SCRIPTING](#scripting_opt) if -disabled. Please note that this option is highly experimental and can cause Pcbnew to crash -if Python scripts create an invalid object state within Pcbnew. +menu. This option is enabled by default, but will be disabled if +[KICAD_SCRIPTING](#scripting_opt) is disabled. Please note that this option is highly +experimental and can cause Pcbnew to crash if Python scripts create an invalid object state +within Pcbnew. ## GitHub Plugin ## {#github_opt}