Skip to content

Commit

Permalink
Moving towards more flexible layout of QGIS installation.
Browse files Browse the repository at this point in the history
Now it's possible to set QGIS_*_SUBDIR variables in CMake that will determine
the layout of directories for executables, plugins, data, headers and manuals.

These variables are intended to be used by distributors and not ordinary
users thus they're marked as advanced.


git-svn-id: http://svn.osgeo.org/qgis/trunk@7454 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Nov 18, 2007
1 parent 415646a commit 1b4d963
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 32 deletions.
68 changes: 43 additions & 25 deletions CMakeLists.txt
Expand Up @@ -139,19 +139,12 @@ ENDIF (CMAKE_BUILD_TYPE MATCHES Debug)
# platform specific stuff

IF (WIN32)
SET (QGIS_SOURCE_DIR ${CMAKE_SOURCE_DIR})
IF(NOT MSVC)
SET (QGIS_BIN_DIR ${CMAKE_INSTALL_PREFIX})
SET (QGIS_DATA_DIR ${CMAKE_INSTALL_PREFIX})
SET (QGIS_PLUGIN_DIR ${CMAKE_INSTALL_PREFIX}/plugins)
SET (QGIS_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
ELSE (NOT MSVC)
# FIXME:
# . just deals with leading / where these macros are used.
SET (QGIS_BIN_DIR .)
SET (QGIS_DATA_DIR .)
SET (QGIS_PLUGIN_DIR plugins)
SET (QGIS_INCLUDE_DIR include)
SET (DEFAULT_BIN_SUBDIR .)
SET (DEFAULT_DATA_SUBDIR .)
SET (DEFAULT_PLUGIN_SUBDIR plugins)
SET (DEFAULT_INCLUDE_SUBDIR include)

IF (MSVC)
#tell msvc compiler to use main instead of winmain as the
#application entry point
SET(QT_USE_QTMAIN TRUE)
Expand All @@ -168,11 +161,9 @@ IF (WIN32)
ADD_DEFINITIONS(-DW_OK=2)
ADD_DEFINITIONS(-DR_OK=4)

# ADD_DEFINITIONS(-DQGISDEBUG)

FILE(GLOB files "${CMAKE_SOURCE_DIR}/win_build/vcdeps/*.*")
INSTALL(FILES ${files} DESTINATION .)
ENDIF(NOT MSVC)
ENDIF(MSVC)
ELSE (WIN32)

IF (APPLE)
Expand All @@ -183,12 +174,10 @@ ELSE (WIN32)
ENDIF (APPLE)

# common for MAC and UNIX
SET (QGIS_BIN_DIR ${CMAKE_INSTALL_PREFIX}/bin)
SET (QGIS_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/qgis)
SET (QGIS_PLUGIN_DIR ${CMAKE_INSTALL_PREFIX}/lib/qgis)
SET(QGIS_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include/qgis")
SET (QGIS_SOURCE_DIR ${CMAKE_SOURCE_DIR})

SET (DEFAULT_BIN_SUBDIR bin)
SET (DEFAULT_DATA_SUBDIR share/qgis)
SET (DEFAULT_PLUGIN_SUBDIR lib/qgis)
SET (DEFAULT_INCLUDE_SUBDIR include/qgis)

IF (UNIX AND NOT APPLE)
ADD_DEFINITIONS(-DPREFIX=\\"${CMAKE_INSTALL_PREFIX}\\")
Expand Down Expand Up @@ -216,6 +205,33 @@ ELSE (WIN32)
ADD_DEFINITIONS(-DGUI_EXPORT=)
ENDIF (WIN32)

#############################################################
# user-changeable settings which can be used to customize
# layout of QGIS installation
# (default values are platform-specific)

SET (QGIS_BIN_SUBDIR ${DEFAULT_BIN_SUBDIR} CACHE STRING "Subdirectory where executables will be installed")
SET (QGIS_DATA_SUBDIR ${DEFAULT_DATA_SUBDIR} CACHE STRING "Subdirectory where QGIS data will be installed")
SET (QGIS_PLUGIN_SUBDIR ${DEFAULT_PLUGIN_SUBDIR} CACHE STRING "Subdirectory where plugins will be installed")
SET (QGIS_INCLUDE_SUBDIR ${DEFAULT_INCLUDE_SUBDIR} CACHE STRING "Subdirectory where header files will be installed")

# mark *_SUBDIR variables as advanced as this is not something
# that an average user would use
MARK_AS_ADVANCED (QGIS_BIN_SUBDIR QGIS_DATA_SUBDIR QGIS_PLUGIN_SUBDIR QGIS_INCLUDE_SUBDIR)

# full paths for the installation
SET (QGIS_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${QGIS_BIN_SUBDIR})
SET (QGIS_DATA_DIR ${CMAKE_INSTALL_PREFIX}/${QGIS_DATA_SUBDIR})
SET (QGIS_PLUGIN_DIR ${CMAKE_INSTALL_PREFIX}/${QGIS_PLUGIN_SUBDIR})
SET (QGIS_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/${QGIS_INCLUDE_SUBDIR})

# manual page - makes sense only on unix systems
IF (UNIX)
SET (DEFAULT_MANUAL_SUBDIR man)
SET (QGIS_MANUAL_SUBDIR ${DEFAULT_MANUAL_SUBDIR} CACHE STRING "Subdirectory where manual files will be installed")
MARK_AS_ADVANCED (QGIS_MANUAL_SUBDIR)
SET (QGIS_MANUAL_DIR ${CMAKE_INSTALL_PREFIX}/${QGIS_MANUAL_SUBDIR})
ENDIF (UNIX)

#############################################################
# create qgsconfig.h
Expand Down Expand Up @@ -266,9 +282,11 @@ ENDIF (ENABLE_TESTS)
INSTALL (FILES AUTHORS SPONSORS
DESTINATION ${QGIS_DATA_DIR}/doc)

# manual page... install also on windows?
INSTALL (FILES qgis.man
DESTINATION ${CMAKE_INSTALL_PREFIX}/man/man1)
# manual page - makes sense only on unix systems
IF (UNIX)
INSTALL (FILES qgis.man
DESTINATION ${QGIS_MANUAL_DIR}/man1)
ENDIF (UNIX)


#############################################################
Expand Down
3 changes: 3 additions & 0 deletions cmake_templates/qgsconfig.h.in
Expand Up @@ -8,6 +8,9 @@

#define PREFIX "${CMAKE_INSTALL_PREFIX}"

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

#cmakedefine HAVE_POSTGRESQL

#cmakedefine HAVE_PYTHON
Expand Down
9 changes: 2 additions & 7 deletions src/core/qgsapplication.cpp
Expand Up @@ -65,13 +65,8 @@ void QgsApplication::setPrefixPath(const QString& thePrefixPath, bool useDefault
mPrefixPath = thePrefixPath;
if (useDefaultPaths)
{
#if defined(Q_WS_WIN32)
setPluginPath(mPrefixPath + QString("/plugins"));
setPkgDataPath(mPrefixPath);
#else
setPluginPath(mPrefixPath + QString("/lib/qgis"));
setPkgDataPath(mPrefixPath + QString("/share/qgis"));
#endif
setPluginPath(mPrefixPath + QString("/") + QString(QGIS_PLUGIN_SUBDIR));
setPkgDataPath(mPrefixPath + QString("/") + QString(QGIS_DATA_SUBDIR));
}
}

Expand Down

0 comments on commit 1b4d963

Please sign in to comment.