Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Dont use PREFIX on linux (or anywhere else). On linux assume prefix i…
…s appdirpath/.

This fixes issues where qgis is nor relocatable after building, and removes cmake warnings about duplicate definition of PREFIX. Note that to be relocatable you should not build using rpath support..


git-svn-id: http://svn.osgeo.org/qgis/trunk@8472 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed May 19, 2008
1 parent 0ec3ee1 commit 19549ff
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 23 deletions.
4 changes: 0 additions & 4 deletions CMakeLists.txt
Expand Up @@ -229,10 +229,6 @@ ELSE (WIN32)
SET (DEFAULT_PLUGIN_SUBDIR lib/qgis)
SET (DEFAULT_INCLUDE_SUBDIR include/qgis)

IF (UNIX AND NOT APPLE)
ADD_DEFINITIONS(-DPREFIX=${CMAKE_INSTALL_PREFIX})
ENDIF (UNIX AND NOT APPLE)

ENDIF (WIN32)


Expand Down
2 changes: 0 additions & 2 deletions cmake_templates/qgsconfig.h.in
Expand Up @@ -15,8 +15,6 @@
//used in main.cpp and anywhere else where the release name is needed
#define RELEASE_NAME "${RELEASE_NAME}"

#define PREFIX "${CMAKE_INSTALL_PREFIX}"

#define QGIS_PLUGIN_SUBDIR "${QGIS_PLUGIN_SUBDIR}"
#define QGIS_DATA_SUBDIR "${QGIS_DATA_SUBDIR}"

Expand Down
16 changes: 15 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -1198,7 +1198,14 @@ void QgisApp::createStatusBar()
QString myIconPath = QgsApplication::themePath();
myProjPixmap.load(myIconPath+"/mIconProjectionDisabled.png");
mOnTheFlyProjectionStatusButton->setPixmap(myProjPixmap);
assert(!myProjPixmap.isNull());
QgsDebugMsg("Icon Path: " + myIconPath.toLocal8Bit());
if (myProjPixmap.isNull())
{
QMessageBox::critical(this, tr("Resource Location Error"),
tr("Error reading icon resources from: \n %1\n Quitting...").arg(myIconPath));

exit(0);
}
mOnTheFlyProjectionStatusButton->setWhatsThis(tr("This icon shows whether on the fly projection is enabled or not. Click the icon to bring up the project properties dialog to alter this behaviour."));
mOnTheFlyProjectionStatusButton->setToolTip(tr("Projection status - Click to open projection dialog"));
connect(mOnTheFlyProjectionStatusButton, SIGNAL(clicked()),
Expand Down Expand Up @@ -1624,6 +1631,7 @@ void QgisApp::restoreSessionPlugins(QString thePluginDirString)
{
QSettings mySettings;

QgsDebugMsg("\n\n*************************************************");
QgsDebugMsg("Restoring plugins from last session " + thePluginDirString);

#ifdef WIN32
Expand Down Expand Up @@ -1664,6 +1672,10 @@ void QgisApp::restoreSessionPlugins(QString thePluginDirString)

loadPlugin(myName(), myDescription(), myFullPath);
}
else
{
QgsDebugMsg("Plugin was not active last session, leaving disabled: " + myEntryName);
}
}
else
{
Expand Down Expand Up @@ -1718,6 +1730,8 @@ void QgisApp::restoreSessionPlugins(QString thePluginDirString)
}
}
#endif
QgsDebugMsg("Loading plugins completed");
QgsDebugMsg("*************************************************\n\n");
}


Expand Down
44 changes: 36 additions & 8 deletions src/core/qgsapplication.cpp
Expand Up @@ -21,6 +21,7 @@
#include <QDir>

#include <qgsconfig.h>
#include <qgslogger.h>

// for htonl
#ifdef WIN32
Expand Down Expand Up @@ -50,42 +51,69 @@ QString QgsApplication::mThemePath;
QgsApplication::QgsApplication(int & argc, char ** argv, bool GUIenabled)
: QApplication(argc, argv, GUIenabled)
{
QgsDebugMsg("\n**********************************");
QgsDebugMsg("\nInitialising QgsApplication...");
#if defined(Q_WS_MACX) || defined(Q_WS_WIN32) || defined(WIN32)
setPrefixPath(applicationDirPath(), TRUE);
setPrefixPath(applicationDirPath(), true);
#else
setPrefixPath(PREFIX, TRUE);
QDir myDir(applicationDirPath());
myDir.cdUp();
QString myPrefix = myDir.absolutePath();
QgsDebugMsg("Prefix: " + myPrefix.toLocal8Bit());
setPrefixPath(myPrefix, true);
#endif
QgsDebugMsg("\nPlugin Path:" + mPluginPath);
QgsDebugMsg("\nPkgData Path:" + mPkgDataPath);
QgsDebugMsg("\nTheme Path:" + mThemePath);
QgsDebugMsg("\n**********************************\n");
}

