← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Use absolute path CMAKE_INSTALL_FULL_LIBDIR for 3d viewer PLUGINDIR

 

Hi Stefan,

On 12/11/2018 11:17 AM, Brüns, Stefan wrote:
> On Sonntag, 9. Dezember 2018 18:07:21 CET Wayne Stambaugh wrote:
>> Stefan,
>>
>> I tested you patch and it seems to work fine on linux.  However, it also
>> affects macos which I'm not sure that it wont break something.  Would
>> one of our macos devs please take a look at this patch when you get a
>> chance.
> 
> Hi Wayne,
> 
> I am quite sure it does not affect MacOS, as the changed code block is guarded 
> by #ifndef __WXMAC__ [1], and PLUGINDIR is not used outside the block as far 
> as I can see.
> 
> Kind regards,
> 
> Stefan
> 
> [1] https://git.launchpad.net/kicad/tree/3d-viewer/3d_cache/
> 3d_plugin_manager.cpp#n123

The patch I'm looking at applies at line 149 which is inside #ifndef
_WIN32 block which would effect both linux and macos.  Is it possible
this code changed you submitted the patch (it does apply cleanly) or I
have the wrong patch.  I've attached the patch I tested just in case.

Cheers,

Wayne
From 3f1f474f8ceab75acda7c1d0a36cc9c33c6124b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@xxxxxxxxxxxxxx>
Date: Tue, 9 Oct 2018 17:35:55 +0200
Subject: [PATCH] Use absolute path CMAKE_INSTALL_FULL_LIBDIR for 3d viewer
 PLUGINDIR

Currently, the plugindir in the plugin manager is constructed as
{CMAKE_INSTALL_PREFIX}/bin/../{CMAKE_INSTALL_LIBDIR}/kicad/..., while
CMakes install uses {CMAKE_INSTALL_LIBDIR}/kicad/...

In case CMAKE_INSTALL_LIBDIR is a relative path "install" prefixes it
with CMAKE_INSTALL_PREFIX and both paths happen to match, otherwise
the constructed path ends up as e.g. "/usr/bin/../usr/lib/kicad/...".

For these cases where an absolute path is wanted CMake provides the
CMAKE_INSTALL_FULL_<dir> variants which works the same as
CMAKE_INSTALL_<dir> when used as DIRECTORY for install.
---
 3d-viewer/3d_cache/3d_plugin_manager.cpp | 10 +++-------
 3d-viewer/3d_plugin_dir.h.in             |  2 +-
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/3d-viewer/3d_cache/3d_plugin_manager.cpp b/3d-viewer/3d_cache/3d_plugin_manager.cpp
index 52f2cef..fc561e7 100644
--- a/3d-viewer/3d_cache/3d_plugin_manager.cpp
+++ b/3d-viewer/3d_cache/3d_plugin_manager.cpp
@@ -149,14 +149,10 @@ void S3D_PLUGIN_MANAGER::loadPlugins( void )
     #endif
 
     #ifndef _WIN32
-        // multiarch friendly determination of the plugin directory: the executable dir
-        // is first determined via wxStandardPaths::Get().GetExecutablePath() and then
-        // the CMAKE_INSTALL_LIBDIR path is appended relative to the executable dir.
+        // PLUGINDIR = CMAKE_INSTALL_FULL_LIBDIR path is the absolute path
+        // corresponding to the install path used for constructing KICAD_USER_PLUGIN
 
-        fn.Assign( wxStandardPaths::Get().GetExecutablePath() );
-        fn.RemoveLastDir();
-        wxString tfname = fn.GetPathWithSep();
-        tfname.Append( wxString::FromUTF8Unchecked( PLUGINDIR ) );
+        wxString tfname = wxString::FromUTF8Unchecked( PLUGINDIR );
         fn.Assign( tfname, "");
         fn.AppendDir( "kicad" );
     #else
diff --git a/3d-viewer/3d_plugin_dir.h.in b/3d-viewer/3d_plugin_dir.h.in
index 6cf6de2..fb923ec 100644
--- a/3d-viewer/3d_plugin_dir.h.in
+++ b/3d-viewer/3d_plugin_dir.h.in
@@ -1 +1 @@
-#define PLUGINDIR "@CMAKE_INSTALL_LIBDIR@"
+#define PLUGINDIR "@CMAKE_INSTALL_FULL_LIBDIR@"
-- 
2.19.0


Follow ups

References