Fix 3D plugins mutiarch support.

Use CMAKE_INSTALL_LIBDIR instead of wxStandardPaths::GetPluginsDir() to
determine plugin directory.

Fixes lp:1682812

https://bugs.launchpad.net/kicad/+bug/1682812
This commit is contained in:
Cirilo Bernardo 2017-04-17 01:41:21 +00:00 committed by Wayne Stambaugh
parent 1a75d9979f
commit 68a7a5235e
3 changed files with 20 additions and 8 deletions

View File

@ -36,6 +36,7 @@
#include "common.h" #include "common.h"
#include "pgm_base.h" #include "pgm_base.h"
#include "3d_plugin_dir.h"
#include "3d_plugin_manager.h" #include "3d_plugin_manager.h"
#include "plugins/3d/3d_plugin.h" #include "plugins/3d/3d_plugin.h"
#include "3d_cache/sg/scenegraph.h" #include "3d_cache/sg/scenegraph.h"
@ -132,22 +133,29 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void )
checkPluginPath( testpath, searchpaths ); checkPluginPath( testpath, searchpaths );
#endif #endif
#ifndef _WIN32 // suppress 'kicad' subdir since it is redundant on MSWin #ifndef _WIN32
fn.Assign( wxStandardPaths::Get().GetPluginsDir(), "" ); // multiarch friendly determination of the plugin directory: the executable dir
fn.RemoveLastDir(); // is first determined via wxStandardPaths::Get().GetExecutablePath() and then
fn.AppendDir( wxT( "kicad" ) ); // the CMAKE_INSTALL_LIBDIR path is appended relative to the executable dir.
fn.Assign( wxStandardPaths::Get().GetExecutablePath() );
fn.RemoveLastDir();
wxString tfname = fn.GetPathWithSep();
tfname.Append( wxString::FromUTF8Unchecked( PLUGINDIR ) );
fn.Assign( tfname, "");
fn.AppendDir( "kicad" );
#else #else
// on windows the plugins directory is within the executable's directory
fn.Assign( wxStandardPaths::Get().GetExecutablePath() ); fn.Assign( wxStandardPaths::Get().GetExecutablePath() );
#endif #endif
fn.AppendDir( wxT( "plugins" ) ); fn.AppendDir( wxT( "plugins" ) );
fn.AppendDir( wxT( "3d" ) ); fn.AppendDir( wxT( "3d" ) );
// checks plugin directory relative to executable path
checkPluginPath( std::string( fn.GetPathWithSep().ToUTF8() ), searchpaths ); checkPluginPath( std::string( fn.GetPathWithSep().ToUTF8() ), searchpaths );
checkPluginPath( wxT( "/usr/lib/kicad/plugins/3d" ), searchpaths ); // check for per-user third party plugins
checkPluginPath( wxT( "/usr/local/lib/kicad/plugins/3d" ), searchpaths );
checkPluginPath( wxT( "/opt/kicad/lib/kicad/plugins/3d" ), searchpaths );
// note: GetUserDataDir() gives '.pcbnew' rather than '.kicad' since it uses the exe name; // note: GetUserDataDir() gives '.pcbnew' rather than '.kicad' since it uses the exe name;
fn.Assign( wxStandardPaths::Get().GetUserDataDir(), "" ); fn.Assign( wxStandardPaths::Get().GetUserDataDir(), "" );
fn.RemoveLastDir(); fn.RemoveLastDir();

View File

@ -0,0 +1 @@
#define PLUGINDIR "@CMAKE_INSTALL_LIBDIR@"

View File

@ -1,8 +1,11 @@
#add_definitions(-DPRINT_STATISTICS_3D_VIEWER) #add_definitions(-DPRINT_STATISTICS_3D_VIEWER)
add_definitions(-DPCBNEW) add_definitions(-DPCBNEW)
configure_file( 3d_plugin_dir.h.in 3d_plugin_dir.h @ONLY )
include_directories(BEFORE ${INC_BEFORE}) include_directories(BEFORE ${INC_BEFORE})
include_directories( include_directories(
${CMAKE_CURRENT_BINARY_DIR}
../pcbnew ../pcbnew
../polygon ../polygon
3d_canvas 3d_canvas