QgsApplication::~QgsApplication()
{}

void QgsApplication::setPrefixPath(const QString& thePrefixPath, bool useDefaultPaths)
void QgsApplication::setPrefixPath(const QString thePrefixPath, bool useDefaultPaths)
{
mPrefixPath = thePrefixPath;
if (useDefaultPaths)
{
setPluginPath(mPrefixPath + QString("/") + QString(QGIS_PLUGIN_SUBDIR));
setPkgDataPath(mPrefixPath + QString("/") + QString(QGIS_DATA_SUBDIR));
setPluginPath(mPrefixPath + QDir::separator() + QString(QGIS_PLUGIN_SUBDIR));
setPkgDataPath(mPrefixPath + QDir::separator() + QString(QGIS_DATA_SUBDIR));
}
}

void QgsApplication::setPluginPath(const QString& thePluginPath)
void QgsApplication::setPluginPath(const QString thePluginPath)
{
mPluginPath = thePluginPath;
QgsDebugMsg("\n\n\n\n\n +++++++++++++++++++++++\n plugin path changed\n" + mPluginPath + "\n +++++++++++++++++ \n\n\n\n");
}

void QgsApplication::setPkgDataPath(const QString& thePkgDataPath)
void QgsApplication::setPkgDataPath(const QString thePkgDataPath)
{
mPkgDataPath = thePkgDataPath;
mThemePath = mPkgDataPath + QString("/themes/default/");
}

const QString QgsApplication::prefixPath()
{
return mPrefixPath;
}
const QString QgsApplication::pluginPath()
{
return mPluginPath;
}
const QString QgsApplication::pkgDataPath()
{
return mPkgDataPath;
}
const QString QgsApplication::themePath()
{
return mThemePath;
}

/*!
Set the theme path to the specified theme.
*/
void QgsApplication::selectTheme(const QString& theThemeName)
void QgsApplication::selectTheme(const QString theThemeName)
{
mThemePath = mPkgDataPath + QString("/themes/") + theThemeName + QString("/");
}
Expand Down
16 changes: 8 additions & 8 deletions src/core/qgsapplication.h
Expand Up @@ -25,7 +25,7 @@ class CORE_EXPORT QgsApplication: public QApplication
virtual ~QgsApplication();

//! Set the theme path to the specified theme.
static void selectTheme(const QString& theThemeName);
static void selectTheme(const QString theThemeName);

//! Returns the path to the authors file.
static const QString authorsFilePath();
Expand Down Expand Up @@ -67,25 +67,25 @@ class CORE_EXPORT QgsApplication: public QApplication
static const QString svgPath();

//! Returns the path to the application prefix directory.
static const QString& prefixPath() { return mPrefixPath; }
static const QString prefixPath();

//! Returns the path to the application plugin directory.
static const QString& pluginPath() { return mPluginPath; }
static const QString pluginPath();

//! Returns the common root path of all application data directories.
static const QString& pkgDataPath() { return mPkgDataPath; }
static const QString pkgDataPath();

//! Returns the path to the current theme directory.
static const QString& themePath() { return mThemePath; }
static const QString themePath();

//! Alters prefix path - used by 3rd party apps
static void setPrefixPath(const QString& thePrefixPath, bool useDefaultPaths = FALSE);
static void setPrefixPath(const QString thePrefixPath, bool useDefaultPaths = FALSE);

//! Alters plugin path - used by 3rd party apps
static void setPluginPath(const QString& thePluginPath);
static void setPluginPath(const QString thePluginPath);

//! Alters pkg data path - used by 3rd party apps
static void setPkgDataPath(const QString& thePkgDataPath);
static void setPkgDataPath(const QString thePkgDataPath);

//! loads providers
static void initQgis();
Expand Down

0 comments on commit 19549ff

Please sign in to comment.