From 2afa67f946560afe65627b3f7aa11ca2c6c477ec Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 3 Mar 2025 12:34:31 -0800 Subject: [PATCH] Allow AppImages to pick out different location Don't assume that libraries are located in the CMAKE lib install directory as AppImage will relocate them based on the mount point --- common/paths.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/common/paths.cpp b/common/paths.cpp index eca85e5a2c..388d6aefea 100644 --- a/common/paths.cpp +++ b/common/paths.cpp @@ -381,10 +381,24 @@ wxString PATHS::GetStockPlugins3DPath() fn.AppendDir( wxT( "PlugIns" ) ); } #else - // KICAD_PLUGINDIR = CMAKE_INSTALL_FULL_LIBDIR path is the absolute path - // corresponding to the install path used for constructing KICAD_USER_PLUGIN - wxString tfname = wxString::FromUTF8Unchecked( KICAD_PLUGINDIR ); - fn.Assign( tfname, "" ); + wxString envPath; + + // AppImages have a different path to the plugins, otherwise we end up with host sytem + // plugins being loaded. + if( wxGetEnv( wxT( "APPIMAGE" ), nullptr ) && wxGetEnv( wxT( "APPDIR" ), &envPath ) ) + { + fn.AssignDir( envPath ); + fn.AppendDir( wxT( "usr" ) ); + fn.AppendDir( wxT( "lib" ) ); + } + else + { + // KICAD_PLUGINDIR = CMAKE_INSTALL_FULL_LIBDIR path is the absolute path + // corresponding to the install path used for constructing KICAD_USER_PLUGIN + wxString tfname = wxString::FromUTF8Unchecked( KICAD_PLUGINDIR ); + fn.Assign( tfname, "" ); + } + fn.AppendDir( wxT( "kicad" ) ); fn.AppendDir( wxT( "plugins" ) ); #endif