Allow setting the kicad config dir

This allows setting the config dir at build time, providing packagers a
method of controlling where the configuration files are placed.

Fixes: lp:1780601
* https://bugs.launchpad.net/kicad/+bug/1780601
This commit is contained in:
Seth Hillbrand 2019-04-08 12:28:14 -07:00
parent 9c00a7a5c3
commit 257d9b5fe9
4 changed files with 25 additions and 10 deletions

View File

@ -128,11 +128,9 @@ option( KICAD_SPICE "Build KiCad with internal Spice simulator." ON )
set( CMAKE_CXX_VISIBILITY_PRESET "hidden" )
set( CMAKE_VISIBILITY_INLINES_HIDDEN ON )
# Global setting: build everything position independent
set( CMAKE_POSITION_INDEPENDENT_CODE ON )
# Global setting: Use C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@ -160,12 +158,9 @@ endif()
# Add option to add user directories for linker, if any
LINK_DIRECTORIES( ${LINK_DIRECTORIES_PATH} )
if( UNIX )
set( KICAD_USER_CONFIG_DIR $ENV{HOME} CACHE PATH "Location of user specific KiCad config files" )
elseif( MINGW )
set( KICAD_USER_CONFIG_DIR $ENV{APPDATA} CACHE PATH "Location of user specific KiCad config files" )
endif()
mark_as_advanced( KICAD_USER_CONFIG_DIR )
set( KICAD_CONFIG_DIR "kicad" CACHE STRING "Location of user specific KiCad config files" )
mark_as_advanced( KICAD_CONFIG_DIR )
add_definitions( -DKICAD_CONFIG_DIR=${KICAD_CONFIG_DIR} )
# Set default data file path to CMAKE_INSTALL_PREFIX if it wasn't specified during the
# CMake configuration. The value of DEFAULT_INSTALL_PATH is expanded in config.h and

View File

@ -144,7 +144,7 @@ so use at your own risk.
## Graphics Context Overlay ## {#overlay_opt}
The USE_WX_OVERLAY option is used to enable the optional wxOverlay class for graphics rendering
on macOS. This is enabled on macOS by default and disabled on all other platforms.
on macOS. This is enabled on macOS and GTK3 by default and disabled on all other platforms.
## Scripting Support ## {#scripting_opt}
@ -222,6 +222,18 @@ information as follows:
|
output of `git describe --dirty` if git is available.
## KiCad Config Directory ## {#config_dir_opt}
The default KiCad configuration directory is `kicad`. On Linux this is located at
`~/.config/kicad`, on MSW, this is `C:\Documents and Settings\username\Application Data\kicad` and
on MacOS, this is `~/Library/Preferences/kicad`. If the installation package would like to, it may
specify an alternate configuration name instead of `kicad`. This may be useful for versioning
the configuration parameters and allowing the use of, e.g. `kicad5` and `kicad6` concurrently without
losing configuration data.
This is set by specifying the KICAD_CONFIG_DIR string at compile time.
# Getting the KiCad Source Code ## {#getting_src}
There are several ways to get the KiCad source. If you want to build the stable version you

View File

@ -288,7 +288,7 @@ wxString GetKicadConfigPath()
cfgpath.AssignDir( envstr );
}
cfgpath.AppendDir( wxT( "kicad" ) );
cfgpath.AppendDir( TO_STR( KICAD_CONFIG_DIR ) );
// Use KICAD_CONFIG_HOME to allow the user to force a specific configuration path.
if( wxGetEnv( wxT( "KICAD_CONFIG_HOME" ), &envstr ) && !envstr.IsEmpty() )

View File

@ -46,6 +46,14 @@
*/
#define TO_UTF8( wxstring ) ( (const char*) (wxstring).utf8_str() )
/**
* Stringifies the given parameter by placing in quotes
* @param cstring STRING (no spaces)
* @return "STRING"
*/
#define TO_STR2(x) #x
#define TO_STR(x) TO_STR2(x)
/**
* function FROM_UTF8
* converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.