Use KICAD_DATA for data path lookup in scripting

Fixes https://gitlab.com/kicad/code/kicad/issues/7036
This commit is contained in:
Seth Hillbrand 2021-01-12 08:19:59 -08:00
parent cd2c46e5c9
commit 2cb8dff650
3 changed files with 14 additions and 3 deletions

View File

@ -490,8 +490,14 @@ if( NOT APPLE )
set( KICAD_BIN bin
CACHE PATH "Location of KiCad binaries." )
set( KICAD_DATA ${CMAKE_INSTALL_DATADIR}/kicad
CACHE PATH "Location of KiCad data files." )
# Do not make these variables "PATH" b/c cmake will truncate them and we need the full path
if( NOT IS_ABSOLUTE ${CMAKE_INSTALL_DATADIR} )
set( KICAD_DATA ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/kicad
CACHE STRING "Location of KiCad data files." )
else()
set( KICAD_DATA ${CMAKE_INSTALL_DATADIR}/kicad
CACHE STRING "Location of KiCad data files." )
endif()
if( WIN32 )
set( KICAD_PLUGINS ${KICAD_BIN}/scripting/plugins

View File

@ -77,6 +77,9 @@
/// Allows scripts install directory to be referenced by the program code.
#define PYTHON_DEST "@PYTHON_DEST@"
/// Allows scripts install directory to be referenced by the program code.
#define KICAD_DATA "@KICAD_DATA@"
/// ngspice version string detected by pkg-config when available.
#cmakedefine NGSPICE_BUILD_VERSION "@NGSPICE_BUILD_VERSION@"

View File

@ -41,6 +41,8 @@
#include <wx/app.h>
#include <config.h>
/* init functions defined by swig */
#if PY_MAJOR_VERSION >= 3
@ -658,7 +660,7 @@ wxString PyScriptingPath( bool aUserPath )
#if defined( __WXMAC__ )
path = GetOSXKicadDataDir() + wxT( "/scripting" );
#else
path = Pgm().GetExecutablePath() + wxT( "../share/kicad/scripting" );
path = Pgm().GetExecutablePath() + KICAD_DATA + wxS( "/scripting" );
#endif
}
}