mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-07 17:25:33 +00:00
Make run from build dir work for debug executables
When using KICAD_RUN_FROM_BUILD_DIR, at least on Linux, not all executables can assume executable/.. is the build directory - instead iterate upwards until a CMakeCache.txt file in encountered. Without this, for example, the PNS log viewer complains about missing JSON schema files.
This commit is contained in:
parent
51606e80d5
commit
d0d4c4065b
@ -148,6 +148,28 @@ wxString PATHS::GetDefaultUserProjectsPath()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the CMake build root directory for the current executable
|
||||
* (which assumes the executable is in a build directory).
|
||||
*
|
||||
* This is done because not all executable are located at the same
|
||||
* depth in the build directory.
|
||||
*/
|
||||
static wxString getCmakeBuildRoot()
|
||||
{
|
||||
wxFileName fn = PATHS::GetExecutablePath();
|
||||
// The build directory will have a CMakeCache.txt file in it
|
||||
while( fn.GetDirCount() > 0 && !wxFileExists( fn.GetPathWithSep() + wxT( "CMakeCache.txt" ) ) )
|
||||
{
|
||||
fn.RemoveLastDir();
|
||||
}
|
||||
|
||||
wxASSERT_MSG( fn.GetDirCount() > 0, wxT( "Could not find CMake build root directory" ) );
|
||||
|
||||
return fn.GetPath();
|
||||
}
|
||||
|
||||
|
||||
wxString PATHS::GetStockDataPath( bool aRespectRunFromBuildDir )
|
||||
{
|
||||
wxString path;
|
||||
@ -166,7 +188,7 @@ wxString PATHS::GetStockDataPath( bool aRespectRunFromBuildDir )
|
||||
#elif defined( __WXMSW__ )
|
||||
path = getWindowsKiCadRoot();
|
||||
#else
|
||||
path = GetExecutablePath() + wxT( ".." );
|
||||
path = getCmakeBuildRoot();
|
||||
#endif
|
||||
}
|
||||
else if( wxGetEnv( wxT( "KICAD_STOCK_DATA_HOME" ), &path ) && !path.IsEmpty() )
|
||||
|
Loading…
Reference in New Issue
Block a user