diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d35d542f7..4a6dae6c63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,12 @@ option(KICAD_SCRIPTING_WXPYTHON "set this option ON to build wxpython implementation for wx interface building in python and py.shell" ) +# 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 filee should be is exec path. + #Set version option (stable or testing) @@ -259,7 +265,15 @@ endif(WIN32 AND USE_WX_GRAPHICS_CONTEXT) # Find Python and other scripting resources if (KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES) - execute_process(COMMAND python2 -c "import sys;print\"%s.%s\"%sys.version_info[0:2]" OUTPUT_VARIABLE PYTHON_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) + if( "${PYTHON_EXECUTABLE}" STREQUAL "" ) + if(WIN32) + SET( PYTHON_EXECUTABLE "python.exe" ) + else(WIN32) + SET( PYTHON_EXECUTABLE "python2" ) + endif(WIN32) + endif() + + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys;print\"%s.%s\"%sys.version_info[0:2]" OUTPUT_VARIABLE PYTHON_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) set(PYTHON_DEST "lib/python${PYTHON_VERSION}/dist-packages" ) find_package(PythonLibs) include_directories(${PYTHON_INCLUDE_PATH} diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index b7e743b01d..478e3e820e 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -301,7 +301,7 @@ if (KICAD_SCRIPTING) DEPENDS ../scripting/kicadplugins.i COMMAND ${SWIG_EXECUTABLE} ${SWIG_OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx scripting/pcbnew.i - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../scripting/fixswigimports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../scripting/fixswigimports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) @@ -432,9 +432,9 @@ install(TARGETS pcbnew if(KICAD_SCRIPTING) add_custom_target(FixSwigImportsScripting ALL - ${CMAKE_CURRENT_SOURCE_DIR}/../scripting/fixswigimports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../scripting/fixswigimports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pcbnew - COMMENT "Fixing swig_import_helper" + COMMENT "Fixing swig_import_helper in Kicad scripting" ) @@ -444,9 +444,9 @@ endif(KICAD_SCRIPTING) if (KICAD_SCRIPTING_MODULES) add_custom_target(FixSwigImportsModuleScripting ALL - ${CMAKE_CURRENT_SOURCE_DIR}/../scripting/fixswigimports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../scripting/fixswigimports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew - COMMENT "Fixing swig_import_helper" + COMMENT "Fixing swig_import_helper in Kicad scripting modules" )