From 4274f2d5d5ebbd91b694c1899758e3b48512fcf2 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Wed, 8 Apr 2015 13:27:04 -0400 Subject: [PATCH] Fix config.h default data install path assignment during configuration. * Remove redundant definition of KICAD_DATA_PATH since DEFAULT_INSTALL_PATH was already defined. * Use DEFAULT_INSTALL_PATH as the substitution for the default environment variable paths. * Add option to define DEFAULT_INSTALL_PATH during CMake configuration with fall back to CMAKE_INSTALL_PREFIX if not not defined. * Developer note: this change is primarily for package builders where CMAKE_INSTALL_PATH is the path where the package builder temporarily installs the build output before creating the package. When building packages, DEFAULT_INSTALL_PATH should be set to the path where the package will be installed by default. --- CMakeLists.txt | 12 +++++++++++- CMakeModules/config.h.cmake | 13 ++----------- common/pgm_base.cpp | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c37ff3bd4..154aaaeeff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,7 +94,7 @@ set( KICAD_REPO_NAME "product" CACHE STRING "Name of the tree from which this bu set( DOWNLOAD_DIR ${PROJECT_SOURCE_DIR}/.downloads-by-cmake CACHE PATH "Location of KiCad downloads, suggested is a dir common to all builds, i.e. global." ) -#Add option to add user directories for linker, if any +# Add option to add user directories for linker, if any LINK_DIRECTORIES( ${LINK_DIRECTORIES_PATH} ) if( UNIX ) @@ -104,6 +104,16 @@ elseif( MINGW ) endif() mark_as_advanced( KICAD_USER_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 +# used in the source code to define the base path for kicad search paths and environment +# variables. +if( NOT DEFAULT_INSTALL_PATH ) + set( DEFAULT_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}" + CACHE + PATH + "Location of KiCad data files." ) +endif() #================================================ # Set flags for GCC, or treat llvm as GCC diff --git a/CMakeModules/config.h.cmake b/CMakeModules/config.h.cmake index b7b6cbfe56..bc4e50ac9d 100644 --- a/CMakeModules/config.h.cmake +++ b/CMakeModules/config.h.cmake @@ -58,17 +58,8 @@ /// The legacy file format revision of the *.brd file created by this build #define LEGACY_BOARD_FILE_VERSION 2 -/// The install prefix defined in CMAKE_INSTALL_PREFIX. -#define DEFAULT_INSTALL_PATH "@CMAKE_INSTALL_PREFIX@" - -/// The install prefix used for KiCad's libraries. -/// These paths are only intended to be reasonable default values that work if -/// the user installs KiCad in the default path for a given platform. -#if defined( __APPLE__ ) -#define KICAD_DATA_PATH "/Library/Application Support/kicad" -#else -#define KICAD_DATA_PATH "@CMAKE_INSTALL_PREFIX@/@KICAD_DATA@" -#endif +/// The install prefix defined during CMake configuration or fall back to CMAKE_INSTALL_PREFIX. +#define DEFAULT_INSTALL_PATH "@DEFAULT_INSTALL_PATH@" /// The wxPython version found during configuration. #if defined( KICAD_SCRIPTING_WXPYTHON ) diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp index e927327203..f4c8f86e96 100644 --- a/common/pgm_base.cpp +++ b/common/pgm_base.cpp @@ -423,7 +423,7 @@ bool PGM_BASE::initPgm() m_local_env_vars[ envVarName ] = envVarItem; wxFileName tmpFileName; - tmpFileName.AssignDir( wxString( wxT( KICAD_DATA_PATH ) ) ); + tmpFileName.AssignDir( wxString( wxT( DEFAULT_INSTALL_PATH ) ) ); tmpFileName.AppendDir( wxT( "modules" ) ); envVarName = wxT( "KISYSMOD" ); envVarItem.SetValue( tmpFileName.GetPath() );